Is a Partial Postback with RadWindow Possible?

16 posts, 2 answers
  1. Robert
    Robert avatar
    253 posts
    Member since:
    Aug 2007

    Posted 18 Jan 2012 Link to this post

    My post is related to this one: http://www.telerik.com/community/forums/aspnet-ajax/window/migrating-from-modalpopupextender-to-radwindow.aspx

    I'm trying to replace all instances of the Modal Popup Extender with RadWindow.  I've enclosed a screenshot example of one of them.  Simply put, I want to display a modal popup window and get the user to fill in a bunch of info.

    Important Note: Several of the control changes will cause a postback BUT I only want a partial postback!  What's happening now is that every time I change the value of a control that has Autopostback="true" I get a full postback.  This is unacceptable.

    Is what I'm looking to do even possible with the RadWindow?  If so, how?

    Sincerely,

    Robert W.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 18 Jan 2012 Link to this post

    Hello,

    You can make the RadWindow as modal by setting the Modal property as true. This illustrate how to use RadWindow as control contaoner.

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3602 posts

    Posted 20 Jan 2012 Link to this post

    Hello guys,

    I'd like to add a link on the subject of using RadWindow with AJAX: http://www.telerik.com/help/aspnet-ajax/radwindow-ajaxifying.html. It explains how and why ajaxifying a RadWindow that is used with its ContentTemplate is not as straighforward as a simple container like an asp Panel - because of the content that is moved in the DOM tree. Because of this the update panel must also be confined in the ContentTemplate.


    Kind regards,
    Marin
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  5. Robert
    Robert avatar
    253 posts
    Member since:
    Aug 2007

    Posted 22 Jan 2012 Link to this post

    Princy: Your simplistic solution does not solve the problem.

    Marin: Thank you for your thoughtful response.  I followed the instructions you provided a link to.  Specifically, I added an UpdatePanel inside the RadWindow ContentTemplate.  This got things working a little better but when a partial postback occurs (such as from an Autopostback of a Textbox control) the modal dialog box flashes off and then back on for a moment.  Aesthetically this is not really acceptable.

    I need a definitive answer from Telerik as I have to make a critical decision about staying with the Modal Popup Extender or replacing it with RadWindow:

    Is there a way to use RadWindow in an AJAXified environment such that an off/on flash does not occur during a partial postback?  If the answer to this question is 'No', might Telerik be planning on fixing this problem in the next 6 months or providing an entirely new control that would work as effectively as the Modal Popup Extender?

    Sincerely,

    Robert W.
  6. Answer
    Marin Bratanov
    Admin
    Marin Bratanov avatar
    3602 posts

    Posted 23 Jan 2012 Link to this post

    Hi Robert,

    The definitive answer is YES, the RadWindow can be used in an ajaxified environment. The crucial part is to configure AJAX so that it is not disposed (i.e. it is out of any upate panels).

    For your convenience I am attaching a simple page that shows the approach in action - a button on the page that opens the RadWindow (this is done entirely on the client, if you need it from the server I suggest you examine this thread), a button on the page that will perform an AJAX request that will not affect the RadWindow and content inside the RadWindow that works with AJAX independently (without having the RadWindow flash).

    I also recorded a video with the expected behavior: http://screencast.com/t/PMVgpLSVw. Please check if this works properly with you as well. If it does not please try removing the ACT's dll from the Bin folder, as we have had reports on wrong MS AJAX scripts coming from it instead from the original MS assemblies. If you are still having difficulties with this please isolate this case in a simple, runnable project and send it back to us via a support ticket so we can debug it and see what is going on.


    Kind regards,
    Marin
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  7. Robert
    Robert avatar
    253 posts
    Member since:
    Aug 2007

    Posted 23 Jan 2012 Link to this post

    Marin,

    Just wanted to give you a quick (interim) thank you for the sample project and the screencast.  It all appears to work perfectly.  I even added a TextBox with Autopostback=true to the RadWindow.  It worked perfectly too.

    Now I need to investigate my project's code to see why it's not working correctly.

    I'll get back to you shortly,

    Robert
  8. Robert
    Robert avatar
    253 posts
    Member since:
    Aug 2007

    Posted 23 Jan 2012 Link to this post

    Marin,

    I've started implementing your approach and things seem to be working fine so far.  For starters, the flashing off/on is gone now that I'm no longer using the "VisibleOnPageLoad" property to turn the RadWindow on & off.

    In my situation, pre & post server-side processing has to be done before showing & closing the RadWindow.  So, following your lead, i constructed this pair of simple client-side function calls from my C# code:

           // Display the RadWindow<br>        string script = "$find(\"" + RadWindow1.ClientID + "\").show();";<br>        Page page = HttpContext.Current.CurrentHandler as Page;<br>        ScriptManager.RegisterStartupScript(page, page.GetType(), Guid.NewGuid().ToString(), script, true);<br><br>        // Close the RadWindow<br>        string script = "$find(\"" + RadWindow1.ClientID + "\").close();";<br>        Page page = HttpContext.Current.CurrentHandler as Page;<br>        ScriptManager.RegisterStartupScript(page, page.GetType(), Guid.NewGuid().ToString(), script, true);

    Note: At first I tried ".hide()" to get rid of the RadWindow but I'm using it in modal mode and immediately noticed that the greyed out main page was staying that way after the RadWindow disappeared.  Then i discovered that ".close()" was the correct approach.

    I've mainly posted the code here so you could tell me if you see anything wrong with what I've done.

    Robert
  9. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3602 posts

    Posted 24 Jan 2012 Link to this post

    Hello Robert,

    I am glad to hear things are working out with you :) I cannot see anything wrong with the code (I assume it is in a class located in the App_Code folder because of the casting of the context to page). You only need to make sure that the correct ClientID is passed (or RadWindow object, depending on the exact way you have configured it), yet I believe it should work well. As for hide and close - yes, these are two different methods with the behavior you have experienced. I believe you have found it yourself, yet I will link it just in case - the RadWindow's client-side API.


    Greetings,
    Marin
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  10. Robert
    Robert avatar
    253 posts
    Member since:
    Aug 2007

    Posted 24 Jan 2012 Link to this post

    Marin,

    Your comment about me casting the Context to a Page got me thinking.  Why do I do it that way?  I thought about it and remembered that way back when I saw some sample code doing it that way so I assumed it was the way to do it.  But your comment prompted me to test something new.  Here's the C# method I've placed in a file called Common.cs, which is accessible by all other pages in my project:

        public static void ShowDialog(RadWindow radWindow)<br>    {<br>      string script = "$find(\"" + radWindow.ClientID + "\").show();";<br>      Control ctrl = HttpContext.Current.CurrentHandler as Control;<br>      ScriptManager.RegisterStartupScript(ctrl, ctrl.GetType(), Guid.NewGuid().ToString(), script, true);<br>    }

    Now, if there's a different/better way than casting the Context to a Control, I'd love to hear about it!

    Robert

  11. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3602 posts

    Posted 25 Jan 2012 Link to this post

    Hello Robert,

    So far I have found the RegisterStartupScript() method the most reliable way to inject a script from the code-behind and I have also found that it works best when you pass a Page object for its first two arguments as finally the script must be injected onto a page. I have not experienced issues with it when I pass (Page, Page.GetType(),.....) so far and my best suggestion for the time being is to stick with Page. You may test with casting to Control and if it works for you - then you can use it. This is after all, a general ASP concept and quite often depends on project structure for example (i.e. calling this method from a user control may not always work, but this is just a speculation and may not be correct).


    Kind regards,
    Marin
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  12. Robert
    Robert avatar
    253 posts
    Member since:
    Aug 2007

    Posted 30 Jan 2012 Link to this post

    Marin,

    Forgive me but I've come across another hurdle that I've spent many hours trying to get past but can't.  I'm thinking you might quickly know the solution.

    As I reported before, I have successfully implemented the RadWindow as a modal dialog box.  To be more precise, I successfully implemented it in ASP.Net Content Form which had the RadWindow at the top level like this:

    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"><br>    /* Assorted layout code */<br>    <telerik:RadWindow ID="rwEditRatesAllowed" runat="server" Modal="true"><br>        /* . . .  */<br>    </telerik:RadWindow><br></asp:Content>

    I was able to successfully show the RadWindow with a call to this method:

        public static void ShowDialog(RadWindow radWindow)<br>    {<br>        string script = "$find(\"" + radWindow.ClientID + "\").show();";<br>        Page page = HttpContext.Current.CurrentHandler as Page;<br>        ScriptManager.RegisterStartupScript(page, page.GetType(), Guid.NewGuid().ToString(), script, true);<br>    }

    But now I want to show a RadWindow which resides within a User Control that itself is loaded into another User Control that is loaded into a Content Form.  In other words, the hierarchical structure is as follows:

         - Master Page
         -    Content Form
         -        User Control Parent
         -            User Control Child
         -                RadWindow

    The problem is that 'ShowDialog' above fails to find the RadWindow.  I have tried everything I can think of to find it using a combination of Javascript and jQuery but with no success :-(

    Might you have any ideas how I can solve this?

    Robert

  13. Robert
    Robert avatar
    253 posts
    Member since:
    Aug 2007

    Posted 30 Jan 2012 Link to this post

    Achieving no success, I tried wrapping the RadWindow with a RadWindowManager (see screenshot).  Unfortunately I got this error when i tried to run the project:

    Cannot unregister UpdatePanel with ID 'UpdatePanel2' since it was not registered with the ScriptManager. This might occur if the UpdatePanel was removed from the control tree and later added again, which is not supported.
    Parameter name: updatePanel
  14. Answer
    Marin Bratanov
    Admin
    Marin Bratanov avatar
    3602 posts

    Posted 31 Jan 2012 Link to this post

    Hi Robert,

    I've just answered your support ticket on this matter, so please refer to it for the question on opening the RadWindow.

    As for the issue when the manager is introduced - please examine the following KB article which explains it in greater detail: http://www.telerik.com/support/kb/aspnet-ajax/window/cannot-unregister-updatepanel-with-id-updatepanelid-since-it-was-not-registered-with-the-scriptmanager.aspx.


    Greetings,
    Marin
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  15. Robert
    Robert avatar
    253 posts
    Member since:
    Aug 2007

    Posted 31 Jan 2012 Link to this post

    Thank you, Marin.  For those encountering this problem in the future, this article, referred to me by Marin, provided the answer to my major dilemma: http://www.telerik.com/help/aspnet-ajax/radwindow-troubleshooting-javascript-from-server-side.html

    The key point is this: AJAX controls are loaded after window.onload is fired!
  16. wilson
    wilson avatar
    31 posts
    Member since:
    Jul 2006

    Posted 10 Jan 2013 Link to this post

    Hi Martin,
      I just found this post and it might solve my problem.
      If I use your example project, how do I change the code so when I click on Button1, it will also update the text in Label2?

    Thanks.
  17. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3602 posts

    Posted 11 Jan 2013 Link to this post

    Hello,

    This is the way MS AJAX works. Update Panels with UpdateMode set to Conditional are not automatically updated when another control posts back. You need to call its server-side Update() method to update it in the code-behind click handler of the button.


    Greetings,
    Marin Bratanov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017