html checkbox control

just_life

New member
Joined
Sep 20, 2006
Messages
2
Programming Experience
Beginner
Hi All,
I have a checkbox which when checked, 2 text fields become visible.These two textboxes do not run at server. How can I access the value in these input fields? Am getting the error:
"Object reference not set to an instance of an object. "
I have some javascript which works fine in showing up the textboxes when checkbox is checked.


My code behind page:
VB.NET:
ProtectedSub Login1_Authenticate(ByVal sender AsObject, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate
Dim Form1 As System.Web.UI.HtmlControls.HtmlForm
Dim checkboxpwd AsNew HtmlInputCheckBox()
Dim textbox_pswd1 As System.Web.UI.HtmlControls.HtmlInputtext
Dim textbox_pswd2 As System.Web.UI.HtmlControls.HtmlInputtext
'protected System.Web.UI.HtmlControls.checkbox checkboxpwd
If (checkboxpwd.checked = False) Then
'If checkboxpwd.ID2 Then
If textbox_pswd1.value = textbox_pswd2.value Then[COLOR=red]---this is error line.[/COLOR]

The code on my aspx page is
HTML:
<input type="checkbox" id="checkboxpwd" style="z-index: 108; left: 166px; position: absolute; top: 490px"
onclick="form1.textbox_pswd1.style.display=checked ? '' : 'none'; form1.textbox_pswd2.style.display=checked ? '' : 'none'" runat="server"/>
<input style="z-index: 107; left: 196px; position: absolute; top: 490px; display:none" type="text" name="textbox_pswd1"/>
<input style="z-index: 106; left: 196px; position: absolute; top: 520px; display:none" type="text" name="textbox_pswd2"/>

Can anyone please help me to access the input field values.

Thank You
 
Last edited by a moderator:
Hi,

Since your textboxes are not run at server, it wun work

Your code-behind:

VB.NET:
Dim textbox_pswd1 As System.Web.UI.HtmlControls.HtmlInputtext
Dim textbox_pswd2 As System.Web.UI.HtmlControls.HtmlInputtext

both textbox_pswd1 and textbox_pswd1 are not initialised to anything. They contain nothing now.
 
Back
Top