Coolite toolkit PAGE method call

Source: Internet
Author: User
The ajaxmethod function provided by coolite toolkit is the same as the pagemethod of ASP. NET Ajax. It is very easy to use. For details, refer to the following simple example:
[Ajaxmethod]
Public String pagemethod ()
{
Return "called Page POST method: pagemethod ()";
} <Ext: scriptmanager id = "scriptmanager1" runat = "server">
</Ext: scriptmanager>
<Ext: button id = "button1" runat = "server" text = "Submit">
<Listeners>
<Click handler = "requestmethod ()"
/>
</Listeners>
</Ext: button>
<SCRIPT type = "text/JavaScript">
Function requestmethod ()
{
Coolite. Ajaxmethods . Pagemethod ({
Success: function (result ){
Ext. msg. Alert ('Return prompt ', result );
}
});
}
</SCRIPT>

Use the coolie. ajaxmethods. method name provided by the coolite toolkit to directly call the POST method. Mutual Transmission Data (Simple text string, object, JSON Supports multiple formats, which is the same as ASP. NET Ajax. In addition, coolite toolkit also provides a more powerful PAGE method calling function, that is, it can call the master page and the user's Definition Controls (usercontrol. If you want to call the method on the master page, you need to provide the ajaxmethod method interface in the corresponding master page, and configure the proxy for it through ajaxmethodproxyidattribute Generate Policy, as shown in:
[Ajaxmethodproxyid (idmode = ajaxmethodproxyidmode. None)]
Public
Partial
Class mymaster: system. Web. UI. masterpage
{
[Ajaxmethod]
Public
String pagemethod ()
{
Return
"The POST method of the master page is called: pagemethod ()";
}
}
Frontend page call:
<% @ Page title = "" Language = "C #" masterpagefile = "~ /Mymaster. Master "autoeventwireup =" true"
Codebehind = "masterdemo. aspx. cs" inherits = "webapplication1.masterdemo"
%>
<Asp: Content ID = "content1" contentplaceholderid = "contentplaceholder1" runat = "server">
<Ext: scriptmanager id = "scriptmanager1" runat = "server">
</Ext: scriptmanager>
<Ext: button id = "button1" runat = "server" text = "Submit">
<Listeners>
<Click handler = "requestmethod ()"
/>
</Listeners>
</Ext: button>
<SCRIPT type = "text/JavaScript">
Function requestmethod (){
Coolite. ajaxmethods. pagemethod ({
Success: function (result ){
Ext. msg. Alert ('Return prompt ', result );
}
});
}
</SCRIPT>
</ASP: content>
If you call methods in user-defined controls, the method is not much different from the master page. The difference is that usercontrol needs to set an alias to successfully call the method. Example:
[Ajaxmethodproxyid (idmode = ajaxmethodproxyidmode. Alias, alias =
"UC")]
Public
Partial
Class timecontrol: system. Web. UI. usercontrol
{
[Ajaxmethod]
Public
String pagemethod ()
{
Return datetime. Now. tostring ();
}
}
The client uses the alias to call the following:
<Uc1: timecontrol id = "timecontrol1" runat = "server"
/>
<Ext: button id = "btnusercontrol" runat = "server" text = "Call usercontrol">
<Listeners>
<Click handler = "coolite. ajaxmethods. UC. pagemethod (
{
Success: function (result)
{
Ext. msg. Alert (result );
}
});"
/>
</Listeners>
</Ext: button>

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.