PDA

View Full Version : [CLOSED] DirectMethod Parameter Value from JavaScript



VirtualArtists
Apr 08, 2013, 7:44 PM
Hi - I'm new to Ext.Net, so maybe I'm missing something, but here is the goal:
Value="FileInfo()" : Calls JavaScript function - FileInfo() should get return value from JavaScript function FileInfo() , and pass that to the DirectEvent Method as the value of the "sFilePath" param. Should pass this into the URLShareFile C# method in code behind. Is this possible?



<ext:Button ID="btnShare" runat="server"
Text="Select File, then click here toget Share/Embed Code: (URL Link):">
<DirectEvents>
<Click OnEvent="URLShareFile">
* <ExtraParams> ** * * *
<ext:Parameter Name="sFilePath" Value="FileInfo()" />
</ExtraParams>
<EventMask ShowMask="true" />
</Click>
</DirectEvents>
</ext:Button>

geoffrey.mcgill
Apr 08, 2013, 9:48 PM
Hello,

By default the .Value will be sent as a text/string value, which means in your sample the value "FileInfo()" will be sent to the DirectEvent handler on the server. The JavaScript function is not actually called under this mode.

You can work around this issue by setting Mode="Raw" on the <ext:Parameter>.

The following sample demonstrates the whole scenario.

Example


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

<script runat="server">
protected void Button1_Click(object sender, DirectEventArgs e)
{
X.Msg.Notify("Random", e.ExtraParams["random"]).Show();
}
</script>


<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET Example</title>


<script>
var getRandom = function () {
return Math.floor(Math.random() * 10);
};
</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />


<ext:Button runat="server" Text="Submit">
<DirectEvents>
<Click OnEvent="Button1_Click">
<ExtraParams>
<ext:Parameter Name="random" Value="getRandom()" Mode="Raw" />
</ExtraParams>
</Click>
</DirectEvents>
</ext:Button>
</form>
</body>
</html>

Hope this helps.