1. Complete the logon page (go to the notepad file to verify the password and user name ). 2. Complete the user registration page (display the registration information in the DIV of this page ).

Source: Internet
Author: User

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 ();
}
}

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.