|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to set property "ReadOnly" on all TextBoxes on a WebFormHello,
I'm in the process of learning asp.net and WebForms. Could somebody indicate how I can write code to control the properties of the (TextBox) controls on a WebForm.?Thanks. Dan Kimhi Use the Page_Load method in your
-- Show quoteHide quoteChristopher A. Reed "The oxen are slow, but the earth is patient."code-behind. "Dan Kimhi" <d**@sof.fr> wrote in message news:%23DrYHngNGHA.2036@TK2MSFTNGP14.phx.gbl... > Hello, > > I'm in the process of learning asp.net and WebForms. > > Could somebody indicate how I can write code to control the properties of > the (TextBox) controls on a WebForm.?Thanks. > > Dan Kimhi > txtbox1.readonly = True
txtbox2.readonly = True or depending on the situation you could use; txtbox1.enabled = False txtbox2.enabled = False or txtbox1.visible = False txtbox2.visible = False You can do this in the Public Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) txtbox1.readonly = True txtbox2.readonly = True End Sub Hope this helps, Jeremy Reid http://blackstaronline.net/hgtit Thank you both for your reply.
I mean more like a recursive function that can find the TextBox on the Page and change its property... Dan "blackstaronline.net" <jr***@blackstaronline.net> a écrit dans le message de news: 1140463195.602259.73***@f14g2000cwb.googlegroups.com...Show quoteHide quote > txtbox1.readonly = True > txtbox2.readonly = True > > or depending on the situation you could use; > > txtbox1.enabled = False > txtbox2.enabled = False > > or > > txtbox1.visible = False > txtbox2.visible = False > > You can do this in the > > Public Sub Page_Load(ByVal sender As System.Object, ByVal e As > System.EventArgs) > txtbox1.readonly = True > txtbox2.readonly = True > End Sub > > Hope this helps, > Jeremy Reid > http://blackstaronline.net/hgtit > You can always use Page.Controls and loop through the controls on the page
and identifying each Textbox object. But why do want to do this since this is adding extra code to your application? Please explain what you're trying to do. -- Show quoteHide quoteChristopher A. Reed "The oxen are slow, but the earth is patient." "Dan Kimhi" <d**@sof.fr> wrote in message news:eHkMR6qNGHA.420@tk2msftngp13.phx.gbl... > Thank you both for your reply. > > I mean more like a recursive function that can find the TextBox on the > Page and change its property... > > Dan I do it all the time. If the result from a dynamic drop down are used
to fill a 2nd dynamic drop down, I will make the 2nd drop down Enabled=False until the OnSelectedItem change for the first drop down. Sometimes a sacrifice in a few extra lines of code is necessary for "ease of use" in your application. Just my 2 cents. Jeremy Reid http://hgtit.com Thank you all for helping.
I finally used the following: Private Sub SetTextBoxes(ByVal bval As Boolean) Dim c As Control Dim childc As Control For Each c In Page.Controls For Each childc In c.Controls If TypeOf childc Is TextBox Then Dim t As TextBox = CType(childc, TextBox) t.ReadOnly = bval End If Next Next End Sub Dan Kimhi "blackstaronline.net" <jr***@blackstaronline.net> a écrit dans le message de news: 1140541589.811798.303***@g14g2000cwa.googlegroups.com...Show quoteHide quote >I do it all the time. If the result from a dynamic drop down are used > to fill a 2nd dynamic drop down, I will make the 2nd drop down > Enabled=False until the OnSelectedItem change for the first drop down. > Sometimes a sacrifice in a few extra lines of code is necessary for > "ease of use" in your application. > > Just my 2 cents. > > Jeremy Reid > http://hgtit.com >
Image Rollovers with the Hyperlink Control
Converting the time from one timezone to another Composite Server Control and DefaultValue Attribute The case of the crazy reseting dropdowns :-( Please help! Looking for a book on writing ASP.NET Controls with VB.NET GridView ASP.NET 2.0 Question general request about links CompileWith From one form to another.. using ASPNET objects in custom webcontrol |
|||||||||||||||||||||||