本文整理汇总了C#中System.Web.UI.WebControls.Login类的典型用法代码示例。如果您正苦于以下问题:C# Login类的具体用法?C# Login怎么用?C# Login使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Login类属于System.Web.UI.WebControls命名空间,在下文中一共展示了Login类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CustomLogin
//引入命名空间
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace Samples.AspNet.Controls
{
public sealed class CustomLogin : Login
{
public CustomLogin() { }
protected override void OnLoggingIn(LoginCancelEventArgs e)
{
// Set the Membership provider for the Login control from a DropDownList.
DropDownList list = (DropDownList)this.FindControl("domain");
this.MembershipProvider = list.SelectedValue;
base.OnLoggingIn(e);
}
protected override void CreateChildControls()
{
LayoutTemplate = new MyTemplate();
base.CreateChildControls();
}
}
// A Template that contains the child controls.
public class MyTemplate : ITemplate
{
void ITemplate.InstantiateIn(Control container)
{
// A TextBox for the user name.
TextBox username = new TextBox();
username.ID = "username";
// A TextBox for the password.
TextBox password = new TextBox();
password.ID = "password";
// A CheckBox to remember the user on subsequent visits.
CheckBox remember = new CheckBox();
remember.ID = "RememberMe";
remember.Text = "Don't forget me!";
// Failure Text.
Literal failure = new Literal();
failure.ID = "FailureText";
// A DropDownList to choose the Membership provider.
DropDownList domain = new DropDownList();
domain.ID = "Domain";
domain.Items.Add(new ListItem("SqlMembers"));
domain.Items.Add(new ListItem("SqlMembers2"));
// A Button to log in.
Button submit = new Button();
submit.CommandName = "login";
submit.Text = "LOGIN";
container.Controls.Add(new LiteralControl("UserName:"));
container.Controls.Add(username);
container.Controls.Add(new LiteralControl("<br>Password:"));
container.Controls.Add(password);
container.Controls.Add(new LiteralControl("<br>"));
container.Controls.Add(remember);
container.Controls.Add(new LiteralControl("<br>Domain:"));
container.Controls.Add(domain);
container.Controls.Add(new LiteralControl("<br>"));
container.Controls.Add(failure);
container.Controls.Add(new LiteralControl("<br>"));
container.Controls.Add(submit);
}
}
}
开发者ID:.NET开发者,项目名称:System.Web.UI.WebControls,代码行数:80,代码来源:Login
注:本文中的System.Web.UI.WebControls.Login类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论