① The prompt box is written in the background:
Front-end code:
Code
<Script type = "text/javascript">
Function DelSelectedRowFn (){
Ext. MessageBox. confirm ('hprompt ', 'whether to delete these records', function (btn ){
If (btn = "yes "){
Coolite. AjaxMethods. DeleteSelectedRow (); // executes the background method.
}
});
}
</Script>
<Ext: Button ID = "ButtonDel" runat = "server" Text = "delete test">
<Listeners>
<Click Fn = "DelSelectedRowFn"/>
</Listeners>
</Ext: Button>
Background code:
Code
[AjaxMethod]
Public void DeleteSelectedWorkFlow ()
{
// Write the logic code for deletion first...
// If the deletion is successful, the following prompt is displayed.
Ext. Msg. Show (new MessageBox. Config
{
Title = "prompt ",
Message = "you have successfully deleted this record! ",
Buttons = MessageBox. Button. OK,
AnimEl = this. ButtonDel. ClientID,
});
}
② The prompt box is written at the front end:
Front-end code:
Code
<Script type = "text/javascript">
// After the deletion example is successful, a prompt box is displayed at the front end.
Function DelSelectedRowFn2 (){
Ext. MessageBox. confirm ('hprompt ', 'Do you really want to delete this record?', function (btn ){
If (btn = "yes "){
Coolite. AjaxMethod. request ("DeleteSelectedRow2 ",{
Success: function (result ){
Ext. Msg. alert ("prompt", result );
},
EventMask :{
ShowMask: true,
Msg: 'deleting... ', please wait ...',
MinDelay: 500
}
});
}
});
}
</Script>
<Ext: Button ID = "Button3" runat = "server" Text = "after deletion is successful, a dialog box is displayed at the front-end (ExtJS)">
<Listeners>
<Click Fn = "DelSelectedRowFn2"/>
</Listeners>
</Ext: Button>
Background code:
[AjaxMethod]
Public string DeleteSelectedRow2 ()
{
// Write the deleted logic code first.
// A string is returned after deletion.
Return "you have successfully deleted it! ";
}
3. Write all in the background:
Code
Protected void button#click (object sender, AjaxEventArgs e)
{
Ext. Msg. Alert ("prompt", "message content", new MessageBox. ButtonsConfig
{
Yes = new MessageBox. ButtonConfig
{
Handler = "Coolite. AjaxMethods. DoYes ()",
Text = "OK"
},
No = new MessageBox. ButtonConfig
{
Handler = "Coolite. AjaxMethods. DoNo ()",
Text = "cancel"
}
}). Show ();
}
// Server method:
[AjaxMethod]
Public void DoYes ()
{
Ext. Msg. Alert ("Operation prompt", "deleted successfully! "). Show ();
}
[AjaxMethod]
Public void DoNo ()
{
Ext. Msg. Alert ("Operation prompt", "You just clicked cancel"). Show ();
}
}
}