1. Complete the logon page (go to the notepad file to verify the password and user name ).
Code in ASP:
<Form ID = "form1" runat = "server">
<Div>
<Table align = "center" border = "1px" width = "50%">
<Tr> <TD class = "style1" align = "center"> User Name: </TD> <input type = "text" id = "username" runat = "server"/> </TD> </tr>
<Tr> <TD class = "style1" align = "center"> password: </TD> <input type = "password" id = "passwordtxt" runat = "server"/> </TD> </tr>
<Tr> <TD class = "style1" align = "center"> <input style = "width: 79px; "type =" button "id =" btn_login "value =" login "xonserverclick =" button#click "runat =" server "/> </TD>
<TD align = "center"> <label id = "htmltext" runat = "server"> </label> </TD> </tr>
</Table>
</Div>
</Form>
Code in the method:
Protected void button#click (Object sender, eventargs E)
{
String [] lines = file. readalllines ("password.txt ");
String username = username. value;
String Password = passwordtxt. value;
For (INT I = 0; I <lines. length; I ++)
{
String [] line = lines [I]. Split ('');
If (line [0] = username & line [1] = PASSWORD)
{
Htmltext. innertext = "Logon successful! ";
Return;
}
Else
{
Htmltext. innertext = "Logon Failed! ";
}
}
}
2. Complete the user registration page (display the registration information in the DIV of this page ).
Code in ASP Webpage:
<Form ID = "form1" runat = "server">
<Div>
<Table align = "center" border = "1px" width = "50%">
<Tr> <TD class = "style1" align = "center"> User Name: </TD> <input type = "text" id = "username" runat = "server"/> </TD> </tr>
<Tr> <TD class = "style1" align = "center"> password: </TD> <input type = "password" id = "passwordtxt" runat = "server" xonclick = "Return passwordtxt_onclick () "/> </TD> </tr>
<Tr> <TD class = "style1" align = "center"> confirm the password: </TD> <input type = "password" id = "passwordtxt1" runat = "server" xonclick = "Return passwordtxt_onclick () "/> <label id =" label1 "runat =" server "> </label> </TD> </tr>
<Tr> <TD> gender: </TD> <input type = "radio" id = "radio1" runat = "server" name = "sex"/> male <input type = "radio" ID = "Radio2" name = "sex" name = "sex"/> female </TD> </tr>
<Tr> <TD> Avatar: </TD> <input type = "file" id = "file1" runat = "server"/> </TD> </tr>
<Tr> <TD class = "style1" align = "center"> <input style = "width: 79px; "type =" button "id =" btn_login "value =" login "xonserverclick =" button#click "runat =" server "/> </TD>
<TD align = "center"> <label id = "htmltext" runat = "server"> </label> </TD> </tr>
</Table>
<Div id = "divresult" runat = "server"> </div>
</Div>
</Form>
Code in the method:
Protected void button#click (Object sender, eventargs E)
{
Stringbuilder sb = new stringbuilder ();
SB. append ("User name :");
SB. append (username. value );
SB. append ("<br/> ");
SB. append ("Password :");
SB. append (passwordtxt. value );
SB. append ("<br/> ");
If (passwordtxt. value. Trim () = passwordtxt1.value. Trim ())
{
SB. append ("Confirm Password :");
SB. append (passwordtxt1.value );
SB. append ("<br/> ");
}
Else
{
Label1.innertext = "the two passwords are inconsistent !!! ";
Passwordtxt. value = "";
Passwordtxt1.value = "";
}
SB. append ("Gender :");
If (radio1.checked = true)
{
SB. append ("male ");
}
Else
{
SB. append ("female ");
}
SB. append ("<br/> ");
SB. append ("Avatar ");
String filename = file1.postedfile. filename;
Filename = datetime. Now. ticks. tostring () + filename. substring (filename. lastindexof ("."));
This. file1.postedfile. saveas (server. mappath ("Upload" + "\" + filename ));
SB. append (" ");
If (passwordtxt1.value! = "")
{
Divresult. innerhtml = sb. tostring ();
}
}