[Bug 2.3.1]: UpdateContent exception on loaded control

Page 2 of 3 FirstFirst 123 LastLast
  1. #11
    To update ASP.NET controls during a DirectEvent you have to call the Update method on that control (an extension method inside Ext.NET).
    protected void MsgTest( object sender, DirectEventArgs e ) 
    {
        HeadL.InnerHtml = "This text was changed";
        HeadL.Update();
        Button1.Text = "Proves button changed in directEvent";
        ASPButton.Text = "Changed aspbutton";
        ASPButton.Update();
    }
  2. #12
    Quote Originally Posted by Daniil View Post
    To update ASP.NET controls during a DirectEvent you have to call the Update method on that control (an extension method inside Ext.NET).
    protected void MsgTest( object sender, DirectEventArgs e ) 
    {
        HeadL.InnerHtml = "This text was changed";
        HeadL.Update();
        Button1.Text = "Proves button changed in directEvent";
        ASPButton.Text = "Changed aspbutton";
        ASPButton.Update();
    }
    This is the type of topic I was describing in http://forums.ext.net/showthread.php...202#post121202 that forces 2 code paths for basic ajax updates. I tried EventP.UpdateContent() at the end in MsgTest as well and that does the trick too. I think this will address the last of my topics preventing my ability to move forward without causing constant refreshes, especially if you guys are able to fix that other weakness with manually suspending the scripting. Thank you for walking me through. I realize there's an efficiency to only sending the client the items that are actually changed, but there are times where that efficiency needs be be measured against the universality of being able to update and manage universal layouts or sections of code, especially in a blackbox setting.
  3. #13
    I added the following to MsgTest:
    		Button1.Listeners.Render.Handler = "alert('Test');";
    This listener does not get updated.

    UpdateContent seems to be the only way to reliably address this but shouldn't the listener be able to be updated regardless? In my production case, I do not have all the variables to construct the handler until after the DirectEvent.
  4. #14

    UpdateContent problems...

    UpdateContent in my production case actually created new problems including an exception on the client-side. In my production case, I have an accordion panel and all the Panels need to refresh just to update the Buttons section.
    Element.override.getWidth (ext-all-dev.js:28029)
    Ext.define.measureOwnerWidth (ext-all-dev.js:54673)
    Ext.define.measureAutoDimensions (ext-all-dev.js:54546)
    Ext.define.calculate (ext-all-dev.js:73365)
    Ext.define.runLayout (ext-all-dev.js:169263)
    Ext.define.runCycle (ext-all-dev.js:169232)
    Ext.define.run (ext-all-dev.js:169163)
    Ext.define.statics.flushLayouts (ext-all-dev.js:42443)
    Ext.define.statics.resumeLayouts (ext-all-dev.js:42459)
    Ext.resumeLayouts (ext-all-dev.js:46374)
    (anonymous function) (VM7226:1)
    Ext.net.DirectEvent.Ext.data.Connection.executeScriptDelay (extnet-all-debug.js:1389)
    Ext.net.DirectEvent.Ext.data.Connection.executeScript (extnet-all-debug.js:1380)
    Ext.net.DirectEvent.Ext.data.Connection.requestSuccessHandler (extnet-all-debug.js:1321)
    Ext.apply.callback (ext-all-dev.js:12089)
    Ext.define.onComplete (ext-all-dev.js:48205)
    Ext.define.onStateChange (ext-all-dev.js:48151)
    (anonymous function) (ext-all-dev.js:3335)
    All because I'm trying to do one thing; update the listener's handler with UpdateContent on a panel that has a button in the Buttons section with a listener. I'd prefer to just isolate and update the button, but when I call Update on the button, I'm notified in a server exception "The Lazy control (DetailP) can not be updated."
    Last edited by michaeld; Nov 20, 2013 at 12:10 PM.
  5. #15
    I'm going to take the listener topic onto another thread. I'll try to create a sample tomorrow related to the UpdateContent issue as it seems unrelated.
  6. #16
    Quote Originally Posted by michaeld View Post
    I'm going to take the listener topic onto another thread.
    For references,
    http://forums.ext.net/showthread.php?27308

    To get this
    Button1.Listeners.Render.Handler = "alert('Test');";
    rendered to client, you can re-render the Button
    Button1.Render();
    Yes, updating Listeners and DirectEvents during a DirectEvent is much more complicated to do automatically. It is not just the Hidden property, then we can just call client side show/hide methods.
  7. #17
    Quote Originally Posted by Daniil View Post
    Yes, updating Listeners and DirectEvents during a DirectEvent is much more complicated to do automatically. It is not just the Hidden property, then we can just call client side show/hide methods.
    Can you elaborate on why?

    What this means is I cannot rely on Panel.UpdateContent() to universally and reliably update an entire section on a page in a DirectEvent without manual tweaking of multiple paths based on white-box knowledge of the code. I'm back to square one on the no-refresh page paradigm.
  8. #18
    Well, I didn't meant that. I meant that it is going to be quite complicated for us to reflect this:
    Button1.Listeners.Render.Handler = "alert('Test');";
    to client automatically without any Render or UpdateContent calls by developer.

    Well, an UpdateContent call of the Button1's container should re-render that Button wholly including the Listeners section. If it doesn't work in some case, it might be a bug.
  9. #19
    Quote Originally Posted by Daniil View Post
    Currently, we have some idea which might make the case working without manual suspending of scripting. Though, we have to test it a bit more. We will update the thread with a final decision.
    I want to revisit this above. Can you update me on status?


    Moreover, I want to talk more about what it looks like building a reusable user control. It's starting to get pretty cut-n-paste ugly. I'm considering starting to extend Ext.Net again to support some basic logic if it can't be provided.

    Let me start at the beginning...

    Level 1
    I have a basic panel in a user control. Page_Load populate its members. So far so good.

    Level 2
    Okay, but there are DirectEvents, so for efficiency I skip rendering on posts-back by adding a test at the beginning of Page_Load with X.IsAjaxRequest and return right away. Very basic and we address 2 modes: Page_Load and DirectEvent.

    Level 3
    At this level I feel like there's limited extnet support. In this scenario, I've got DirectEvents constructing the User Control and rendering needs to be turned back on. I need an exception.

    But at present, there's no way to ask Ext.net two questions: "Am I in a post-back?" but also "Do I need to render this control anyway?" It would be nice if I could ask, but as present I have to do something like this manually when I load the UserControl: Context.Items["DirectControlRender"]=true, so that when the user control enters Page_Load I can test (X.IsAjaxRequest && Context.Items["DirectControl"]==null).

    But that's not all. Because as we've described earlier, I have to wrap the UserControl loading around turning on and off X.ControlsScripting before calling Panel1.ContentControls.Add( uc ).

    The more controls I do this to, the more I'm confident there really are 3 modes. What's the status on all this? I'm hoping for some extension to all this before 2.4. Is that on the roadmap?
    Last edited by michaeld; Nov 27, 2013 at 9:33 AM.
  10. #20

    I thought I would share what I've done in the meantime...

    I added the following to MyExtensions.cs to Ext.Net:
    using System;
    using System.Web;
    
    
    namespace Ext.Net {
        public partial class X {
            public static bool DirectRendering {
                get {
                    return HttpContext.Current.Items["DirectRendering"] != null;
                }
                set {
                    if( value )
                        HttpContext.Current.Items["DirectRendering"] = true;
                    else
                        HttpContext.Current.Items.Remove( "DirectRendering" );
                }
            }
            public static bool IsAjaxRequestNotRendering {
                get {
                    return ( X.IsAjaxRequest && !X.DirectRendering );
                }
            }
        }
    }
    Then added the following extension method in my project:
            public delegate void BindFn( System.Web.UI.Control ctr );
    
            public static System.Web.UI.Control AddDirectControl( this ComponentBase ctnr, string ctlPath, string ctlName, BindFn bindFn = null ) {
                // Add the user control
                var uc = ctnr.Page.LoadControl( ctlPath );
                uc.ClientIDMode = System.Web.UI.ClientIDMode.Static;
                uc.ID = ctlName;
    
                // Clear the Contents of the container
                ctnr.ContentControls.Clear();
    
                // Give a chance to bind before adding the control
                if( bindFn != null )
                    bindFn( uc );
    
                // Add the control
                X.ControlsScripting = false;
                X.DirectRendering = true;
                ctnr.ContentControls.Add( uc );
                X.ControlsScripting = true;
                X.DirectRendering = false;
    
                // Update the Container
                ctnr.ReRender();
                return uc;
            }

    In the DirectEvent creating the control, I can now do this:
            DateP.AddDirectControl( "/ctl/EventDataFull.ascx", "uc",
                (uc) => {
                    UIDataLayer.BindDataToControl<CCalendarItem>( Context, uc, calendaritem );
                }
            );
    In the Page_Load of the user control EventDateFull.ascx I can now:
    protected void Page_Load( object sender, EventArgs e ) {
    
            if( X.IsAjaxRequestNotRendering )
                    return;
                     //...
    This helps... But I'm still waiting for a more robust solution in ext.net.
    Last edited by michaeld; Dec 01, 2013 at 11:50 AM.
Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. Replies: 1
    Last Post: Apr 02, 2013, 5:03 AM
  2. Replies: 1
    Last Post: Oct 10, 2012, 11:47 AM
  3. [CLOSED] [1.0] User Control loaded several times
    By FVNoel in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jul 07, 2011, 10:33 AM
  4. Replies: 2
    Last Post: Oct 29, 2010, 8:51 AM
  5. Replies: 2
    Last Post: Feb 10, 2010, 10:45 AM

Posting Permissions