Coolite method call

Source: Internet
Author: User

Today, I need to delete the check box. I encountered a small problem. Then I wrote something in a mess, and I fixed the problem by mistake. the blocked thinking is active, so you can't help but write down the coolite method call.

Let's start with the button:

Coolite's button method calls are flexible. It can easily call Javascript methods, or call the backgroundCodeMethod in.

Parameters can be transferred flexibly.

1. CallJavascriptMethod in

Assume that the JavaScript method is

VaR scriptmethod = function ()

{

.....

};

A. the first method to call the JavaScript method.

<Ext: button id = "btn1" text = "button 1" runat = "server">

<Listeners>
<ClickFN= "Scriptmethod"/>
</Listeners>

</Button>

B. method 2

<Ext: button id = "btn1" text = "button 1" runat = "server">

<Listeners>
<ClickHandler= "= {Scriptmethod}"/>
</Listeners>

</Button>

2. Call methods in the server code

A. the first method is very similar to Asp.net.

<Ext: button id = "btn1" text = "button 1" runat = "server">

<Ajaxevents>

<ClickOnevent= "Btn1_click"/>

</Ajaxevents>
</Button>

The corresponding method is:

Protected void btn1_click (Object sender,AjaxeventargsE)
{
This. settime ();
}

The difference from the original Asp.net lies in ajaxeventargs.
B. the following method has powerful functions and is convenient for passing parameters. You can also add a callback function, which is very convenient.

<Ext: button id = "btn1" text = "button 1" runat = "server">

<Listeners>

<ClickHandler= "Coolite. ajaxmethods. mymethod (

# {Textname}. value,

# {Textpass}, value,

{

Success: function (result) {Ext. msg. Alert ('msg ', result );}

}

); "/>

</Listeners>
</Button>

In this way, the following method is called in the server code:

[Ajaxmethod]

PublicIntMymethod (string parameter 1, 2, etc ...)

{

....

Return ...;

}

The green part is the passed parameter, for example# {Txtname}. ValueIs the value entered in the control whose ID is txtname. The control can be an ext control, an ASP Server Control, or an HTML control. 

The blue part is the callback function. After the method you call is executed, a result is returned. You can call JavaScript to process the result here ..

When I encountered this problem today, I found that the background method can be easily called in Javascript as follows:

VaR delselected = function (){
Ext. MessageBox. Confirm ('hprompt ', 'whether to delete record', function (BTN ){
If (BTN = 'yes '){
Coolite. ajaxmethods. Del ();
}
});

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.