Document directory
- Introduction
- Important attributes
- Example
Introduction
The validatorcallout control is a prompt control used to bind verification controls, so that the display of verification information is more intuitive. As follows:
Important attributes
Targetcontrolid: ID of the verification control to bind
Width: the width of the pop-up prompt.
Highlightcssclass: The style applied to the pop-up prompt information
Warningiconimageurl: Address of the alert image in the pop-up information
Example
1. Open vs2005 and create an ajaxcontroltoolkit website named oec2003_validatorcallout.
2. Open the default. aspx page generated by default and switch to the form view.
3. Drag two Textbox, two requiredfieldvalidator and two validatorcallout controls on the page.
4 two requiredfieldvalidator controls correspond to two Textbox, to verify that the two textbox cannot be empty, and define the error message. These error messages will be displayed through validatorcallout, set the display attribute of requiredfieldvalidator to none. Otherwise, the error message will be displayed in both places. This is what we don't want to see. The Code is as follows:
<Asp: requiredfieldvalidator id = "requiredfieldvalidator1" runat = "server" controltovalidate = "textbox1" display = "NONE" errormessage = "name cannot be blank <br> enter name"> </ASP: requiredfieldvalidator> <br/> password & nbsp; Code: <asp: textbox id = "textbox2" runat = "server" textmode = "password" width = "148px"> </ASP: textbox> <asp: requiredfieldvalidator id = "requiredfieldvalidator2" runat = "server" controltovalidate = "textbox2" display = "NONE" errormessage = "the password cannot be blank. Enter the password"> </ASP: requiredfieldvalidator
5. set two validatorcallout controls to correspond to two requiredfieldvalidator controls. The Code is as follows:
<ajaxtoolkit:validatorcalloutextender id="ValidatorCalloutExtender1" runat="server" targetcontrolid="RequiredFieldValidator1"> </ajaxtoolkit:validatorcalloutextender> <ajaxtoolkit:validatorcalloutextender id="ValidatorCalloutExtender2" runat="server" targetcontrolid="RequiredFieldValidator2"> </ajaxtoolkit:validatorcalloutextender>
6. Save the design and run the program. When the form is submitted without entering text in the text box, an error prompt box appears next to the text box, as shown in