Recently, some friends of anthem. NET and I mentioned the ASP. Net-based Ajax framework. Today I have the opportunity to try it myself. The preliminary feeling seems to be comparable to ASP. NET Ajax, or even better than ASP. NET Ajax in some places. Of course, a half-hour attempt cannot be counted as anything.ArticleMany of the conclusions may be due to my "Ignorance" and I named it "Guan zhongpiao.
The main page of anthem. NET is here, which provides download files and a large number of examples.Program. At the same time, the Mye Hu brothers in the blog Park have also written some good articles about anthem. net, which is worth learning (hopefully Mye Hu brothers will make persistent efforts !).
This article uses ASP. net Ajax and anthem. net implements the most simple Ajax application, that is, a button on the page is a label. clicking the button will set the text in the label on the server side. Of course, all of this is done using Ajax asynchronous delivery. And compare the compilation of the two implementation methodsCode, Generate client script size, execution efficiency, etc.
ASP. NET Ajax program code
I think you are very familiar with ASP. NET Ajax: scriptmanager and updatepanel:
<ASP: scriptmanager ID= "Scriptmanager1" Runat= "Server" />
<Div>
<ASP: button ID= "Btnsettext" Runat= "Server" Text= "Set text" Onclick= "Btnsettext_click" />
<ASP: updatepanel ID= "Up1" Runat= "Server">
<Triggers>
<ASP: asyncpostbacktrigger Controlid= "Btnsettext" Eventname= "Click" />
</Triggers>
<Contenttemplate>
<ASP: Label ID= "Lbtext" Runat= "Server" />
</Contenttemplate>
</ASP: updatepanel>
</Div>
Server-side processing functions are also simple:
Protected VoidBtnsettext_click (ObjectSender, eventargs E)
{
Lbtext. Text ="This text is set on server side .";
}
Success!
Anthem. Net program code
Replace. DLL copy to the bin folder of the web site, and then in the web. <configuration> \ <system. add the following line to the Web >\< pages >\< controls> to register anthem. net Control:
<Add Tagprefix= "Anthem" Namespace= "Anthem" Assembly= "Anthem"/>
You do not need to add scriptmanager to the anthem. NET page. Instead, you provide a set of server-side controls with Ajax functions inherited from existing ASP. NET controls. According to the above registration in the web. config file, the control prefix is anthem.
The page of the anthem. Net program is very simple:
<Div>
<Anthem: button ID= "Btnsettext" Runat= "Server" Text= "Set text" Onclick= "Btnsettext_click" />
<Anthem: Label ID= "Lbtext" Runat= "Server" />
</Div>
The server-side processing function is one more line than ASP. NET Ajax and explicitly specifies that the content in the label needs to be updated (this sentence is similar to the updatepanel of ASP. NET Ajax ):
Protected VoidBtnsettext_click (ObjectSender, eventargs E)
{
Lbtext. Text ="This text is set on server side .";
Lbtext. updateaftercallback =True;
}
It seems simpler!
Running result
The running results of the two examples are exactly the same: click the button to execute an asynchronous delivery, and the text set by the server is displayed in the label.
Comparison of ASP. NET Ajax and anthem. Net implementation methods
The same functions, but there are comparisons:
Conclusion
The understanding is not deep enough, and the conclusion is no longer ...... The above data seems to illustrate some problems!