I have a web form that has a checkbox on it and a textbox associated
with it. I want the textbox to be displayed when the checkbox is checked
and I want this to happen on the client-side instead of posting back to
the server. The checkbox is a server control (asp:checkbox.. .). I can
write some codebehind that will display an alert message upon checking
the box that looks something like this...
Page_Load...
Dim s As String
Dim scriptString As New System.Text.Str ingBuilder
chkExpDate.Attr ibutes.Add("onc lick", "alertmsg() ")
scriptString.Ap pend("<script language=JavaSc ript> function alertmsg()
{")
scriptString.Ap pend("alert('hi '); }<")
scriptstring.Ap pend("/" + "script>"
s = scriptstring.To String()
Page.RegisterSt artupScript("st artup", s)
End Sub
I used this as a test to make sure the server control was running the
script. But, when I change the script to assess the value of the server
control checkbox such as checked = true, I get errors and if I just try
to display the asp:textbox, it doesn't work either.
Any suggestions?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Comment