sureshcd10 Posted March 29, 2004 Posted March 29, 2004 :confused: :( I m using ASP.NET and VB.NET I have one TextBox1 and TextBox2 on a webform1.aspx where the TextBox2.Enabled=False TextBox1.autopostback=False Now if the length of Textbox.Text>2 ie., if len(Textbox1.text)>2 then 'I wanted the TextBox2.Enabled=True else TextBox2.Enabled=False end if ie I wanted to Enable/disable TextBox1 with out Changing the AutoPostBack to True TextBox1 and TextBox2 are all Serverside VB Controls Which event I should use ? and How can I execute that event with out Changing the AutoPostBack to True I mean with out POSting to Server Any one having an Idea ...plzz..hlp me... :confused: :( :o Thanks in adv. Quote ima
Moderators Robby Posted March 29, 2004 Moderators Posted March 29, 2004 You're saying that if the length of the textbox is > 2 then you want to enable the textbox, how will the user enter theses characters if it was disabled to begin with? Unless you are populating the textbox from the server? If so then the following should work. if textbox1.text.length > 2 then textbox1.enabled =true else textbox1.enabled =false end if Quote Visit...Bassic Software
Superfly1611 Posted March 29, 2004 Posted March 29, 2004 Javascript: <script id="ClientSideScript" language="Javascript"> function buttonClick() { sourceElement = document.getElementById("textbox1"); destElement = document.getElementById("textbox2"); if (sourceElement.value.length > 2) { destElement.disabled=false; } else { destElement.disabled=true; } } </script> then... <asp:button id="myButton" onClick="buttonClick();" runat="server" text="Click Me" /> or <input type=button value="Click Me" onClick="buttonClick();"> I have no idea when you wanted this to be done (u didn't specify) so i chose a button click - but this applies to anything Quote
MorningZ Posted March 29, 2004 Posted March 29, 2004 "with out POSting to Server" realize that ASP.NET is a server side language.... you cannot do anything in vb or C# that doesn't require a trip to the browser... Javascript (and the script posted above) is your only answer IF you don't want to do a round trip Quote If you make it idiot proof, they'll build a better idiot :-)
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.