PDA

View Full Version : Confirm MessageBox with ButtonsConfig in UserControl



andreydruz
Mar 08, 2011, 6:21 PM
Hello,

I trying to use Confirm MessageBox with ButtonsConfig in UserControl;
DoYes() and DoNo() doesn't work.

The code same to http://examples1.ext.net/#/MessageBox/Basic/ButtonsConfig/ except UserControl

Its work on page but doesn't in UserControl



<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<%@ Register src="test.ascx" tagname="test" tagprefix="uc" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
</head>
<body>
<ext:ResourceManager runat="server" />
<form id="Form1" runat="server">
<uc:test ID="uctest" runat="server" />
</form>
</body>
</html>





<%@ Control Language="C#" AutoEventWireup="true" %>
<%@ 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 = "#{DirectMethods}.DoYes()",
Text = "Yes Please"
},
No = new MessageBoxButtonConfig
{
Handler = "#{DirectMethods}.DoNo()",
Text = "No Thanks"
}
}).Show();
}

[DirectMethod]
public void DoYes()
{
Notification.Show(new NotificationConfig { Title = "Title", Icon = Icon.Information, Html = "yes" });
}

[DirectMethod]
public void DoNo()
{
Notification.Show(new NotificationConfig { Title = "Title", Icon = Icon.Information, Html = "no" });

}
</script>

<p>
<ext:Button ID="Button3" runat="server" Text="Confirm" Icon="Error">
<Listeners>
<Click Handler="#{DirectMethods}.DoConfirm()" />
</Listeners>
</ext:Button>
</p>

<p><ext:Label ID="Label1" runat="server" Format="You clicked the '<b>{0}</b>' Button." /></p>


Thanks
Andrey.

andreydruz
Mar 08, 2011, 6:48 PM
I find the error.

Resolved.




<%@ Control Language="C#" AutoEventWireup="true" %>
<%@ 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 = "Ext.net.DirectMethods.uctest.DoYes()",
Text = "Yes Please"
},
No = new MessageBoxButtonConfig
{
Handler = "Ext.net.DirectMethods.uctest.DoNo()",
Text = "No Thanks"
}
}).Show();
}

[DirectMethod]
public void DoYes()
{
Notification.Show(new NotificationConfig { Title = "Title", Icon = Icon.Information, Html = "yes" });
}

[DirectMethod]
public void DoNo()
{
Notification.Show(new NotificationConfig { Title = "Title", Icon = Icon.Information, Html = "no" });

}
</script>

<p>
<ext:Button ID="Button3" runat="server" Text="Confirm" Icon="Error">
<Listeners>
<Click Handler="Ext.net.DirectMethods.uctest.DoConfirm()" />
</Listeners>
</ext:Button>
</p>

<p>
<ext:Button ID="Button1" runat="server" Text="Confirm" Icon="Error">
<Listeners>
<Click Handler="Ext.net.DirectMethods.uctest.DoYes();" />
</Listeners>
</ext:Button>
</p>

<p>
<ext:Button ID="Button2" runat="server" Text="Confirm" Icon="Error">
<Listeners>
<Click Handler="Ext.net.DirectMethods.uctest.DoNo();" />
</Listeners>
</ext:Button>
</p>

<p><ext:Label ID="Label1" runat="server" Format="You clicked the '<b>{0}</b>' Button." /></p>




<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<%@ Register src="~/Crm/Controls/test.ascx" tagname="test" tagprefix="uc" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
</head>
<body>
<ext:ResourceManager runat="server" />
<form id="Form1" runat="server">
<uc:test ID="uctest" runat="server" />
</form>
</body>
</html>