ASP. NET automatically checks whether the user name is registered (using Ajax technology) (running in IE and Firefox)
Design by hakuci
Code download
The running environment ASP. NET 2.0, Ajax extension package, and sqlserver database can be run only after the development environment is configured. Code .
This code is based on a three-tier architecture
In an empty solution, add a project: model, Dal, BLL, dbutility, and an Ajax-based website project.
Model
Including: Class desingerinfo. CS stores entity classes for data access layer and logic layer calls
Dal data access layer
The desinger. CS class is used to create various data objects. The configuration files and reflection are used here.
Bll business logic layer
Including: desinger. CS Processing Applications Program Is called by the presentation layer.
Dbutility public data access layer
Including: Class sqlhelper. CS to implement specific executereader, executedatatable, executenonquery, etc.
The website project is the presentation layer:
Database Table Structure (this example only uses the first field)
On the "register. aspx" Page, add the updatepanel and updateprogress controls of the textbox and Ajax extensions controls.
For example:
Add control content and Set Properties
Updatepanel content
The updatepanel settings Add the asynchronous send back control bound to the text box. An event occurs when the text is changed.
Updateprogress content
Updateprogress attribute settings bind updatepanel
The running effect is as follows: (run through IE and Firefox)
Code Analysis
/// <Summary>
/// The designer checks whether the registered URL is automatically generated.
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "E"> </param>
Protected void txtname_textchanged (Object sender, eventargs E)
{
Bll. desinger blldata = new desinger (); // create an object
If (blldata. exists (this. txtname. Text. Trim () // you can check whether this user exists.
{
This. lblcheckname. Text = "registration is not allowed! ";
This. lblcheckname. Visible = true;
}
Else
{
This. lblcheckname. Text = "allow registration! ";
This. lblcheckname. Visible = true;
}
This. labelurl. Text = "http: // localhost/DESIGNER/" + this. txtname. text;
}
Code download
Design by hakuci
2008.4.22