This is a migrated thread and some comments may be shown as answers.

Get dimensions of borders, title bar etc.

3 Answers 79 Views
Window
This is a migrated thread and some comments may be shown as answers.
Ulrik
Top achievements
Rank 1
Ulrik asked on 16 Sep 2009, 01:15 PM
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

3 Answers, 1 is accepted

Sort by
0
Fiko
Telerik team
answered on 21 Sep 2009, 12:39 PM
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.
0
Ulrik
Top achievements
Rank 1
answered on 30 Sep 2009, 07:52 AM
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
0
Georgi Tunev
Telerik team
answered on 30 Sep 2009, 11:01 AM
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.
Tags
Window
Asked by
Ulrik
Top achievements
Rank 1
Answers by
Fiko
Telerik team
Ulrik
Top achievements
Rank 1
Georgi Tunev
Telerik team
Share this question
or