Get dimensions of borders, title bar etc.

4 posts, 0 answers
  1. Ulrik
    Ulrik avatar
    5 posts
    Member since:
    May 2009

    Posted 16 Sep 2009 Link to this post

    Hello,

    I am using RadWindow to display a form which updates itself using Ajax, thereby changing its dimensions. To accommodate for this, I have created a small client script which - on each Ajax response - sets the width and height of the RadWindow equal to the width and height of the table I use to layout the form. The script follows here:

    function resizeWindow() 
      var table = $get('layoutTable'); 
      oWindow.set_width(table.offsetWidth); 
      oWindow.set_height(table.offsetHeight); 

    Now, the problem is that the set_width and set_height methods sets the width and height of the whole RadWindow, and not the client area. I therefore has to add the width and height of the window borders and title bar, respectively. This means my code now depends on the current skin, which isn't something I want. Is there any way I can easily retrieve the dimensions of the window borders, or set the dimensions of the client area directly?

    Thanks a lot!


    Regards,

    Ulrik Rasmussen
  2. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 21 Sep 2009 Link to this post

    Hello Ulrik,

    Could you please try the oWindow.autoSize() method instead of the set_width and set_height ones. If you use the suggested approach, I recommend you add this code in the head tag of the page that is opened inside the RadWindow :

    <style type="text/css"
        html, body, form 
        { 
            height: 100%; 
            padding: 0; 
            margin: 0; 
            width: 100%; 
        } 
    </style> 

    I hope this helps.

    All the best,
    Fiko
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Ulrik
    Ulrik avatar
    5 posts
    Member since:
    May 2009

    Posted 30 Sep 2009 Link to this post

    Hello Fiko,

    The oWindow.autoSize()-method only seems to work when initially opening the window - when the window resizes due to an Ajax update, the autoSize()-call has no effect.


    /Ulrik
  4. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 30 Sep 2009 Link to this post

    Hi Ulrik,

    Indeed, when AutoSize is set to true, RadWindow will update its size only when there is a postback in the content page. The client autoSize() method however, can be called after the Ajax request has finished.
    For example:
    ASPX
    <head runat="server"
        <title></title
     
        <script type="text/javascript"
            function GetRadWindow() 
            { 
                var oWindow = null
                if (window.radWindow) 
                    oWindow = window.radWindow; 
                else if (window.frameElement.radWindow) 
                    oWindow = window.frameElement.radWindow; 
                return oWindow; 
            } 
     
            function resizeWin() 
            { 
                GetRadWindow().autoSize(); 
            }  
        </script> 
     
    </head> 
    <body> 
        <form id="form1" runat="server"
        <asp:ScriptManager ID="ScriptManager1" runat="server"
        </asp:ScriptManager> 
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
            <ClientEvents OnResponseEnd="resizeWin" /> 
            <AjaxSettings> 
                <telerik:AjaxSetting AjaxControlID="Button1"
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="Label1" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
            </AjaxSettings> 
        </telerik:RadAjaxManager> 
        <asp:Button ID="Button1" runat="server" Text="Click me" /> 
        <asp:Label ID="Label1" runat="server"></asp:Label> 

    Codebehind
    Protected Sub Button1_Click(ByVal sender As ObjectByVal e As System.EventArgs) Handles Button1.Click 
        Label1.Width = Unit.Pixel(800) 
        Label1.Height = Unit.Pixel(800) 
        Label1.BorderStyle = BorderStyle.Solid 
        Label1.BorderWidth = Unit.Pixel(5) 
        Label1.BorderColor = Drawing.Color.Red 
    End Sub 


    All the best,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top