|
-
Dec 18th, 2002, 02:17 PM
#1
Thread Starter
Addicted Member
Vaildation... sometimes
I have a textbox for a username, a bunch of other ones for other info, and two buttons at the bottom of the page: One to login and another that hides the current panel and shows another panel with information about creating a new account.
Now I want to have a required validation on the username box, so I add a required field validator, but the problem is that if the person wants to see the information panel instead of logining in they can't, they have to provide a username....
how do I avoid this?
-
Dec 18th, 2002, 07:07 PM
#2
Hyperactive Member
Set the CausesValidation attribute on the button that hides/shows the panel to False.
VB Code:
<script language="vb" runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
End Sub
Sub Login_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Write("Logged in!")
End Sub
Sub ShowSomething_Click(ByVal sender As Object, ByVal e As System.EventArgs)
If Something.Visible Then
Something.Visible = False
Else
Something.Visible = True
End If
End Sub
</script>
<html>
<body>
<form id="ConditionalValidation" runat="server">
UserName:
<asp:TextBox
ID="UserName"
Runat="server"/>
<asp:RequiredFieldValidator
ID="UserNameRequired"
Runat="server"
ControlToValidate="UserName"
ErrorMessage="*"
ToolTip="UserName is required!"
Display="Dynamic"/>
<br />
<asp:Button
ID="Login"
Runat="server"
OnClick="Login_Click"
Text="Login!"/>
<asp:Button
ID="ShowSomething"
Runat="server"
CausesValidation="False"
OnClick="ShowSomething_Click"
Text="Show Something"/>
<br />
<asp:Label
Visible="False"
ID="Something"
Text="Here's Something!"
Runat="server"/>
</form>
</body>
</html>
-
Dec 18th, 2002, 07:23 PM
#3
Thread Starter
Addicted Member
Resolved
Awesome thanks for that I figured it had to be something simple.. just couldn't find it anywhere
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|