Code In the front-end :
<Body> <Div id = "TOP"> </div> <Form ID = "login" name = "login" Action = "? Action = login "method =" Post "> <Div id =" center "> <Div id =" center_left "> </div> <Div id =" center_middle "> <Div class = "user"> <label> User Name: <input type = "text" name = "username" id = "username"/> </label> </div> <br/> <Div class = "user"> <label> password: <input type = "password" name = "userpassword" id = "userpassword"/> </label> </div> <Div id = "center_middle_right"> </div> <Div id = "center_submit"> <Div class = "button"> </div> <Div class =" button "> </div> <Div id =" center_right "> </div> </form> <Div id =" footer "> </div> </body>
Execute form. Submit () to pass parameters in form through the image click event.
Backend CS code:
Protected string action = ""; mybaseclass mydata = new mybaseclass (); protected class userlogininfo {Public String username = ""; Public String userpassword = "";} protected userlogininfo _ userlogininfo = new userlogininfo (); // create the object protected void page_load (Object sender, eventargs e) {init_webcontrols ();} public void init_webcontrols () {try {If (! String. isnullorempty (request. querystring ["action"]) // obtain the {Action = request. querystring ["action"]. trim (). tolower (); // remove spaces and write them smaller} switch (Action) {Case "login": If (! String. isnullorempty (request. Form ["username"]) &! String. isnullorempty (request. form ["userpassword"]) // obtain the {_ userlogininfo parameter in form. username = request. form ["username"]. tostring (); _ userlogininfo. userpassword = request. form ["userpassword"]. tostring (); string user = "select Administrator name, password from T _ administrator table where Administrator name = '" + _ userlogininfo. username + "'and Password ='" + _ userlogininfo. userpassword + "'"; if (mydata. readdataset (user ). tables [0]. rows. count = 1) {respons E. redirect ("Main. aspx ", false); // prevents response. execution of the end method termination page} else {response. write ("<script language = JavaScript> alert ('incorrect password or username. Please try again! '); </SCRIPT> ") ;}} break ;}catch (exception ex) {Throw new exception (ex. Message );}}