[CLOSED] XRender UserControl DirectMethod

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] XRender UserControl DirectMethod

    Hi Guys,

    This post can be taken as in continuation to my previous post

    http://forums.ext.net/showthread.php...5710-16-1.aspx

    I have a user control which has a DirectMethod.

    When I load that control dynamically, the direct method is not registered on the client side. Only the script for components is received.

    Again it could be only with latest code base... But u may be able to confirm. try the following code...

    test.aspx

    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!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></title>
        
        <script runat="server">
          [DirectMethod]
            public void loadControl() {
                Control cw = this.LoadControl("test.ascx");
                cw.ID = "cw";
                panel1.ContentControls.Add(cw);
                panel1.UpdateContent();
                
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        
        <ext:ResourceManager ID="scp1" runat="server" DirectMethodNamespace="DM"></ext:ResourceManager>
        
        <ext:Panel runat="server" ID="panel1"></ext:Panel>
        
    
        </form>
    </body>
    </html>
    test.ascx

    <%@ Control Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
    
        [DirectMethod]
        public string test()
        {
            return "Test";
        }
    
        </script>
    
    <ext:Button runat="server" ID="button1" Text="btn"></ext:Button>

  2. #2

    RE: [CLOSED] XRender UserControl DirectMethod

    Hi,

    Fixed. Please update from SVN and retest. Please let me know about result
  3. #3

    RE: [CLOSED] XRender UserControl DirectMethod

    I will check that, for now there are Further Problems...

    1) If there are additional script which are to be loaded, and on success of direct method, if you call any component, it gives an error. Probably because its not yet registered in the DOM. This happens only in case if there are additional scripts. In my case there is tabclosemenu-js.

    Try in firebug : DM.loadControl({success:function(){cw_win.show()}} );

    Try with the Tabclosemenu plugin and without the plugin. Without plugin it works as expected.

    2) Icons. No icons are downloaded on the client side. There is an icon on Button as well as window. None show.

    test.aspx

    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!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></title>
        
        <script runat="server">
          [DirectMethod]
            public void loadControl() {
                Control cw = this.LoadControl("test.ascx");
                cw.ID = "cw";
                panel1.ContentControls.Add(cw);
                panel1.UpdateContent();
                
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        
        <ext:ResourceManager ID="scp1" runat="server" DirectMethodNamespace="DM" ></ext:ResourceManager>
        
        <ext:Panel runat="server" ID="panel1"></ext:Panel>
        
    
        </form>
    </body>
    </html>
    text.ascx
    <%@ Control Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
          
        }
        
        [DirectMethod]
        public string test()
        {
            return "Test";
        }
    
        </script>
    
    <ext:Button runat="server" ID="button1" Text="btn" Icon="Accept"></ext:Button>
    
    <ext:Window runat="server" Hidden="true" Icon="Application" Height="300" Width="200" Layout="fit" ID="win">
    <Items>
    <ext:TabPanel runat="server" ID="tabpn" >
    <Items>
    <ext:Panel runat="server" ID="pnl1" Title="P0">
    
    </ext:Panel>
    <ext:Panel runat="server" ID="Panel1"  Title="P1">
    
    </ext:Panel>
    <ext:Panel runat="server" ID="Panel2"  Title="P2">
    
    </ext:Panel>
    
    </Items>
    <Plugins>
    <ext:TabCloseMenu runat="server"></ext:TabCloseMenu>
    </Plugins>
    </ext:TabPanel>
    </Items>
    </ext:Window>
  4. #4

    RE: [CLOSED] XRender UserControl DirectMethod

    Hi,

    In the example that I provided... Please try the following in firebug:

    1) DM.loadControl() and then

    2) DM.cw.test();

    You will get a server error "The control with ID 'cw' not found"

    Please confirm if you get the same...

  5. #5

    RE: [CLOSED] XRender UserControl DirectMethod

    Hi,

    1) When you use controls which required additional resiurces (js and css files) then return scripts executed after resources loading only.

    In your case TabCloseMenu required additional js file. Therefore response wrapping control creating by special function which loads resources and after that executes script (create control) only

    Therefore control is inaccessable in the success handler of the DirectMethod. Register script on server side instead success property

    2) Icon css doesn't register during DirectEvent. Therefore you have to register all icons during initial page load
    ResourceManager1.RegisterIcon(Icon.Add);
    We are planning to fix icon issue in the final release

    3) About DirectMethod. You have to recreate user control on each request otherwise ResourceManager could not find DirectMethod because user control with direct method is not loaded
  6. #6

    RE: [CLOSED] XRender UserControl DirectMethod

    vladimir (1/22/2010)Hi,

    1) When you use controls which required additional resiurces (js and css files) then return scripts executed after resources loading only.

    In your case TabCloseMenu required additional js file. Therefore response wrapping control creating by special function which loads resources and after that executes script (create control) only

    Therefore control is inaccessable in the success handler of the DirectMethod. Register script on server side instead success property


    3) About DirectMethod. You have to recreate user control on each request otherwise ResourceManager could not find DirectMethod because user control with direct method is not loaded
    For 1) So I will have to register the script of the additional plugins in code behind...


    For 2) I did not get it... I will load the user control by direct method... and I would want to use the DirectMethod in the control that i have loaded for which you say I will have to recreate (reload?) which will again loop back to same problem...


    I think ideally it shud just register the DirectMethod to the ResourceManager on 1st load... otherwise there is no point in using this method... There would be many instances where you would want to load the usercontrol and it may or may not have DirectMethod. If it does, then reloading it again n again is not a good idea...



  7. #7

    RE: [CLOSED] XRender UserControl DirectMethod

    Hi,

    1) You can try to register TabCloseMenu resources at the initial PageLoad if you don't want to loading it after DirectMethod execution


    Ext.Net.ResourceManager.RegisterControlResources<Ext.Net.TabCloseMenu>();

    3) Recreate doesn't mean rerender. Just recreates on server side without rendering. If user control is hosting direct method then we cannot to move it to another place. You have to load instance of the user control in to the Controls collection otherwise ResourceManager couldnot call method because it is unexisting


    reloading it again n again is not a good idea...
    You don't bother that ASP.NET recreates all controls which defined in the markup, recreates on each request


    There is no other way, we cannot use something that was not loaded
  8. #8

    RE: [CLOSED] XRender UserControl DirectMethod

    So,

    Control cw = this.LoadControl("test.ascx");
    cw.ID="cw";


    is something I need to do everytime I call a DirectMethod... Correct me if m wrong...


    We dont need to do that in Asp.net Update Panel... I know DirectMethod works differently, but still if there is something that I can do as a permanent solution to this?


    Thanks,








  9. #9

    RE: [CLOSED] XRender UserControl DirectMethod

    Hi,

    LoadControl is not enough. You have to add to the Controls collection


    We dont need to do that in Asp.net Update Panel...
    Example?
  10. #10

    RE: [CLOSED] XRender UserControl DirectMethod

    I meant not with Ext.net... Just under normal Asp.net site...

    Anyway... You can mark this is closed... I shud be able to handle it... If not will post it here...


Page 1 of 2 12 LastLast

Similar Threads

  1. XRender call DirectMethods from UserControl
    By vucuongkg in forum 2.x Help
    Replies: 1
    Last Post: Mar 19, 2012, 10:58 AM
  2. [CLOSED] DirectMethod/XRender Issue
    By logicspeak in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Oct 26, 2011, 5:43 AM
  3. DirectMethod Not Found. (using XRender)
    By aespinoza in forum 1.x Help
    Replies: 0
    Last Post: Jun 26, 2010, 9:25 PM
  4. [CLOSED] [1.0] DirectMethod - Page . UserControl . UserControl
    By Patrick in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Feb 25, 2010, 9:33 AM
  5. [CLOSED] XRender UserControl NamingContainer
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 27
    Last Post: Jan 21, 2010, 4:10 PM

Posting Permissions