[OPEN] [#409] Exception in Transformer with UserControlLoader with RenderMode.AddTo

Page 1 of 2 12 LastLast
  1. #1

    [OPEN] [#409] Exception in Transformer with UserControlLoader with RenderMode.AddTo

    Is there any reason this shouldn't work?

    <%@ Page Language="C#" EnableViewState="false" %>
    
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e) {
        }
        protected void CreateTest( object sender, DirectEventArgs e ) {
            var ucl = new UserControlLoader() { Path = "Test39.ascx", UserControlClientIDMode = System.Web.UI.ClientIDMode.Predictable, UserControlID = "uc1" };
            RP.Items.Add( ucl );
            ucl.Render( "RP", RenderMode.AddTo );
        }
    </script>
    
    
    <!DOCTYPE html>
    <html>
    <head id="Head1" runat="server">
        <title>Ext.NET Example</title>
    </head>
    <body>
        <form id="Form1" runat="server">
    
    
            <ext:ResourceManager ID="ResourceManager1" runat="server" ScriptMode="Development" SourceFormatting="true" />
            <ext:Viewport ID="vp" runat="server" Layout="HBoxLayout">
                <Items>
    
    
                    <ext:Container ID="LP" runat="server" Border="true" Padding="5" Flex="1" Layout="FitLayout">
                        <Items>
                            <ext:Button runat="server" Text="Test Right Panel Load">
                            <DirectEvents>
                                <Click OnEvent="CreateTest" />
                            </DirectEvents>
                            </ext:Button>                                
                            <ext:Hidden ID="ucLoaded" runat="server" Text="0" />
                        </Items>
                    </ext:Container>
    
    
                    <ext:Container ID="RP" runat="server" Flex="1" Layout="VBoxLayout">
                        <Items>
                            <ext:TextField ID="test" runat="server" />
                        </Items>
                    </ext:Container>
    
    
                </Items>
            </ext:Viewport>
        </form>
    </body>
    </html>
    <%@ Control Language="C#" ClassName="Test39" %>
    
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e) {
        }
        protected void MsgTest( object sender, DirectEventArgs e ) {
            HeadL.InnerHtml = "This text was changed";
            Button1.Text = "Proves button changed in directEvent";
            ASPButton.Text = "Changed aspbutton";
            Button1.Listeners.Render.Handler = "alert('Test');";
            Button1.Render();
        }
    </script>
    
    
    <ext:Panel ID="EventP" runat="server" Flex="1" Padding="5" Title="TestRightPanel">
        <Content>
            <div class="TitlePnl">
                <h1 id="TitleL" runat="server" class="Title">Test Title</h1>
                <div class="HeadPnl">
                    <span id="HeadL" runat="server" class="Head">Test Span</span>
                </div>
                <asp:Button ID="ASPButton" runat="server" Text="AspButton" />
            </div>
    
    
        </Content>
        <Items>
            <ext:Button ID="Button1" runat="server" Text="Test DirectEvent in Loaded Control">
                <DirectEvents>
                    <Click OnEvent="MsgTest" />
                </DirectEvents>
                <Listeners>
                    <AfterRender Handler="" />
                </Listeners>
            </ext:Button>
        </Items>
    </ext:Panel>
    Last edited by Daniil; Dec 23, 2013 at 11:44 AM. Reason: [OPEN] [#409]
  2. #2
    Hello!

    Try the following:

    protected void CreateTest( object sender, DirectEventArgs e ) {
        var ucl = new UserControlLoader() { Path = "Test39.ascx", UserControlClientIDMode = System.Web.UI.ClientIDMode.Predictable, UserControlID = "uc1" };
        RP.Items.Add( ucl );
        RP.ReRender();
    }
    Does it help?
  3. #3
    Quote Originally Posted by Baidaly View Post
    Try the following:

    Does it help?
    Sorry, Baidaly, we've been down this road already. The Render with AddTo may not seem critical to this example, but it is critical to the scenarios I'm testing. The reason I have a textbox in RP is to prove this point. If you ReRender RP, you will blow away the value the client has for the textbox. Everything I'm posting since a few weeks ago is about protecting the client controls that are already rendered from being destroyed, and focusing the reload to the target section.

    In my original test at top, it's a slight variation from what Vladimir has offered. The ucl.Render attempts to render ONLY the ucl, then after, add it to the RP parent control list without rendering RP again or destroying its existing controls.

    So the reason for providing this test case was to show that UserControlLoader does not work with AddTo. I think it's a bug and some work needs to go into it. I'll accept another alternate in the meantime until the above is fixed, if you can come up with one that allows layout and meets the requirements stated above including participating in layout, which UserControlLoader is able, ideally without having to create a Fit Layout Container.
    Last edited by michaeld; Dec 22, 2013 at 1:31 AM.
  4. #4

    Final Issues

    The subject related to this thread may be the last item I'm struggling with related to reliable reload of Registered controls. I posted a sample application here:
    http://forums.ext.net/showthread.php...026#post123026

    I'd very much appreciate your guys' help to get layouts working properly in all cases.
  5. #5
    Hi everybody,

    I think if you add the UserControlLoader to the RP's Items.
    RP.Items.Add(ucl);
    you are free not to set up a container to render and the AddTo mode:
    ucl.Render( "RP", RenderMode.AddTo );
    I mean the Render call might look this way:
    ucl.Render();
    Though, it produces the same Exception. I also have a feel it should just work. We will investigate. Thank you for the report.

    Also please note that a Container's Items and Content should not be used at the same time.

    Quote Originally Posted by michaeld View Post
    The subject related to this thread may be the last item I'm struggling with related to reliable reload of Registered controls. I posted a sample application here:
    http://forums.ext.net/showthread.php...026#post123026

    I'd very much appreciate your guys' help to get layouts working properly in all cases.
    I will respond in that thread.
    Last edited by Daniil; Dec 23, 2013 at 4:47 AM.
  6. #6
    I discussed it with Vladimir. The UserControlLoader doesn't support the Render method. We should support it or throw an Exception. Created an Issue:
    https://github.com/extnet/Ext.NET/issues/409

    Not high priority for now.

    So, currently, this is a solution to get it working:
    Quote Originally Posted by michaeld View Post
    ideally without having to create a Fit Layout Container.
    I mean putting a UserControlLoader into a Container, then render that Container.

    Also it should be achievable with a UserControlRenderer.Render().
  7. #7
    Quote Originally Posted by Daniil View Post
    I discussed it with Vladimir. The UserControlLoader doesn't support the Render method. We should support it or throw an Exception. Created an Issue:
    https://github.com/extnet/Ext.NET/issues/409

    Not high priority for now.

    So, currently, this is a solution to get it working:


    I mean putting a UserControlLoader into a Container, then render that Container.

    Also it should be achievable with a UserControlRenderer.Render().
    Please do not remove support for UserControlLoader.Render(). I am counting on that support in the new api I posted for rendering UserControls that contain Windows or other bin type objects, and it works great and would not be appropriate to render a wrapping container in that case. See here for how I'm using it.
    http://forums.ext.net/showthread.php...873#post122873 See AddDirectEvent(Page,...)

    However, if you want to throw a "not supported" exception, do so in the parameterized versions. But please keep the Render() without parameters.
    Last edited by michaeld; Dec 24, 2013 at 12:48 AM.
  8. #8
    Quote Originally Posted by Daniil View Post
    Also it should be achievable with a UserControlRenderer.Render().
    Also, I was instructed by Vladimir to stop using UserControlRender if I expect controls to be part of the page life-cycle. So that's why I switched everything to using wrapping it in a container, but this causes the new problem being presently discussed here:http://forums.ext.net/showthread.php...ent()&p=123038
  9. #9
    Quote Originally Posted by michaeld View Post
    Please do not remove support for UserControlLoader.Render(). I am counting on that support in the new api I posted for rendering UserControls that contain Windows or other bin type objects, and it works great and would not be appropriate to render a wrapping container in that case. See here for how I'm using it.
    http://forums.ext.net/showthread.php...873#post122873 See AddDirectEvent(Page,...)

    However, if you want to throw a "not supported" exception, do so in the parameterized versions. But please keep the Render() without parameters.
    Agree, it would be nice to have it supported. I removed the "Exception part" the Issues's description. Now it is just a feature request.

    Though, we are not sure how the non-parameterized Render method works for you. Generally speaking, it should not. Anyway, we recommend not to rely on that.

    A solution could be using a UserControlLoader's Components collection. In this case, you can work individually with Ext.NET components from a user control.

    Still another solution is wrapping a UserControlLoader in a Container. Could you, please, clarify why do you not want that?

    EDIT:

    I think you clarified it here:
    http://forums.ext.net/showthread.php...l=1#post123074

    Yes, dealing with layouts might be kind of problematic with that intermediary Container. Though, you could adjust its Layout as needed as well.

    Another solution could be creating custom controls instead of using user controls. Well, yes, it would be a big turn. Though, have you ever thought about it as an alternative of what you are doing currently?

    Quote Originally Posted by michaeld View Post
    Also, I was instructed by Vladimir to stop using UserControlRender if I expect controls to be part of the page life-cycle. So that's why I switched everything to using wrapping it in a container, but this causes the new problem being presently discussed here:http://forums.ext.net/showthread.php...ent()&p=123038
    Yep, I remember that, but decided to mention anyway.
    Last edited by Daniil; Dec 24, 2013 at 8:17 AM.
  10. #10
    Quote Originally Posted by Daniil View Post
    Agree, it would be nice to have it supported. I removed the "Exception part" the Issues's description. Now it is just a feature request.
    Unfortunately for me, it isn't as much a feature request as a possible show-stopper.
    I may have to return back to using UserControlRender since it's the only UserControl rendering pattern that supports AddTo. The only problem it has is that SelfRenderingPage does not support FindControls with the original Page. I try very hard not to avoid adding code into the Ext.Net binary like I showed on page one here: http://forums.ext.net/showthread.php...kEvent()/page2.
    Maybe the simple answer is just to make an note internally that all Page.FindControl calls must instead be replaced using an extension method of our own creation that uses the original Page.

    Quote Originally Posted by Daniil View Post
    Yes, dealing with layouts might be kind of problematic with that intermediary Container. Though, you could adjust its Layout as needed as well.
    It's a little more than just problematic. It adds a whole layer of unnecessary challenge and complexity just because of a hole in the Render api set. I think the option above is superior if you can't think of any other option. I've reached the end.


    Quote Originally Posted by Daniil View Post
    Another solution could be creating custom controls instead of using user controls. Well, yes, it would be a big turn. Though, have you ever thought about it as an alternative of what you are doing currently?
    No. It's not really an option. The reason I'm building this at all is because we may be turning the coding over to another and the learning curve must be minimal.
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 2
    Last Post: Dec 19, 2013, 10:54 AM
  2. [CLOSED] [#198] [2.2] UserControlLoader in Bin Exception
    By michaeld in forum 2.x Legacy Premium Help
    Replies: 6
    Last Post: May 02, 2013, 5:55 AM
  3. Replies: 4
    Last Post: Oct 20, 2010, 7:43 AM
  4. Replies: 6
    Last Post: Oct 19, 2010, 12:33 PM
  5. [CLOSED] [1.0] rendermode.addto layout issue
    By ljankowski in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 31, 2010, 5:17 PM

Posting Permissions