用Placeholer控件动态创建Login控件
<%@ page language="C#" %><script runat="server">
// This custom Login control checks the user name
// entered by the user is a valid e-mail address
class CustomLogin : Login
{
bool IsValidEmail(string strIn)
{
// Return true if strIn is in valid e-mail format.
return Regex.IsMatch(strIn, @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$");
} override protected void OnLoggingIn(System.Web.UI.WebControls.LoginCancelEventArgs e)
{
if (!IsValidEmail(UserName))
{
InstructionText = "You must enter a valid e-mail address.";
e.Cancel = true;
}
else
{
InstructionText = String.Empty;
}
}
} // Add the custom login control to the page.
void Page_Load(object sender, EventArgs e)
{
CustomLogin loginControl = new CustomLogin();
loginControl.ID = "loginControl";
Placeholder1.Controls.Add(loginControl);
}</script>
<html>
<body>
<form id="Form1" runat="server">
<asp:placeholder id="Placeholder1" runat="server"></asp:placeholder>
</form>
</body>
</html>
override protected void OnLoggingIn重写这一方法中,如何通过重写实现一些别的功能,比如说在页面上加入Label1,要实现按下登录就进行Label1.text="hello",这个在这个方法里面不能写,请问在哪写呀,我想应该是保护的问题,但是不知如何解决???
<%@ page language="C#" %><script runat="server">
// This custom Login control checks the user name
// entered by the user is a valid e-mail address
class CustomLogin : Login
{
bool IsValidEmail(string strIn)
{
// Return true if strIn is in valid e-mail format.
return Regex.IsMatch(strIn, @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$");
} override protected void OnLoggingIn(System.Web.UI.WebControls.LoginCancelEventArgs e)
{
if (!IsValidEmail(UserName))
{
InstructionText = "You must enter a valid e-mail address.";
e.Cancel = true;
}
else
{
InstructionText = String.Empty;
}
}
} // Add the custom login control to the page.
void Page_Load(object sender, EventArgs e)
{
CustomLogin loginControl = new CustomLogin();
loginControl.ID = "loginControl";
Placeholder1.Controls.Add(loginControl);
}</script>
<html>
<body>
<form id="Form1" runat="server">
<asp:placeholder id="Placeholder1" runat="server"></asp:placeholder>
</form>
</body>
</html>
override protected void OnLoggingIn重写这一方法中,如何通过重写实现一些别的功能,比如说在页面上加入Label1,要实现按下登录就进行Label1.text="hello",这个在这个方法里面不能写,请问在哪写呀,我想应该是保护的问题,但是不知如何解决???
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货