Q1 2009 Visible=False causes client side runtime error

6 posts, 1 answers
  1. PJ Melies
    PJ Melies avatar
    30 posts
    Member since:
    Sep 2008

    Posted 07 Apr 2009 Link to this post

    We have a page that contains a RadDockLayout with multiple RadDocks.  Some of these RadDocks don't apply to certain users under certain conditions so we have code that may set Visible=false on some of the docks.  This code was fine in the Q3 2008 version of the controls but since we've upgraded to the Q1 2009 version (2009.1.402.35) this code now produces a Javascript "'undefined' is null or not an object" runtime error when the page loads in the browser.

    Below is a basic example of our layout and it exhibits the problem I just mentioned.

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TestHiddenDock._Default" %> 
     
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
     
    <!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>Untitled Page</title> 
    </head> 
    <body> 
        <form id="form1" runat="server">  
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />              
            <telerik:RadDockLayout ID="RadDockLayout1" runat="server">  
                <telerik:RadDockZone ID="RadDockZone1" runat="server" Width="900px">  
                    <telerik:RadDock ID="RadDock1" runat="server" Width="900px" Title="Visible">  
                        <ContentTemplate>Visible by default</ContentTemplate> 
                    </telerik:RadDock> 
                    <telerik:RadDock ID="RadDock2" runat="server" Width="900px" Title="Invisible by Default">  
                        <ContentTemplate>Invisible by default.</ContentTemplate> 
                    </telerik:RadDock> 
                </telerik:RadDockZone> 
            </telerik:RadDockLayout> 
        </form> 
    </body> 
    </html> 

    Visiblity is set to false for RadDock2 in the code behind (see below).
    using System;  
     
    namespace TestHiddenDock  
    {  
        public partial class _Default : System.Web.UI.Page  
        {  
            protected void Page_Load(object sender, EventArgs e)  
            {  
                if (!Page.IsPostBack)  
                    RadDock2.Visible = false;  
            }  
        }  

    Is there a workaround for this problem?
  2. Answer
    Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 09 Apr 2009 Link to this post

    Hello PJ,

    In such scenario, you should use the Closed property instead of Visible. Just set it to true when you want to hide the RadDock control.


    Best wishes,
    Georgi Tunev
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  3. Glenn Miller
    Glenn Miller avatar
    4 posts
    Member since:
    May 2003

    Posted 09 Apr 2009 Link to this post

    I'm having the same problem when setting a RadDock visible = false. The jscript error occurs when you set the visible property to false at design time or runtime.

    I tried using the Close property to "hide" the RadDock. Using the close property instead of the visible property does work to hide the RadDock. The problem is any Html, etc. that is inside of the RadDock still gets sent to the browser.

    For example I have a RadDock setup like this:

     

    <

     

    Telerik:raddock id="RadDock4" title="RadDock4" runat="server" width="200px" dockmode="Docked" Closed="True" >

     

     

     

        <ContentTemplate>
              This text should not be sent to the browser

     

        </ContentTemplate>

     

     

    </telerik:raddock>

     

     


    The text "This text should not be sent to the browser" is still sent to the browser.

    In our real app, we have many RadDock's that are dynamically turned on / off. Many have user controls located within them. Using the close method still allows all the output from the controls be sent to the browser. As you might image, the Html output is quite large.

    We did not have this problem using an eariler version of the controls. This problem only started when we updated to the newer 2009.1.402.20 version.

    We were using the 2008.03.1314.20 version. In this version we were able to set visible=false, and it worked fine.

    Any Ideas on how we can make the visible property actually work properly in the 2009.1.402.20 version ?

    Thanks,
    Glenn

     

     

     

  4. PJ Melies
    PJ Melies avatar
    30 posts
    Member since:
    Sep 2008

    Posted 09 Apr 2009 Link to this post

    The suggestion of using the Closed property actually solves the issue for us but I would think the control should be fixed so as not to throw exceptions when docks are set to Visible=false; otherwise, what is the purpose of having the property if you can't use it?  The scenario Glenn mentions above is valid.  No reason to send a lot of text over http if it's not needed.
  5. Petio Petkov
    Admin
    Petio Petkov avatar
    825 posts

    Posted 13 Apr 2009 Link to this post

    Hi All,

    To preserve the state of the RadDock controls they should be rendered (hidden or shown) on the page, so we added a property Closed, which is responsible for RadDock's visibility on the client.
    The RadDock.Visible property is inherited from its parent class and in previous versions this JavaScript error not appears because we workarounded the case when the RadDock.Visible property is set to false. We will do our best to fix this error for the next RadControls for ASP.NET AJAX release.
     Till then, you can use the following workaround which overrides the $create method:

    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> 
    <!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>Untitled Page</title> 
    </head> 
    <body> 
        <form id="form1" runat="server">  
        <asp:ScriptManager ID="ScriptManager1" runat="server">  
        </asp:ScriptManager> 
        <script type="text/javascript">  
            window.$createOld = window.$create;  
            window.$create = function(arg1, arg2, arg3, arg4, arg5) {  
                if (arg1 && arg1.__typeName == "Telerik.Web.UI.RadDock") {  
                    if (arg5) {  
                        return this.$createOld(arg1, arg2, arg3, arg4, arg5);  
                    }  
                }  
                else {  
                    return this.$createOld(arg1, arg2, arg3, arg4, arg5);  
                }  
            }  
        </script> 
        <div> 
            <telerik:RadDockLayout ID="layoutCtrl" runat="server">  
                <telerik:RadDockZone ID="leftZone" runat="server" Width="300px" Skin="WebBlue" BorderStyle="None">  
                      
                    <telerik:RadDock ID="RadDock2" runat="server" Visible="true" 
                        Skin="WebBlue"  Title="aa">  
                    </telerik:RadDock>    
                   <telerik:RadDock ID="RadDock3" runat="server" Visible="false" 
                        Skin="WebBlue"  Title="aa">  
                    </telerik:RadDock> 
                </telerik:RadDockZone> 
            </telerik:RadDockLayout>   
              
            <telerik:RadDock ID="RadDock1" runat="server" Visible="true" 
                        Skin="WebBlue"  Title="aa">  
                    </telerik:RadDock>    
                   <telerik:RadDock ID="RadDock4" runat="server" Visible="false" 
                        Skin="WebBlue"  Title="aa">  
                    </telerik:RadDock> 
        </div> 
        </form> 
    </body> 
    </html> 
     


    Regards,
    Petio Petkov
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  6. Glenn Miller
    Glenn Miller avatar
    4 posts
    Member since:
    May 2003

    Posted 14 Apr 2009 Link to this post

    Thanks for the workaround. It seems to work fine.

    A note to anyone wanting to use this method:

    Do not place the workaround script inside of a "RadCodeBlock". It will not work correctly if you do.

    Thanks,
    Glenn
Back to Top