|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionThe purpose of creating this ASP.NET AJAX Extender Control is to enrich client validation behavior based on the .NET client validation mechanism. This practice also shows you how easy it can be to create face in and out behavior with a "light-weight" JavaScript library, jQuery. BackgroundProbably, many of you know about the
Using the codeThe way to use this library is very simple. This control is created as an ASP.NET AJAX Extender, and Visual Studio 2008 provides us a very friendly user interface to add an extender to a control. First, you need to put a Like this: Second, you need to create the input controls along with labels that associate with the inputs, and to link them by specifying the " Third, put a button on the page and also the validators that you require. It's that simple. Here is an example: <asp:panel id="pnlTest" runat="server" cssclass="form">
<library:label id="Label1" runat="server"
for="tbxFirstName,tbxLastname" text="Name:" />
<asp:textbox id="tbxFirstName" runat="server" validationgroup="test"></asp:textbox>
<asp:textbox id="tbxLastname" runat="server" validationgroup="test"></asp:textbox>
<asp:requiredfieldvalidator id="RequiredFieldValidator1" runat="server"
controltovalidate="tbxFirstName" display="Dynamic"
errormessage="First name is required."
validationgroup="test"></asp:requiredfieldvalidator>
<asp:requiredfieldvalidator id="RequiredFieldValidator2" runat="server"
controltovalidate="tbxLastname" display="Dynamic"
errormessage="Last name is required."
validationgroup="test"></asp:requiredfieldvalidator>
<br />
<library:label id="Label2" runat="server" for="tbxEmail" text="Email:" />
<asp:textbox id="tbxEmail" runat="server"
validationgroup="test"></asp:textbox><asp:regularexpressionvalidator
id="RegularExpressionValidator1" runat="server"
errormessage="Email is invalid."
controltovalidate="tbxEmail" display="Dynamic"
validationexpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
validationgroup="test"></asp:regularexpressionvalidator>
<br />
<asp:linkbutton id="lbnSubmit" runat="server"
validationgroup="test">Submit</asp:linkbutton>
</asp:panel>
<library:clientvalidationbehavior id="pnlTest_ClientValidationBehavior"
runat="server" invalidcolor="Red" targetcontrolid="pnlTest"
validationgroup="test" validcolor="Black" />
ConclusionIf you wish to know more of how it is done, please visit my blog here. If you like this article, please remember to vote. If you have any suggestions, bugs, or enhancements, please share them with me! Thanks! History
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||