Jump to content

How to change Readonly property in VB.Net


raviprakashg

Recommended Posts

Are you talking about a System.Web.UI.WebControls.TextBox or System.Windows.Forms.TextBox? You're only going to be able to change the font in a TextBox if it is a System.Windows.Forms.TextBox. HTML/CSS doesn't allow you to style <input type="text" /> controls so System.Web.UI.WebControls.TextBox.Font is a read-only property.

Link to comment
Share on other sites

I would think that it should give you an error. It might compile, but you should at least get a runtime error.According to Microsoft, in Visual Basic, the Font property is ReadOnly and in C#, there is only a getter defined (no setter).EDIT: of course, I don't have any idea because all of my style stuff is taken care of in CSS rather than compiled code :) I would prefer changing the CssClass rather than playing with the Font:

txt.CssClass = "InputSelected"

Link to comment
Share on other sites

Jesh I read that article you linked to. I think it is Font that is readonly. Font only has a getter but it's properties are settable....they even change some in the code below.
Interesting. Thanks for the clarification.Anyhow, like I said in my edit above, I typically set CssClass for an object in the compiled code rather than specific styles so that, if it came to it, I would simply have to change a CSS file rather than change some VB/C# and then completely rebuild (and/or republish) the entire website.
Link to comment
Share on other sites

Interesting. Thanks for the clarification.Anyhow, like I said in my edit above, I typically set CssClass for an object in the compiled code rather than specific styles so that, if it came to it, I would simply have to change a CSS file rather than change some VB/C# and then completely rebuild (and/or republish) the entire website.
I agree that is the best method, leave it to MS to give you the option of bad programming.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...