ThePrettyGeek
asked on
vb.net asp.net password show and hide with a checkbox
I thought this would be simple but its giving me issues.
All I want to do is be able to show the password when a check box is checked and hide it when its not.
This is my code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If chkShowChars.Checked = True Then
txtDBPassword.TextMode = TextBoxMode.SingleLine
Else
txtDBPassword.TextMode = TextBoxMode.Password
End If
End Sub
Protected Sub chkShowChars_CheckedChange d(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkShowChars.CheckedChange d
If chkShowChars.Checked = True Then
txtDBPassword.TextMode = TextBoxMode.SingleLine
Else
txtDBPassword.TextMode = TextBoxMode.Password
End If
End Sub
it does check to see if its checked during the page load but it does nothing when I check or uncheck the box.
I put the if statement in the page load sub so if there was a postback it would automatically check again but Im obviously missing something.
I'm sure when someone answers this Im going to want ot smack myself but that doesn't negate the fact that I need help with it.
All I want to do is be able to show the password when a check box is checked and hide it when its not.
This is my code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If chkShowChars.Checked = True Then
txtDBPassword.TextMode = TextBoxMode.SingleLine
Else
txtDBPassword.TextMode = TextBoxMode.Password
End If
End Sub
Protected Sub chkShowChars_CheckedChange
If chkShowChars.Checked = True Then
txtDBPassword.TextMode = TextBoxMode.SingleLine
Else
txtDBPassword.TextMode = TextBoxMode.Password
End If
End Sub
it does check to see if its checked during the page load but it does nothing when I check or uncheck the box.
I put the if statement in the page load sub so if there was a postback it would automatically check again but Im obviously missing something.
I'm sure when someone answers this Im going to want ot smack myself but that doesn't negate the fact that I need help with it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Is the AutoPostback property of the checkbox set to true?
ASKER
No I didn't have the autopostback property set to true and I'm sorry I took so long getting back to you on this. I would still like to figure this out but I ended up taking the check box out for the time being as I couldn't get edemcs suggestion to work right and with the autopostback property set to true it would clear the textbox all together on the post back. The odd thing was that if it was set to TextBoxMode.Password it would disappear but uncheck the box and set it back to TextBoxMode.SinglLine and the data would re-appear so it wasn't forgetting it.
edemcs, would you please share a code snippet on this one on how you got this to work. I think your going down the path I want to take, I just seem to either end up with two text boxes on on top of the other or no text boxes at all for the password or two textboxes with on where its supposed to be and the other in the upper left corner.
edemcs, would you please share a code snippet on this one on how you got this to work. I think your going down the path I want to take, I just seem to either end up with two text boxes on on top of the other or no text boxes at all for the password or two textboxes with on where its supposed to be and the other in the upper left corner.
ASKER
Ok, I used a placeholder to hold two different textboxes and then pass the text from one to the other the issue now is that the textbox in password mode will not allow me to pull updated data from it and I end up with a blank password field
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I disagree. I explained how you may do what you were looking to do with a clear explanation. Just because you didn't have it written out for you, I still provided an answer that gave you a solution. Please be considerate towards other's time and efforts.
ASKER
Like I said you started the thought process but if truth where to be told it was another Expert who gave me the answer that led to the solution on a totally unrelated question. magadesign_sviluppo from this site and foolios from the asp.net site are actually who filled in the blanks while I was researching something else. To be honest until this afternoon I had given up on this question and didn't even care anymore the text box was working fine and I was planning just letting the question expire since I couldn't figure out how to just close it for not figuring it out.
I felt that either no one cared to check back over the next 45 days exactly after I requested clarification and received not another response on the thread or in my vernal experience and harrowing, "my time and efforts" weren't as important as others.
I hope the posted snippet helps others as they make their way around the web.
I'm going to raise the points from 125 to the 500Max and then grant them to you. I still feel the answer came from other sources but if you feel so strongly then I want to make sure that your efforts are rewarded.
I felt that either no one cared to check back over the next 45 days exactly after I requested clarification and received not another response on the thread or in my vernal experience and harrowing, "my time and efforts" weren't as important as others.
I hope the posted snippet helps others as they make their way around the web.
I'm going to raise the points from 125 to the 500Max and then grant them to you. I still feel the answer came from other sources but if you feel so strongly then I want to make sure that your efforts are rewarded.
Thank you, ThePrettyGeek. I thought at least something could have been given to those who helped. To be honest, most users respond within the hour or same day. You didn't respond to my post for over 7 days and therefore was unintentionally not given as much attention.