自定义文本框登录Asp.net会员提供 [英] Asp.net Membership provider with custom textboxes to login

查看:164
本文介绍了自定义文本框登录Asp.net会员提供的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装ASPNET会员provider.Now我创建一个登录表单(这不是默认的asp.net登录表单),但我看到很多例子在互联网,他们使用默认的登录页面..所以。我想知道如何做登录这个?

我的aspx code此处

 <表格名称=表单区级=形区域=服务器>
                    < H1>用户登录< / H1>
                    < P>请输入用户名和放大器;密码登录< / P>
                    < ASP:文本框ID =txtusr=服务器>< / ASP:文本框>
                    < ASP:文本框ID =txtpw=服务器的TextMode =密码>< / ASP:文本框>
                    < ASP:按钮的ID =提交=服务器文本=提交/>
                    < D​​IV CLASS =形区域底部>&安培; NBSP;< / DIV>
                < /表及GT;

在这里,我创建ASPNET管理website.I用户角色想知道什么时候点击链接如何登录

我看到一些例如像this..Can我用这个

 保护无效loginUser_Authenticate(对象发件人,AuthenticateEventArgs E)
{
    布尔isLogin = Membership.ValidateUser(loginUser.UserName,loginUser.Password);
    如果(isLogin)
    {
        loginUser.Visible = TRUE;
        会话[用户] = User.Identity.Name;
        FormsAuthentication.RedirectFromLoginPage(loginUser.UserName,真);
        的Response.Redirect(Default.aspx的);
    }
}


解决方案

核心关闭所有为

 布尔isLogin = Membership.ValidateUser(loginUser.UserName,loginUser.Password);

但你要小心处理正确的事件。
您正在使用定制登录表单,所以你需要拦截点击内的按钮,验证用户event.then可以执行你需要的操作。

我希望能帮助你。

I installed ASPNET Membership provider.Now i create a Login form(This is not a default asp.net login form).But i saw lots of example in internet they use default login page.. So. i wanted to know how to do login with this?

My aspx code here

<form  name="form-area"  class="form-area" runat="server">
                    <h1>User Login</h1>
                    <p>Please Enter Username & Password to login</p>
                    <asp:TextBox ID="txtusr" runat="server" ></asp:TextBox>
                    <asp:TextBox ID="txtpw" runat="server" TextMode="Password" ></asp:TextBox>
                    <asp:Button ID="submit" runat="server" Text="Submit" />
                    <div class="form-area-bottom">&nbsp;</div>
                </form>

Here i create a User Roles in ASPNET administration website.I wanted to know about when button click how to Login

I saw some example like this..Can i use this

protected void loginUser_Authenticate(object sender, AuthenticateEventArgs e)
{
    bool isLogin = Membership.ValidateUser(loginUser.UserName, loginUser.Password);
    if (isLogin)
    {
        loginUser.Visible = true;
        Session["user"] = User.Identity.Name;
        FormsAuthentication.RedirectFromLoginPage(loginUser.UserName, true);
        Response.Redirect("Default.aspx");
    }
}

解决方案

the core off all is

 bool isLogin = Membership.ValidateUser(loginUser.UserName, loginUser.Password);

but you take care to handles the correct event. you're using custom login form so you need to intercept click button validate user within that event.then you can perform the action that you need.

i hope that can help you.

这篇关于自定义文本框登录Asp.net会员提供的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆