我已创建此登录页面。
<asp:Label id="Label2" style="Z-INDEX: 103; LEFT: 112px; POSITION: absolute; TOP: 112px" runat="server">Password</asp:Label>
<asp:TextBox id="txtLogin" style="Z-INDEX: 109; LEFT: 192px; POSITION: absolute; TOP: 56px" runat="server"
Width="152px"></asp:TextBox>
<asp:TextBox id="txtPassword" style="Z-INDEX: 102; LEFT: 192px; POSITION: absolute; TOP: 104px"
runat="server" TextMode="Password" Width="152px"></asp:TextBox>
<asp:Label id="Label1" style="Z-INDEX: 100; LEFT: 112px; POSITION: absolute; TOP: 56px" runat="server">Login</asp:Label>
<asp:RequiredFieldValidator id="RequiredFieldValidator1" style="Z-INDEX: 104; LEFT: 368px; POSITION: absolute; TOP: 64px"
runat="server" ErrorMessage="Please enter Login Name" ControlToValidate="txtLogin" Width="153" Height="19"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator id="RequiredFieldValidator2" style="Z-INDEX: 105; LEFT: 368px; POSITION: absolute; TOP: 104px"
runat="server" ErrorMessage="Please enter password" ControlToValidate="txtPassword" Width="153px" Height="19px"></asp:RequiredFieldValidator>
<asp:Button id="btnLogin" style="Z-INDEX: 106; LEFT: 216px; POSITION: absolute; TOP: 168px"
runat="server" Width="72px" Text="Sign In" Height="24px" onclick="btnLogin_Click"></asp:Button>
<asp:Label id="LabelError" style="Z-INDEX: 107; LEFT: 176px; POSITION: absolute; TOP: 272px"
runat="server" Width="456px" Height="48px" Font-Bold="True" Font-Size="Medium"
ForeColor="#0000C0"></</asp:Label>
<asp:Button ID="Button1" style="Z-INDEX: 106; LEFT: 300px; POSITION: absolute; TOP: 168px"
runat="server" Width="72px" Text="New User" Height="24px" onclick="Button1_Click"/>
除了新用户按钮外,一切正常。我想按下它然后发送给我另一页NewUser.aspx。我在按钮点击中写这个代码
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("NewUser.aspx");
}
但是当我按下按钮然后验证(我用它们登录)告诉我提供我不想要的登录名和密码。我怎么能这样做?
答案 0 :(得分:3)
要么:
CausesValidation
属性设置为false
答案 1 :(得分:1)
这可以使用ValidationGroup
属性进行控制。在ValidationGroup
和验证器上设置btnLogin
属性,这应该可以解决问题。
答案 2 :(得分:0)
您也可以将按钮更改为
<a href="/NewUser.aspx" title="New User>New User</a>
这也更快,因为您不会使服务器站点重定向