[CLOSED] DirectMethod Parameter Value from JavaScript

  1. #1

    [CLOSED] DirectMethod Parameter Value from JavaScript

    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>
    Last edited by Daniil; Apr 16, 2013 at 5:32 AM. Reason: [CLOSED]
  2. #2
    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.
    Geoffrey McGill
    Founder

Similar Threads

  1. [CLOSED] [#49] Directmethod exception with hashtable as parameter
    By Patman in forum 1.x Legacy Premium Help
    Replies: 22
    Last Post: Mar 05, 2013, 5:11 PM
  2. Replies: 0
    Last Post: May 14, 2012, 3:41 PM
  3. Replies: 0
    Last Post: Nov 02, 2011, 8:34 AM
  4. [CLOSED] JAVASCRIPT - get parameter URL
    By rnfigueira in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 29, 2011, 2:53 PM
  5. [CLOSED] DirectMethod --> Webservice with Dictionary parameter
    By jchau in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 20, 2011, 9:15 PM

Tags for this Thread

Posting Permissions