How can I execute event with out AutoPostBacking

sureshcd10

Regular
Joined
Dec 25, 2003
Messages
77
: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.
 
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.
Visual Basic:
if textbox1.text.length > 2 then
    textbox1.enabled =true
else
    textbox1.enabled =false    
end if
 
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
 
"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
 
Back
Top