Asp.net--requiredfieldvalidator Controls and ValidationSummary controls

Source: Internet
Author: User

we are in the login page, if you forget to lose the password to say the user name, there will always be a small reminder on the page.

So how do we do this when the Web is made? This uses the RequiredFieldValidator control and the ValidationSummary control, which are combined to achieve the effect we want.

Let's take the example of the above login:

<asp:         TextBox id= "txtname" runat= "Server" cssclass= "txtname" ontextchanged= "txtcode_textchanged" > </asp:TextBox> <asp:textbox id= "txtpwd" runat= "Server" cssclass= "txtname" ontextchanged= "txtcode_textchanged" > </ asp:textbox> <asp:requiredfieldvalidator id= "RequiredFieldValidator1" runat= "server" ControlToValidate = "Txtn Ame "errormessage=" Please enter account "text=" Please enter account "> </asp:RequiredFieldValidator> <asp:requiredfieldvalidato R id= "RequiredFieldValidator2" runat= "server" ControlToValidate = "txtname" errormessage= "Please enter password" text= "Please enter password" > &L t;/asp:requiredfieldvalidator> <asp:button id= "Btnlogin" runat= "server" CssClass = "Btnlogin" text= "Commit" OnCli ck= "Btnlogin_click"/> <asp:validationsummary id= "ValidationSummary1" runat= "server" ShowMessageBox = "true" Showsummary= "false"/> 


The difference is that the example in the code pops up a hint box and prompts the word after the text box. The most important implementation of this functionality is to set the ShowMessageBox property of the ValidationSummary control to the True,showsummary property to False.

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.