Simple application implementation code for MessageBox in Ext.net

  • 2020-05-17 05:05:49
  • OfStack

Address: http: / / examples. ext. net / # / MessageBox/Basic/ButtonsConfig /
In the example, the method used seems rather complicated.
Foreground.aspx file
 
<%@ Page Language="C#" %> 
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %> 
<script runat="server"> 
[DirectMethod] 
public void DoConfirm() 
{ 
X.Msg.Confirm("Message", "Confirm?", new MessageBoxButtonsConfig 
{ 
Yes = new MessageBoxButtonConfig 
{ 
Handler = "CompanyX.DoYes()", 
Text = "Yes Please" 
}, 
No = new MessageBoxButtonConfig 
{ 
Handler = "CompanyX.DoNo()", 
Text = "No Thanks" 
} 
}).Show(); 
} 
[DirectMethod] 
public void DoYes() 
{ 
this.Label1.Text = "YES"; 
} 
[DirectMethod] 
public void DoNo() 
{ 
this.Label1.Text = "NO"; 
} 
</script> 
<!DOCTYPE html> 
<html> 
<head runat="server"> 
<title>Confirm MessageBox with ButtonsConfig - Ext.NET Examples</title> 
<link href="/resources/css/examples.css" rel="stylesheet" type="text/css" /> 
</head> 
<body> 
<ext:ResourceManager runat="server" DirectMethodNamespace="CompanyX" /> 
<form runat="server"> 
<p> 
<ext:Button runat="server" Text="Confirm" Icon="Error"> 
<Listeners> 
<Click Handler="CompanyX.DoConfirm()" /> 
</Listeners> 
</ext:Button> 
</p> 
</form> 
</body> 
</html> 

Write two separate functions to determine which one to execute. Each function should be marked [DirectMethod] in front. It feels complicated. Then I looked for the button event and found a simple way to do it.
The code in body is as follows:
 
<body> 
<ext:ResourceManager runat="server" DirectMethodNamespace="CompanyX" /> 
<form runat="server"> 
<p> 
<ext:Button runat="server" Text="Confirm" Icon="Error"> 
<DirectEvents> 
<Click OnEvent="Confirm"> 
<Confirmation ConfirmRequest="true" Title=" prompt " Message=" Are you sure you want to delete it? " /> 
</Click> 
</DirectEvents> 
</ext:Button> 
</p> 
</form> 
</body> 

In fact, it can be written directly in the button. The function is to pop up the MessageBox box when the Confirm event is executed in the background. The above two buttons are ok and cancel. If you select ok, you will execute the background event, otherwise you will not jump to the background. This method is a good solution to the simple prompt box function.
Background Confirm event code:
 
protected void Confirm(object sender, DirectEventArgs e) 
{ 
X.Msg.Alert(" Click on the hint ", " You click ok and execute a background event! ").Show(); 
} 

You can use it for reference. I welcome you to exchange ideas.

Related articles: