Home > Net >  The use of c # programming web built-in objects for the source code
The use of c # programming web built-in objects for the source code

Time:11-04

Description: 1. Create two pages, login. Aspx, result. Aspx
2. The first page in the session object to save the username and password information, use a button, and redirect to the second page, in the second page to check the user name and password, the user name is zhang SAN, password is 2020, if properly display the welcome message, if the error, display the page does not allow to grant access.
3. On the first page, add a button, using the cookie information, save the user's access number, I have a small white help you a great god for source code and run the screenshot. Thanks

CodePudding user response:

Can be paid appropriately for a small red envelopes

CodePudding user response:

For example
Public partial class login: PageBase
{
Protected override void onl oad (EventArgs e)
{
BtnLogin. ServerClick +=btnLogin_Click;
Base. The onl oad (e);
}

Void btnLogin_Click (object sender, EventArgs e)
{
//the session storage login information
HttpContext. Current. The Session (" username ")=uname. The Text;
HttpContext. Current. The Session [" PWD "]=PWD. Text;

//to redirect the second interface
The Response. Redirect (" result. Aspx ", true);

}



Public partial class result: PageBase
{
Protected override void onl oad (EventArgs e)
{
//session value
String uname=Session (" username ");
String PWD=Session (" PWD ");

//here is to verify the success or failure
If (success)
{
Response. Write (" & lt; Script language='javascript' & gt; Alert (' ok ') & lt;/script>" );
}
The else
{
return;
}
}

}
  •  Tags:  
  • C#
  • Related