ASP.NET ??????? ?????????? ?? Visual Basic 2005 ?? Visual Basic .NET ?? ?? ????? ???? ????

???? ?????? ???? ??????
???? ID: 316662 - ?? ???????? ?? ?????? ??? ?? ?? ???? ???? ???? ??.
??? ?? ??????? ???? | ??? ?? ??????? ????

?? ????? ??

??????

.NET Framework ?????? ??????? ?????? ?? ??????? ?? ???????? ??, ?? ??? asp.NET ??? ??????? ????? ?? ???, ????? ?????????? ????? ???????? ?? ?????? ?? ???????? ???????? ?? ??? ???????? ??????? ?????? ??????? ??? ???? ???? ???? ?? ???? ????? ???? ?? ?? ???? ?? ????? ?? ????? ?? ?????????? ?? ????? ?? ???????-???? ?? ?????-???? ??????? ?? ??????????? ???? ?? ??? asp.NET ??????? ???????? ?? ????? ?? ???? ??? ????

??????????

????? ???? outlines ???????? ?????????, ??????????, ??????? ?????? ?? ?????? ??? ?? ???? ???:
  • ????? Studio .NET ?? Visual Studio 2005
  • Microsoft ??????? ????? ????? (IIS) ?? ??? ?? ??????? 5.0
?? ???? ????? ?? ?? ?? ????? ???? ?? ?????? ???:
  • ??? ?????????
  • ASP.NET

ASP.NET ??????? ???????? ?? Visual Studio .NET ?? ????? ????

?????????? ?? ????? ?? ??????? cumbersome ????? ?? ???? ??? .NET Framework ??????? ???????? ???? ?????????? ?? ????? ?? ???????? ???? ?? ??????? ?????? ????? ????????? ?????? ???? ??? ?? ?? ?? ??? ??????? ???????? ??? ?? ?????? ????? ??? ?? ????? ??????? ?? ????? ?? ?? ??????? ?? ????????? ???? ?? ??? ???? ??? ??? time ???? ?? ???? ??? ??? ??, ??ValidationSummary??????? ?? ?? ??????? ??? ???? ????? ?? ??? ??? ?????? ????? ????????? ???? ?? ??? ???????? ?????? ?? ?? ???

????? ????? ?? ???? ????? ??? asp.NET ??? ????????? ?? ?????????? ?? ??? ?????????? ???, ?-??? ??? ?? ??????? ?? ??? ????? ???? ??? ?? ?????????? submits ?????? ?? ?? ??????? ??, ?? ??????? ?????????? ?? ??????? ?????????? ?????? ???? ???? ????? ???? ?? ??????? ?? ????? ??? ??? summarized ???? ??? ??? ?????? ????? ????????? ?????
  1. Visual Studio .NET ?? Visual Studio 2005 ??????? ?????
  2. ??? ??? asp.NET ??? ????????? ????????? ??? Visual Basic 2005 ?? Visual Basic .NET ??? ??????
  3. HTML ????? WebForm1.aspx ?? ??????
  4. ?????????? ?? ????? solicit ???? ?? ??? ???? ??????? ?? ??? ????? ???????? ?? ?????? ????? (???????) ??????? WebForm1 HTML ????? ??? ????????? ????? ?? ????? ?? closing ??????? ????? ?? ??? ????? ??? ????????

    ???:: ?? ?? HTML ????? ??? ??? ??????? ??, ?? ??? ?? ?????? ?? HTML ?? ??? ??? ??????? ?? ??? ?????????? ??? ??? ???? ?? ???, ??? ????HTML ?? ??? ??? ?????????????? ???? ???
    <table>
    <tr width=100>
    <td>UserName:</td>
    <td><input id=txtUserName type=text size=20 maxlength=15 runat=server/>*
    </td>
    </tr>
    
    <tr width=100>
    <td>E-mail Address:
    <td><input id=txtEmail type=text size=35 maxlength=30 runat=server/>  (someone@microsoft.com)
    </td>
    </tr>
    
    <tr width=100>
    <td>Password:</td>
    <td><input id=txtPassword type=password size=15 maxlength=10 runat=server/>*
    </td>
    </tr>
    
    <tr width=100>
    <td>Retype Password:</td>
    <td><input id=txtConfirmPassword type=password size=15 maxlength=10 runat=server/>*
    </td>
    </tr>
    </table>
    					
  5. RequiredFieldValidator???????? ?? ???? ???? ?? ??? ??? ????????? ???????? ???? ?? ?? ????? ?? ??? ???? ???? ??? ??? addRequiredFieldValidator???????? ?? ??? ???? ??????? ?? ????????????? ???, ?????????????? ???

    WebForm1 HTML ????? ??? ????????? ????? ?? ??? ?? ??? ????? ??? ???????:
    <asp:RequiredFieldValidator id=valUserNameRequired 
    ControlToValidate=txtUserName ErrorMessage="UserName is a required field." EnableClientScript=true Display=None Runat=server/>
    		<asp:RequiredFieldValidator id=valPasswordRequired 
    ControlToValidate=txtPassword ErrorMessage="Password is a required field." EnableClientScript=true Display=None Runat=server/>
    		<asp:RequiredFieldValidator id=valConfirmPasswordRequired 
    ControlToValidate=txtConfirmPassword ErrorMessage="Password confirmation is a required field."
    EnableClientScript=true Display=None Runat=server/>
    					
  6. ??????? ?????? ????????: ?????????? ?? ?? ??? ???? ??????? ?? ???? ???? ?? ??? ?? ?????? ???????? ???? TheCompareValidatorcontrol compares the contents of two input fields and generates an error message if they do not match. Use aCompareValidatorcontrol to validate the password fields.

    In the WebForm1 HTML window, copy and paste the following code after the validation controls added in step 5:
    <asp:CompareValidator id=valComparePassword 
    ControlToValidate=txtConfirmPassword ErrorMessage="Password fields must match." ControlToCompare=txtPassword Display=None
    EnableClientScript=true Runat=server/>
    					
  7. There are fields that sometimes require more customized validation, such as an e-mail address field. TheRegularExpressionValidatorcontrol ensures that the basic format ofsomeone@microsoft.com is followed. ??????? ?????? ?? ?? ?????? ?????????? ?? ??????? ?? ??????? ? ?? ??? ???, ?? ?????????? ?? ??? ??? ????? ???? ???? ??, ??? ?????????? ??? ?????? ????? ??????? ????? ????? ???RegularExpressionValidator?????????? ?????? ?????? ??? ?? ?-??? ??? ?? ?????? ????? ???? ?? ??? ???????? ???

    WebForm1 HTML ????? ??? ????????? ????? ?? ???? ??????? ?? ???????? ???? ?? ??? ????? ??? ???????:
    <asp:RegularExpressionValidator ID=valEmailAddress
    ControlToValidate=txtEmail	ValidationExpression=".*@.*\..*" ErrorMessage="Email address is invalid." 
    Display=None EnableClientScript=true Runat=server/>
    					
  8. ????? ???????? ??????? ?? ??????? ?????????? ?? ??????? ?? ????? ???? ?? ????? ????? ?? ????? ???? ?? ??? ?????????? ?? ???? ?? ??? ???

    In the WebForm1 HTML window, copy and paste the following code after the preceding validation controls:
    <br>
    <input type=submit id=cmdSumbit value=submit runat=server/>
    					
  9. Finally, aValidationSummarycontrol is used to display all encountered errors in a single area of the form.

    In the WebForm1 HTML window, copy and paste the following code after the code for the????? ???????:
    <br><br>
    <asp:ValidationSummary id=ValSummary HeaderText="The following 
    errors were found:" ShowSummary=True DisplayMode=List Runat=server/>
    					
  10. ????? ????,??????.
  11. ????? ???????? ???????? ??,????????????, ?? ????????? ??????

    Form1 is displayed on the screen.

?????????

  • ??? ?????????? ????? ???? ??????? ????without entering any input values, the three required-field error messages should be displayed.
  • If the user submits two password values that do not match, the "Password fields must match" error message should be displayed.
  • If the user submits an e-mail address that does not conform to the proper format, the "E-mail address is invalid" error message should be displayed.

??????

For more information and resources pertaining to validation controls, browse to the following MSDN Web sites:
Introduction to the Validation Controls
http://msdn2.microsoft.com/en-us/library/2e4hd649.aspx

Validation Server Controls
http://msdn2.microsoft.com/en-us/library/e5a8xz39(VS.71).aspx

Adding and Configuring a ValidationSummary Control
http://msdn2.microsoft.com/en-gb/library/wze2wh7t(VS.71).aspx

???

???? ID: 316662 - ????? ???????: 04 ?????? 2010 - ??????: 2.0
???? ???? ???? ??:
  • Microsoft ASP.NET 1.0
  • Microsoft Visual Basic .NET 2002 Standard Edition
  • Microsoft Visual Studio .NET 2002 Professional Edition
  • Microsoft Visual Studio .NET 2002 Enterprise Architect
  • Microsoft Visual Studio .NET 2002 Enterprise Developer
  • Microsoft Visual Studio .NET 2002 Academic Edition
  • Microsoft Visual Basic .NET 2003 Standard Edition
  • Microsoft Visual Basic 2005
  • Microsoft Visual Studio .NET 2003 Academic Edition
  • Microsoft Visual Studio .NET 2003 Enterprise Architect
  • Microsoft Visual Studio .NET 2003 Enterprise Developer
  • Microsoft Visual Studio .NET 2003 Professional Edition
  • Microsoft Visual Studio 2005 Professional Edition
  • Microsoft Visual Studio 2005 Standard Edition
??????: 
kbvs2005applies kbvs2005swept kbhowtomaster kbinfo kbvalidation kbmt KB316662 KbMthi
???? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:316662

??????????? ???

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com