Neither will Ajax. It is true. However, it will be in the future.

Source: Internet
Author: User
No, it's true. However, it will be in the future, because I want to learn. Article Add to favorites:

Ajax Research Summary ( (Author:Li TianpingReprinted, please note) )
From: http://www.cnblogs.com/ltp/archive/2005/12/03/289725.html

AjaxRecently, it has become popular and popular.WebRefreshing issues during development brings new vigor and hope. Although this technology was used long agoXMLHttpRequest JavascriptSeveral technologies are combined in a certain way, which is not a new technology. However, with a name and encapsulation, it still provides a lot of convenience for many developers. Therefore, I took the time to study it and applied it to the current project. I also made a summary here.

 

 

Specific use:

 

 

1.Add reference in ProjectAjax. dll(The version I used is 5.7.22 . 2)

 

 

2.ModifyWeb. config, Add

 

 


< Configuration >
< System . Web >
< Httphandlers >
< Add Verb = "Post, get" Path = "Ajax/*. ashx" Type = "Ajax. pagehandlerfactory, Ajax" />
</ Httphandlers >

< System . Web >
</ Configuration >

 

 

 

 

3.Create a new class that implements business logic, add a method to it, and add a method to the method.[Ajax. ajaxmethod ()]. For example:

 

 

/// <Summary>

 

 

///Business Logic class

 

 

/// </Summary>

 

 

Public ClassAjaxbllclass

 

 

{

 

 

PublicAjaxbllclass ()

 

 

{

 

 

}

 

 

[Ajax. ajaxmethod ()]

 

 

Public StringGetplacelist (IntClassid)

 

 

{

 

 

Advertisement. BLL. admanage. adplace =NewAdvertisement. BLL. admanage. adplace ();

 

 

Dataset DS = adplace. getlistbyclass (classid );

 

 

StringSTR = "";

 

 

For(IntM = 0; m <Ds. Tables [0]. Rows. Count; m ++)

 

 

{

 

 

STR + = "," + Ds. tables [0]. rows [m] ["placeid"]. tostring () + "|" + Ds. tables [0]. rows [m] ["placename"]. tostring ();

 

 

}

 

 

STR = Str. substring (1, str. Length-1 );

 

 

ReturnSTR;

 

 

}

 

 

 

 

4.On the call page. CSOfPage_loadAdd a class registration line to the eventCode

 

 

Private Void Page_load ( Object Sender, system. eventargs E)
{
// Valid registration methods
Ajax. Utility. registertypeforajax (Typeof(Ajaxbllclass ));
}

 

 

Note:Typeof (Ajaxbllclass)Medium,AjaxbllclassIs the class to contain the method to be called, that is,3Business Logic class created in stepAjaxbllclass

 

 

5.In the call page file or write a separateJSFile,JavascriptThe Code calls the method of the business logic class. For example:

 

 

FunctionClassresult ()

 

 

{

 

 

VaRClassid = Document. getelementbyid ("dropclassid ");

 

 

Ajaxbllclass. getplacelist(Classid. Value, get_class_result_callback );//CallBusiness logic methods

 

 

 

 

}

 

 

 

 

FunctionGet_class_result_callback (response)

 

 

{

 

 

If(Response. value! = NULL)

 

 

{

 

 

Document. getelementbyid ("dropplaceid"). Length = 0;

 

 

VaR piarray = response. value. Split (",");

 

 

For(VaRI = 0; I <piarray. length; I ++)

 

 

{

 

 

VaRAry1 = piarray [I]. tostring (). Split ("| ");

 

 

Document. getelementbyid ("dropplaceid"). Options. Add (NewOption (ary1 [1]. tostring (), ary1 [0]. tostring ()));

 

 

}

 

 

}

 

 

Return

 

 

}

 

 

6.Call

 

 

<Asp: dropdownlist ID="Dropclassid"Runat="Server"Width="250px"Onchange=" Classresult ()"></ASP: dropdownlist>

 

 

Note: For earlier versionsAjaxTo be modifiedGlobal. asaxOfApplication_startEvent, SetAjaxOfHandlerpath:

 

 

Protected VoidApplication_start (Object sender, eventargs E)
{
// Ajax. Utility. handlerpath = "ajax ";//Old Version requirements
}

 

 

Experience:I personally think that although it solves the page refresh problem to a certain extent, it needs to write a lot of script code, and. NetThe combination of the control and class library is not very good, and it is not suitable for a large number of projects. It is still used in some places where the refresh requirements are not too high.ASP. NETThe encoding method is better.

 

 

 

 

Download Sample Code

 

 

 

 

Add some Ajax Resources:

 

 

Http://ajax.schwarz-interactive.de

Http://weblogs.asp.net/mschwarz/

 

 

Http://groups.google.com/group/ajaxpro? Lnk = Li

 

 

MsdnAtlas onWebsite

 

 

ASP. NET "Atlas"Official Website

 

 

ASP. NET "Atlas"Preview document

 

 

AtlasQuick Start tutorial

 

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.