Hey, today we rest, would like to summarize the previous two weeks of learning JavaScript and jquery, but feel good sleepy oh, did not seriously study, so did a little exercise, just began to learn HTML use in the project or pretty happy, Here is a simple summary of this small landing page.
I. Static page of HTML
"Content-type"Content="text/html; Charset=utf-8"/> <title></title> <style>form{margin-right:500px; Margin-top:10px; width:300px; height:300px; } </style>"first.ashx"Method="Post"> <table> <tr><td> User name: </td><td><input type="text"Name="txtname"/></td></tr><br/> <tr><td> Secret code: </td><td><input type="text"Name="txtpwd"/></td></tr><br/> <tr><td><input type="Submit"Name="Submit"Value="Login"/></td> <td><input type="Button"Name="btnfindpwd"Value="Retrieve password"/></td></tr> </table> </form></body>
here is a simple HTML page that implements the style of its login interface.
two. ashx's file code
usingSystem;usingsystem.web;usingSystem.IO;usingUseiinfomodel;usingUSERINFOBLL; Public classFirst:ihttphandler { Public voidProcessRequest (HttpContext context) {context. Response.ContentType="text/html";//documents that are accepted in HTML format stringPath = context. Request.mappath ("firsthtml.html");//get the path to the document stringhtml = file.readalltext (path);//Reading DocumentsContext. Response.Write (HTML);//and then write it back to us is the HTML page stringName=context. request.form["txtname"];//Get Txtname stringPWD = context. request.form["txtpwd"];//Get Txtpwd if(!string. IsNullOrEmpty (name) &&!string. IsNullOrEmpty (PWD))//When the text box is not empty{USERINFOBLL BLL=NewUSERINFOBLL (); Userinfomodelcs Model= BLL. GETLOGINBYNAMEPWD (name, PWD);//Call Data if(bll!=NULL&&string. IsNullOrEmpty (model. Username) &&string. IsNullOrEmpty (model. PWD) {context. Response.Clear (); Context. Response.Write ("Welcome"+ model. Username +"Landing Success");//corresponding Message } } } Public BOOLisreusable {Get { return false; } }}
< Span style= "font-family: blackbody; font-size:14pt; Background-color: #ffcc99; " > three. code for the BLL layer and the DAL layer
Public class USERINFOBLL { new userinfodal (); Public Userinfomodelcs getloginbynamepwd (stringstring pwd) { return dal. Getloginbynamepwd (NAME,PWD); } }
Public classUserinfodal { PublicUserinfomodelcs Getloginbynamepwd (stringNamestringpwd) {//Id, Username, PWD stringsql ="Select Id,username,pwd from userlogin where [email protected] and [email protected]"; Sqlparameter[] Parms={ NewSqlParameter ("@name", name),NewSqlParameter ("@pwd", PWD)}; SqlDataReader Reader=Dbhelp.executereader (sql,parms); Userinfomodelcs Model=NewUserinfomodelcs (); if(reader. Read ()) {model. Id= Convert.ToInt32 (reader[0]); Model. Username= reader[1]. ToString (); Model. PWD= reader[1]. ToString (); } returnmodel; } }
Public Static classDbhelp {Private Static stringConnection = configurationmanager.connectionstrings["SQL"]. ToString (); Public StaticSqlDataReader ExecuteReader (stringSqlparamssqlparameter[] parms) {SqlConnection conn=NewSqlConnection (connection); Conn. Open (); using(SqlCommand cmd =NewSqlCommand ()) {Cmd.commandtext=SQL; Cmd. Parameters.addrange (parms); Cmd. Connection=Conn; Cmd.commandtype=CommandType.Text; Cmd.commandtimeout=5; returncmd. ExecuteReader (commandbehavior.closeconnection); } } }
public class Userinfomodelcs { // id, Username, pwd
public int Id {set ; get public string Username {set ; get public string Pwd {set ; get
Hey, always thought that the use of ASPX to implement its data submission and response, today learned ashx feel this is very strange, the use of it is quite unfamiliar, first in the process of implementing its code is not directly and the page interaction, but all the data and the page and related to the implementation, is not very simple, hey, this is only a personal opinion, do not know everyone in the study of this time is not the feeling that, how to say that? Maybe next we have to study Ajax, learning this is much better, and the interaction of the page will be more convenient, but before also not how to contact Ajax, just see and JS in use, specific or do not understand, wrote here, the recent study of theoretical knowledge has not been summarized, Feel really need to give a little more time to understand, need to understand clearly in the summary. To continue to work hard!
The study of ASHX