Author: Dflying Chen ( Http://dflying.cnblogs.com/ )
PS: I haven't updated it for a long time. Sorry ...... I hope you will continue to support me.
In the previous articles of this series (DevelopmentASP. NET AtlasServerExtenderWidget--Basic concepts and pre-Requirements,DevelopmentASP. NET AtlasServerExtenderWidget--Compile the clientBehavior,DevelopmentASP. NET AtlasServerExtenderWidget--Write ServerExtender & dflyingRecent trends), We have developedAtlasServerExtenderControl. This article is the last one. It describes how to use the previously written control.
First, createAtlas web site, And add reference to the Control compiled above. See:
Then, writeWeb ServiceHere, I simply assume that the user name cannot be obtained.Dflying. Of course, in the specific implementation, You can query and verify from the database. Save itUserregisterservice. asmx:
[WebService (namespace = " Http://www.dflying.net/ " )]
[Webservicebinding (conformsto = Wsiprofiles. basicprofile1_1)]
Public Class Userregisterservice: system. Web. Services. WebService {
[Webmethod]
Public Bool Checkusername ( String Usernamecandidate) {< br> If (usernamecandidate = " dflying " )
return false ;< br> return true ;< BR >}
}
Then, addAtlasOfScriptmanager:
< Atlas: scriptmanager ID = "Scriptmanager1" Runat = "Server" />
AddTextbox, Used to enter the user name;LabelTo display the verification results. Note that both controls areASP. NETThat is, you can use the WYSIWYG development method.ToolboxDrag them to the page.ASP. NETThe development model is the same.
< ASP: textbox ID = "Textbox1" Runat = "Server" > </ ASP: textbox >
< ASP: Label ID = "Label1" Runat = "Server" > </ ASP: Label >
Then it is the core part of the instance,Validateusernameextender. Enter the followingCodeTo specify the properties of our controls. Of course, if you want to, you can also add it to toolbox and drag it to the page.
< Dflying: validateusernameextender ID = "Validateusername" Runat = "Server" >
< Dflying: validateusernameproperties Checkresultlabelid = "Label1" Targetcontrolid = "Textbox1"
Servicename = "Userregisterservice. asmx" Methodname = "Checkusername" Validmessage = "You can use this User Name ."
Invalidmessage = "This user name has already been used, please choose another ." />
</ Dflying: validateusernameextender >
Note thatIDESmart sensing:
All optional properties are listed in the Properties window, which greatly accelerates our development:
In the browser, test the user name that can be used:
Unavailable User Name:
ValidateusernameextenderThis exampleProgramThe code can be downloaded here: http://files.cnblogs.com/dflying/ValidateUserName.zip