Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

: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.

ima
  • Moderators
Posted

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

Visit...Bassic Software
Posted

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

Posted

"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

If you make it idiot proof, they'll build a better idiot :-)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...