Hi,
I'd like to use a messagebox.prompt and capture the value "text" in codebehind to send an email. How can I do this with DirectMethod?
Please, coud you give an example?
Tks,
Oliver
Printable View
Hi,
I'd like to use a messagebox.prompt and capture the value "text" in codebehind to send an email. How can I do this with DirectMethod?
Please, coud you give an example?
Tks,
Oliver
Hi,
Here you are.
Example
Code:<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
[DirectMethod]
public void Test(string buttonId, string text)
{
X.Msg.Alert("DirectMethod", buttonId + "<br/>" + text).Show();
}
</script>
<!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 runat="server">
<title>Ext.NET Example</title>
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:Button runat="server" Text="Prompt">
<Listeners>
<Click Handler="Ext.Msg.prompt('Title', 'Message', function (buttonId, text) {
Ext.net.DirectMethods.Test(buttonId, text);
});" />
</Listeners>
</ext:Button>
</body>
</html>
Hi Daniil,
Thanks for the reply.
Actually, I need to put the click handler in the codebehind, because I'm doing some actions in the code before show the Ext.Msg.Prompt. I tried to do that, but didn't work.
Here my code, please help me to correct the call.
Code to call the msg in codebehind:
Code:X.Msg.Prompt("Mensagem ao Colaborador", "Informe a mensagem a ser enviada ao colaborador", new JFunction { Handler = String.Format("Ext.net.DirectMethods.EnviarMensagem({0});", Request.Params["text"]) }).Show();
Code:[DirectMethod]
public void EnviarMensagem(string texto)
{
//here the action....
}
Example
Code:X.Msg.Prompt("Title", "Message", new JFunction() { Handler = "Ext.net.DirectMethods.DirectMethodName(text);" }).Show();
Daniil,
The code works but the directmethod is not call. The event is called by clicking in a button in the grid. Here the example:
Code:
<ext:CommandColumn Width="10" Header="" Align="Center" Sortable="false">
<Commands>
<ext:GridCommand CommandName="Mensagem" Icon="Email" ToolTip-Text="Enviar Mensagem ao Colaborador" />
</Commands>
</ext:CommandColumn>
<DirectEvents>
<Command OnEvent="ShowDetails" >
<EventMask ShowMask="true" />
<ExtraParams>
<ext:Parameter Name="command" Value="command" Mode="Raw" />
<ext:Parameter Name="id" Value="record.id" Mode="Raw" />
</ExtraParams>
</Command>
</DirectEvents>
Can you help me? The problem is that is not called.Code:protected void ShowDetails(object sender, DirectEventArgs e)
{
string id = e.ExtraParams["id"];
string command = e.ExtraParams["command"];
X.Msg.Prompt("Message", "Asked question", new JFunction() { Handler = "Ext.net.DirectMethods.EnviarMensagem(text);" }).Show();
}
[DirectMethod]
public void EnviarMensagem(string texto)
{
X.Msg.Alert("Message", texto);
}
Tks
Confirmed, doesn't work with Handler.
Please use Fn.
Example
Code:<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
[DirectMethod]
public void TestDirectMethod(string text)
{
X.Msg.Alert("", text).Show();
}
protected void Prompt(object sender, DirectEventArgs e)
{
X.Msg.Prompt("Title", "Message", new JFunction() { Fn = "handler" }).Show();
}
</script>
<!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 runat="server">
<title>Ext.NET Example</title>
<script type="text/javascript">
var handler = function (buttonId, text) {
Ext.net.DirectMethods.TestDirectMethod(text);
};
</script>
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:Button runat="server" Text="Prompt" OnDirectClick="Prompt" />
</body>
</html>
In 2.x there is not work.
What should be corrected to work in 2.x version?
Hi @ginsar,
I think you just need to replace
withCode:Ext.net.DirectMethods.TestDirectMethod(text);
P.S. This is not informative.Code:App.direct.TestDirectMethod(text);
Please always provide more details.Quote:
In 2.x there is not work.