Professional asp.net 2.0 server control and component development
2007-10-10 09:47
501 查看
P653 Listing 21-21
void OnLogin(object sender, EventArgs e)
{
if (CustomComponents.Membership.ValidateUser(userNameTextBox.Text,
passwordTextBox.Text))
{
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( 1,
userNameTextBox.Text, DateTime.Now,
DateTime.Now.AddSeconds(40),false, string.Empty);
string encryptedTicket = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName);
cookie.Value = encryptedTicket;
Page.Response.Cookies.Add(cookie);
EnsureChildControls();
Page.Response.Redirect(
FormsAuthentication.GetRedirectUrl(userNameTextBox.Text, false), true);
}
}
对于EnsureChildControls()的调用,作者解释:
The OnLogin method calls the EnsureChildControls method before the call into the Redirect method because it passes the value of the Text property of the username TextBox into the Redirect method. Recall that every composite
control must call the EnsureChildControls method before it attempts to access its child controls:
但是之前的代码早已经access its child controls了。奇怪。
if (CustomComponents.Membership.ValidateUser(userNameTextBox.Text,
passwordTextBox.Text))
void OnLogin(object sender, EventArgs e)
{
if (CustomComponents.Membership.ValidateUser(userNameTextBox.Text,
passwordTextBox.Text))
{
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( 1,
userNameTextBox.Text, DateTime.Now,
DateTime.Now.AddSeconds(40),false, string.Empty);
string encryptedTicket = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName);
cookie.Value = encryptedTicket;
Page.Response.Cookies.Add(cookie);
EnsureChildControls();
Page.Response.Redirect(
FormsAuthentication.GetRedirectUrl(userNameTextBox.Text, false), true);
}
}
对于EnsureChildControls()的调用,作者解释:
The OnLogin method calls the EnsureChildControls method before the call into the Redirect method because it passes the value of the Text property of the username TextBox into the Redirect method. Recall that every composite
control must call the EnsureChildControls method before it attempts to access its child controls:
但是之前的代码早已经access its child controls了。奇怪。
if (CustomComponents.Membership.ValidateUser(userNameTextBox.Text,
passwordTextBox.Text))
相关文章推荐
- 电子书下载:Professional ASP.NET 2.0 Server Control and Component Development
- Professional asp.net 2.0 Server Control and Component Development
- Professional ASP.NET 2.0 Server Control and Component Development
- 读书笔记《Professional ASP.NET Server Control and Component Development》
- ASP.NET 2.0 FileUpload Server Control (转载自codeproject)
- ASP.NET 2.0 - 控件系列(一) - 菜单控件 Menu Server Control + CSS
- Setup 64-bit Windows Server for Running ASP.NET 1.1 and ASP.NET 2.0 at the Same Time
- Setup 64-bit Windows Server for Running ASP.NET 1.1 and ASP.NET 2.0 at the Same Time
- Saving and Displaying Photos in SQL Server using ASP.NET and FileUpload Control
- Professional ASP.NET 2.0 Security, Membership, and Role Management
- ASP.NET 2.0 MasterPages and FindControl()
- [翻译]Accessing and Updating Data in ASP.NET 2.0: Examining the Data Source Control's Events
- Beginning Web Development, Silverlight, and ASP.NET AJAX: From Novice to Professional
- Professional ASP.NET 2.0 Design: CSS, Themes, and Master Pages
- (2)Asp.Net Server Control 编写
- Detail in Response.redirect and Server.transfer in ASP.NET
- Pro ASP.NET 3.5 Server Controls and AJAX Components
- Simplified and Extended Data Binding Syntax in ASP.NET 2.0(part1)
- ComponentArt WebUI For asp.nET 2.1,So Good Asp.nET UI Control!
- 使用vs2005自带的asp.net development server代替IIS