PDA

View Full Version : [CLOSED] MessageBox Function Fn pass arguments in Ext 2.x



xeo4.it
Apr 03, 2014, 10:06 AM
Goodmorning,
in a my old thread there is an example in Ext 1.x to pass argument to a function in a messagebox,
can you translate in Ext 2.x? Because I take an error "The object not support property or method 'createDelegate'" .
Thank you

Jimmy

Old Example


<%@ Page Language="C#" %>
<%@ Import Namespace="System.Threading" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
protected void Button3_Click(object sender, DirectEventArgs e)
{
string[] parameters = new string[1];
parameters[0] = "First test parameter";

X.Msg.Show(new MessageBoxConfig
{
Title = "",
Message = "Test",
Buttons = MessageBox.Button.OKCANCEL,
AnimEl = this.Button3.ClientID,
Fn = new JFunction { Fn = string.Format("showResultText.createDelegate(window,[{0}], true)", JSON.Serialize(parameters)) }
});
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>

<script type="text/javascript">


var showResultText = function (btn, text, opt, args) {
Ext.Msg.notify("Button Click", args[0]);
};
</script>

</head>
<body>
<ext:ResourceManager ID="ResourceManager1" runat="server" DirectEventUrl="default.aspx" />

<h2>3. Test Arguments</h2>

<span>A multi-line prompt dialog.</span>

<ext:Button ID="Button3" runat="server" Text="Show">
<DirectEvents>
<Click OnEvent="Button3_Click" />
</DirectEvents>
</ext:Button>

</body>
</html>

Daniil
Apr 03, 2014, 8:25 PM
Hi Jimmy,

There is a JavaScript error.

TypeError: showResultText.createDelegate is not a function

Please search for "createDelegate" here:
http://examples2.ext.net/#/Getting_Started/Release_Documents/BREAKING_CHANGES/

xeo4.it
Apr 04, 2014, 2:25 PM
Hi Daniil,
I have corrected the example, below I have put it.
Thank you very much

Jimmy



<%@ Page Language="C#" %>
<%@ Import Namespace="System.Threading" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
protected void Button3_Click(object sender, DirectEventArgs e)
{
string[] parameters = new string[1];
parameters[0] = "First test parameter";


X.Msg.Show(new MessageBoxConfig
{
Title = "",
Message = "Test",
Buttons = MessageBox.Button.OKCANCEL,
AnimEl = this.Button3.ClientID,
Fn = new JFunction { Fn = string.Format("Ext.Function.bind(showResultText, window, [{0}], true)", JSON.Serialize(parameters)) }
});
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>

<script type="text/javascript">


var showResultText = function (btn, text, opt, args) {
Ext.Msg.notify("Button Click", args[0]);
};
</script>

</head>
<body>
<ext:ResourceManager ID="ResourceManager1" runat="server" DirectEventUrl="default.aspx" />

<h2>3. Test Arguments</h2>

<span>A multi-line prompt dialog.</span>

<ext:Button ID="Button3" runat="server" Text="Show">
<DirectEvents>
<Click OnEvent="Button3_Click" />
</DirectEvents>
</ext:Button>

</body>
</html>