ASP. the emergence of net has brought a revolution to web program design. It is a kind of quick and easy-to-use Windows, and a high degree of encapsulation reduces the difficulty of program design, the rich interface controls improve the efficiency of software design and thus shorten the development cycle. The Code hiding and separation technology greatly improves the readability and maintainability of the program. In addition, ADO. NET database access technology, fully integrating the windows program design idea into the web design. The following is a simple exercise for me to build a system architecture:
1. logon page:
The first is the verification of a login user, followed by a system announcement and a notice of a running horse lamp, and finally some connection and copyright descriptions. Webcontrols is used at the front end, and C # code is used at the backend to compare and verify the user's login username and password with the data stored in the database, if it is correct, log on and assign the user's userid and username to the global variables session ["userid"] And session ["username"] to verify the session on the following page to determine whether the user is login, directs the page to index. aspx. If the user name or password fails to be verified, a prompt message is displayed. The implementation code is as follows:
Private void imgbtnlogin_click (Object sender, system. Web. UI. imageclickeventargs E)
{
// Determine whether the user name and password are entered
String username = txtusername. Text. Trim ();
String userpasw = txtpassword. Text. Trim ();
String sqluser = "select * from users where userid = '" + username + "'";
Dataset userdtset = new dataset ();
Userdtset = login. getdataset (sqluser );
// Determine whether the user name exists
Int sqlcount = userdtset. Tables [0]. Rows. count;
If (sqlcount = 0)
{
Showmessage ("the user name does not exist. Please enter it again! ", Page );
Return;
}
// Determine whether the password is correct
String passwd = userdtset. Tables [0]. Rows [0] ["password"]. tostring ();
If (passwd! = Userpasw)
{
Showmessage ("the password is incorrect. Please enter it again! ", Page );
Return;
}
// Assign the global variable value
Session ["userid"] = userdtset. Tables [0]. Rows [0] ["userid"]. tostring ();
Session ["username"] = userdtset. Tables [0]. Rows [0] ["name"]. tostring ();
Response. Redirect ("index. aspx ");
Other parts of login. aspx, such as: the announcement uses the control DataGrid to read the data in the database.
2. index. the ASPX page is the main page of the program. It consists of three parts: a banner on the top, a treevew on the left, and a primary operation area on the right. The Treeview on the left is mainly used for navigation, fram is used to splice several pages to form a page background code:
Private void page_load (Object sender, system. eventargs E)
{
If (! Ispostback)
{
If (session ["username"] = NULL) // if the session is left blank, the logon page is displayed.
Response. Redirect ("check. aspx ");
}
}
A verification page check is used here. if the user does not log on or the session times out, aspx will go to this page three seconds later and go to the logon page. There is a prompt on this page: No Logon or logon times out. Please log on again;
3. My requirements and my requirements page are mainly composed of master details, which can be bound to a database using controls.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service