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.