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 ();
}
});