[CLOSED] Direct Methods with return doesn't work in user control

  1. #1

    [CLOSED] Direct Methods with return doesn't work in user control

    Direct Methods with return doesn't work in user control. it throw javascript error. It cannot find the server method.
    Last edited by Daniil; Nov 13, 2010 at 7:06 PM. Reason: [CLOSED]
  2. #2
    Please see item #3 at the following location,

    http://forums.ext.net/showthread.php...ation-Required
    Geoffrey McGill
    Founder
  3. #3
     
    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <%@ Register Src="~/test.ascx" TagName="test1"  TagPrefix="uc" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <script runat="server">
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" /> 
        <div>
        <uc:test1 ID="test" runat="server" />
        </div>
        </form>
    </body>
    </html>


     
    <%@ Control Language="C#" ClassName="test" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        [DirectMethod]
        public static string NodeLoad(string nodeID)
        {
            Ext.Net.TreeNodeCollection nodes = new Ext.Net.TreeNodeCollection();
            if (!string.IsNullOrEmpty(nodeID))
            {
                Ext.Net.TreeNode node = new Ext.Net.TreeNode();
                node.Text = "TextField node";
                node.CustomAttributes.Add(new ConfigItem("editor", "1", ParameterMode.Value));
                nodes.Add(node);
                node = new Ext.Net.TreeNode();
                node.Text = "1";
                node.CustomAttributes.Add(new ConfigItem("editor", "2", ParameterMode.Value));
                nodes.Add(node);
                node = new Ext.Net.TreeNode();
                node.Text = "ComboBox node";
                node.CustomAttributes.Add(new ConfigItem("editor", "3", ParameterMode.Value));
                nodes.Add(node);
            }
            return nodes.ToJson();
        } 
    </script>
    
     <script type="text/javascript">
         function nodeLoad(node) {
             Ext.net.DirectMethods.NodeLoad(node.id, {
                 success: function (result) {
                     var data = eval("(" + result + ")");
                     node.loadNodes(data);
                 },
                 failure: function (errorMsg) {
                     Ext.Msg.alert('Failure', errorMsg);
                 }
             });
         } 
        </script> 
      
     
        
       
        <ext:TreeGrid ID="TreeGrid1" runat="server" Width="310"> 
            <Columns> 
                <ext:TreeGridColumn Header="Test" DataIndex="text" Width="200" /> 
            </Columns> 
            <Root> 
                <ext:AsyncTreeNode NodeID="0" Text="Root" /> 
            </Root> 
            <Listeners> 
                <BeforeLoad Fn="nodeLoad" /> 
            </Listeners> 
            <Editors> 
                <ext:TreeEditor ID="TreeEditor1" runat="server"> 
                    <Field> 
                        <ext:TextField ID="TextField1" runat="server" /> 
                    </Field> 
                    <Filter Attribute="editor" Value="1" /> 
                </ext:TreeEditor> 
                <ext:TreeEditor ID="TreeEditor2" runat="server"> 
                    <Field> 
                        <ext:NumberField ID="NumberField1" runat="server" /> 
                    </Field> 
                    <Filter Attribute="editor" Value="2" /> 
                </ext:TreeEditor> 
                <ext:TreeEditor ID="TreeEditor3" runat="server"> 
                    <Field> 
                        <ext:ComboBox ID="ComboBox1" runat="server" ForceSelection="true"> 
                            <Items> 
                                <ext:ListItem Text="Item 1" /> 
                                <ext:ListItem Text="Item 2" /> 
                            </Items> 
                        </ext:ComboBox> 
                    </Field> 
                    <Filter Attribute="editor" Value="3" /> 
                </ext:TreeEditor> 
            </Editors> 
        </ext:TreeGrid>
  4. #4
    I think you just have the path wrong to the DirectMethod location. You must add the client-id of the UserControl.

    Example

    Ext.net.DirectMethods.test.NodeLoad
    Hope this helps.
    Geoffrey McGill
    Founder
  5. #5
    the javascript is on the usercontol not on the page. when I add the user control name to the method call I get an error

    System.Exception: The static DirectMethod '' has not been defined. at Ext.Net.DirectRequestModule.ProcessRequest(HttpApplication app, HttpRequest request)
    Last edited by Daniil; Nov 15, 2010 at 8:33 AM. Reason: Please use [CODE] tags
  6. #6
    I got it Fixed. Move I added code behind and
    I added this line of code at the top of the userconrol
    [DirectMethodProxyID(IDMode = DirectMethodProxyIDMode.Alias, Alias = "Test")]

    Thank you for you help
    Last edited by Daniil; Nov 15, 2010 at 8:32 AM. Reason: Please use [CODE] tags

Similar Threads

  1. Direct Methods and Custom Control
    By Zdenek in forum 1.x Help
    Replies: 0
    Last Post: Apr 19, 2012, 10:18 PM
  2. [CLOSED] GridPanel Cell Tooltips doesn't work in user control
    By skisly in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 09, 2011, 1:57 PM
  3. Replies: 8
    Last Post: Jan 25, 2011, 4:21 AM
  4. [CLOSED] Direct events in user control
    By tiramisu in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Dec 13, 2010, 11:34 AM
  5. Replies: 4
    Last Post: Feb 09, 2010, 6:14 PM

Posting Permissions