我正在尝试按照此示例了解如何验证凭据。但是,它使用 asp: 控制登录表单。
如果我要使用 html 控件,以便可以应用 CSS 样式,例如
<div id="login">
<a href="#" id="lclose"></a>
<form action="#" runat="server">
<fieldset>
<div class="frame">
<h4>Login</h4>
<small>Sign in to your account.</small>
<div class="clear"></div>
<input type="text" value="Username" class="input-text autoclear" />
<input type="password" value="Password" class="input-text autoclear"/>
</div>
<div class="separator"></div>
<div>
<input type="submit" value="Sign in" class="input-submit float-right" runat="server" onserverclick="LoginButton_Click"/>
<a href="#" class="float-left">Forgot your password?</a>
</div>
</fieldset>
</form>
</div>
如何在类似于后面的代码中访问用户名和密码?
protected void LoginButton_Click(object sender, EventArgs e)
{
// Validate the user against the Membership framework user store
if (Membership.ValidateUser(UserName.Text, Password.Text))
{
// Log the user into the site
FormsAuthentication.RedirectFromLoginPage(UserName.Text, RememberMe.Checked);
}
// If we reach here, the user's credentials were invalid
InvalidCredentialsMessage.Visible = true;
}
什么是正确的语法而不是UserName.Text, Password.Text
?