Link to home
Start Free TrialLog in
Avatar of gromul
gromul

asked on

Javascript client-side validation for ASP.NET

How do I refer to ASP.NET controls (textboxes...) in Javascript?

Thanks
Avatar of David H.H.Lee
David H.H.Lee
Flag of Malaysia image

SOLUTION
Avatar of nishikanth
nishikanth

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gromul
gromul

ASKER

@x_com: Yeah, I noticed it, but I didn't know that's how you do it in javascript also. And javascript somehow doesn't work on my machine, so I can't test it yet.
what about plain old simple ...

document.urformname.textboxname.value;

does this not work??
document.getElementById should work in most cases....
nishikanth's said is right. We can use document.getElementById to identify all the web controls. That's why we need to assign an unique ID for each web control that we're using now.

>> I noticed it, but I didn't know that's how you do it in javascript also. And javascript somehow doesn't work on my machine, so I can't test it yet.
-My sample already shown in both client-script include with js function. What browser you're using?Try to re-enable the browser to support client-side scripting.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gromul

ASKER

Thanks guys.
Avatar of gromul

ASKER

Thanks guys.
<Script language="javascript">
function ButtonClicked()
{
   document.form1.textbox1.value="Srikanth"
  alert( document.form1.textbox1.value)
/*Here form1 --> is name or id of the form in which your control is present.
           textbox1 --> name or id of the textbox.*/
}
</script>