Common RadWindow issues and their solution

Posted by: the telerik blogs, on 04 Jun 2009 | View original | Bookmarked: 0 time(s)

The RadWindow control is part of the Teleriks RadControls for ASP.NET AJAX suite and is intended to replace the standard browsers popup (window.open()). Since the control is based on an IFRAME, it behaves just like one basically, whatever can be done with an IFRAME, can be achieved with RadWindow as well. This fact is useful when you investigate a reason for some problem related to the RadWindow control. Just replace the RadWindow with a standard IFRAME or browsers popup and see how your application will behave in this case. If the problem still exists, then it is not related to the RadWindow control but is most probably a default browsers behavior or a problem in the used logic itself.

Below you can see several common cases that occur when RadWindow is used and what is the best approach in such scenarios.

  1. Video / audio keep playing after window is closed

    This happens because by default, when a RadWindow is closed, its object is not destroyed but remains hidden on the page so it can be quickly called again when needed. There are 2 ways to avoid that issue:
    1. Set DestroyOnClose=true. See p.5 for more details on the subject.
    2. Use the OnClientClose event handler that is called every time when a RadWindow is closed. There you could use setUrl() client-side method to change the content pages Url which will stop the media as well.
      e.g.
      <script type="text/javascript">
          function ShowWindow()
          {
              var oWnd = window.radopen('Dialog1.aspx', 'window1'); //Opens the window 
              oWnd.add_close(OnClientClose); //set a function to be called when RadWindow is closed 
          }
          function OnClientClose(oWnd)
          {
              oWnd.setUrl("about:blank"); // Sets url to blank
              oWnd.remove_close(OnClientClose); //remove the close handler - it will be set again on the next opening
          }     
      </script>

      <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
      </telerik:RadWindowManager>
      <button onclick="ShowWindow(); return false;">
          open RadWindow</button>
  2. RadMenu overlaps RadWindow

    This behavior is expected by design RadMenu has a higher z-Index value than the RadWindow control. This is needed in common cases where a RestrictionZone is used and the RadMenu control is above that zone. To render the RadWindow control above RadMenu, all you need to do is to change its z-Index, according to this help article. There is a KB article on the same subject as well.
  3. Using OffsetElementID and Top / Left properties together
    When OffsetElementID is specified, Top and Left are calculated towards that element's top left corner. If OffsetElementID is not specified, Top and Left are calculated towards the page's top left corner.  Top and Left can be used along with the RestrictionZoneID property as well - if the RestrictionZoneID property is set,  Top and Left will be calculated towards the top left corner of the restriction zone.
  4. OpenerElementID is not working as expected in some scenarios
    By using the OpenerElementID property it is possible to specify the id of an HTML element that, when clicked, will automatically open the corresponding RadWindow object. The opener can be any element on the page that has an ID attribute - the property expect a client ID, so if you are setting it to a server element, you need to use its ClientID (OpenerElementID="<%# ServerButton.ClientID %>" ).

    Note that if you set this property to a postback element like asp:Button control, the server-side click event of that element will not fire. That is why we recommend using OpenerElementID in simple scenarios only. OpenerElementID is not suitable for ajaxified and databinding scenarios as well. For example if you have a standard asp:Repeater control or RadGrid where you need to open RadWindows by clicking some elements in the columns, you will have to declare number of RadWindows equal to the number of the opener elements in the grid. In such scenarios it is recommended to use RadWindow's client-side or server-side API.
  5. Once a RadWindow is closed, it loses all its settings (width, height, modality, etc.)
    This could happen if you have set DestroyOnClose to true. When this property is set to true, RadWindows object will be destroyed once the window is closed. This, however,  means that you will not be able to open that same RadWindow again until the whole page is reloaded. In such scenario, it will be best to either set all needed properties (width, height, modality, etc.) to the RadWindowManager or as an alternative to use the client-side API and set them when opening the RadWindow.

More information about the RadWindow control is available in the controls documentation check the Programming section for more tips and tricks.

 

Georgi Tunev

Telerik

Advertisement
Free Agile Project Management Tool from Telerik
TeamPulse Community Edition helps your team effectively capture requirements, manage project plans, assign and track work, and most importantly, be continually connected with each other.
Category: WSE | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 10864 | Hits: 17

Similar Posts

  • Quick Reference Guide for Telerik Support more
  • Consolidation of CRM solutions more
  • Partial Trust and Telerik OpenAccess ORM more
  • UppercuT - Automated Builds - VersionBuilder more
  • Thinking about the EntityDataSource more
  • Code Generators: Can't live with them, can't live without them more
  • MOSS Supports Live Earth - How we built Conservation International's Public Websites more
  • Learn how to build document workflow in MOSS 2007 (Live Web cast on July 24th) more
  • Learn how to build document workflow in MOSS 2007 (Live Web cast on June 19th) more
  • SpreadsheetGear Releases New Version of Microsoft Excel Compatible Spreadsheet Component for ASP.NET and Windows Forms more

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD