[CLOSED] You have to set widget's ID to call its methods

  1. #1

    [CLOSED] You have to set widget's ID to call its methods

    I build a control from the codebehind and then used a DirectMethod to close and it gives me the next error : You have to set widget's ID to call its methods.

    Can Anybody help me?

    <%@ Page Language="C#" %> 
    
     <%@ Import Namespace="Panel=Ext.Net.Panel" %> 
    
     <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>  
    
    <!DOCTYPE html /> 
    
     <script runat="server"> 
    
     Ext.Net.Window window1    = new Ext.Net.Window();  
    
    /*---------------------------------------------------------------------------------------------------------*/
     protected void Page_Load(object sender, EventArgs e)
    {
      if (!X.IsAjaxRequest)
        {
            window1.Border = true;
            window1.Width  = 572;
            window1.Height = 430;
                          
            window1.Add(new Ext.Net.Button() { ID = "btnprueba", Text = "Test", OnClientClick = "App.direct.dmtest()" }); 
          
            this.Page.Controls.Add(window1);
        }
    }  
        /*---------------------------------------------------------------------------------------------------------*/
        [DirectMethod]
        public void dmtest()
        {
            this.window1.Close();              
        } 
        /*---------------------------------------------------------------------------------------------------------*/
              
     </script>
     
     <script type="text/javascript" language="javascript">
    
    </script> 
    
     <html>
    <head id="head" runat="server">
        <title>The CRUD Example</title>
        <link href="/resources/css/main.css" rel="stylesheet" type="text/css" />    
    </head>
    <body>
         <ext:ResourceManager ID="ResourceManager1" runat="server"  />  
    </body>
    </html>
    Last edited by Baidaly; Jun 04, 2013 at 2:43 AM. Reason: [CLOSED]
  2. #2
    Please edit your original post and wrap all code samples in [CODE] tags.
    Geoffrey McGill
    Founder
  3. #3

    How to solve EXCEPTION - "You have to set widget's ID to call its methods"

    I need your help, please !!!
  4. #4
    Well, exception text makes it clear that you have to do.
    You have to set ID for the window to call its methods (if window is dynamic (like in your case) then you have to set ID for every request)

    Another option (and it is better) to close the window on the client side

    window1.Add(new Ext.Net.Button() { ID = "btnprueba", Text = "Test", OnClientClick = "this.up('window').close();" });
  5. #5
    Hello!

    You should set ID for the Window and either recreate this control during each request or use X.GetCmp<>()

    <%@ Page Language="C#" %> 
     
     <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>  
     
    <!DOCTYPE html /> 
     
     <script runat="server"> 
     
     Ext.Net.Window window1    = new Ext.Net.Window();  
     
    /*---------------------------------------------------------------------------------------------------------*/
     protected void Page_Load(object sender, EventArgs e)
    {
        if (!X.IsAjaxRequest)
        {
            window1.Border = true;
            window1.Width = 572;
            window1.Height = 430;
            window1.ID = "Window1";
    
            window1.Add(new Ext.Net.Button() { ID = "btnprueba", Text = "Test", OnClientClick = "App.direct.dmtest()" });
    
            this.Page.Controls.Add(window1);
        }
    }  
        /*---------------------------------------------------------------------------------------------------------*/
        [DirectMethod]
        public void dmtest()
        {
            X.GetCmp<Window>("Window1").Close();           
        } 
        /*---------------------------------------------------------------------------------------------------------*/
               
     </script>
      
     <script type="text/javascript" language="javascript">
     
    </script> 
     
     <html>
    <head id="head" runat="server">
        <title>The CRUD Example</title>
        <link href="/resources/css/main.css" rel="stylesheet" type="text/css" />    
    </head>
    <body>
         <ext:ResourceManager ID="ResourceManager1" runat="server"  />  
    </body>
    </html>
  6. #6

    You have to set widget's ID to call its methods

    Both have reazon. I used both option. Thank you very much. Yo can close the thread.

Similar Threads

  1. Replies: 3
    Last Post: May 14, 2013, 12:34 AM
  2. Ext Core Rating Widget
    By sbarnes in forum 1.x Help
    Replies: 0
    Last Post: Jul 23, 2009, 8:03 PM
  3. Adding Widget in Coolite Example Deluxe.
    By sunilaecs in forum 1.x Help
    Replies: 0
    Last Post: Apr 21, 2009, 6:08 AM

Posting Permissions