Error Introduction
Today, we are turning to verification controls.
When you use the requiredfieldvalidator control, everything is properly set and the following error occurs.
Solution
One solution is to copy ASPnet. scriptmanager. jquery. DL to the bin folder. In this way, the problem is solved, but another problem occurs, that is, after everything is set, I find that it does not pop up. Below is my code, only for demonstration, so no code is organized.
<asp:TextBox ID="TextBox1" runat="server" CausesValidation="True"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" Text="*" ControlToValidate="TextBox1" runat="server" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator> <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /> <asp:ValidationSummary ID="ValidationSummary1" ShowMessageBox="true" runat="server" />
No matter how you look for it, you cannot find the above error because the above Code is correct. After I modify another error, this code can be run.
Control description
First, we will introduce the requiredfieldvalidator control, which is used to verify whether the text box is empty.
Controltovalidate: Specifies the control to be monitored
Errormessage: if an error occurs
Text: indicates the text displayed by requiredfieldvalidator when an error occurs.
In the first phase, validationsummary is used. I personally understand that this control is a summary of the above verification control.
Showmessagebox: whether to display the dialog box when an error occurs
Showsummary: When an error occurs, the error message is displayed at the validationsummary location.
Of course, the above two controls have other attributes. I just talked about common ones.
Advanced controls
Now let's talk about the reason for the above settings, but there is no pop-up window. This is my own empty web application. Through debugging tools, I found that jquery statements are introduced in the webpage, while empty web applications are created, jquery is not added to the program.
If you create a new form application (not empty), you will see another scripts folder, which contains the jquery version. js file.
On the console of the debugging tool in the browser, check which version of jquery file is missing and paste it to the corresponding path. In this way, the problem is solved perfectly.