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

get RadWindow's height after Maximize Command.

9 Answers 451 Views
Window
This is a migrated thread and some comments may be shown as answers.
Alessio
Top achievements
Rank 1
Alessio asked on 10 Feb 2009, 11:03 AM
Hi,
I would to get the height of the window after the command of maximizing.

I use this client function:

function OnClientCommand(sender, eventArgs) {                
if (eventArgs._commandName == "Maximize") {
alert(GetRadWindow().getWindowBounds().height);
}

But the message shows the height of the first maximize... 

Thank.

Alessio.
            

9 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 10 Feb 2009, 11:31 AM
Hello Alessio,

I believe that the following forum thread will be of help:
http://www.telerik.com/community/forums/aspnet-ajax/window/is-there-a-window-onmaximize-event.aspx


Sincerely yours,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Alessio
Top achievements
Rank 1
answered on 10 Feb 2009, 11:49 AM
Thanks for your response,

I have changed my code, but still does not work.

function GetRadWindow() {                    
    var oWindow = null;                    
    if (window.radWindow) oWindow = window.radWindow;                    
    else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;                    
    return oWindow;                    

function OnClientCommand(sender, eventArgs) {                
  if (eventArgs._commandName == "Maximize") { 
  setTimeout('OnClientResize(null, null)', 0);                                        }
}

function OnClientResize(sender, eventArgs) {                               
alert(GetRadWindow().getWindowBounds().height);
            }

Alessio.
0
Georgi Tunev
Telerik team
answered on 11 Feb 2009, 07:59 AM
Hi Alessio,

I apologize for not providing a full code sample in my previous reply. Here is how to get the size - you need to get the height and width of the popup element after the resize. Also please note that the OnClientCommand handler must be placed in the parent page:
<asp:ScriptManager ID="ScriptManager1" runat="server"
</asp:ScriptManager> 
 
<script type="text/javascript" language="javascript"
function openWin() 
    var oWnd = $find("<%= rwDialog.ClientID %>");  
    oWnd.show(); 
 
function OnClientCommand(sender,args) 
    if(args.get_commandName() == "Maximize") 
    { 
        window.setTimeout(function() 
        { 
             
            var senderElementStyle = sender.get_popupElement().style; 
            alert(senderElementStyle.width + "   " + senderElementStyle.height);   
        }, 0); 
    } 
 
</script> 
 
<telerik:RadWindow  
    ID="rwDialog"  
    runat="server"  
    NavigateUrl="Dialog.aspx" 
    OnClientCommand="OnClientCommand" 
    > 
</telerik:RadWindow> 
<button id="showDialog" onclick="openWin(); return false;"
    Show Dialog</button> 

If you want to get the size in the parent page, your code should look like this:
    <form id="form1" runat="server"
        <asp:ScriptManager ID="ScriptManager1" runat="server"
        </asp:ScriptManager> 
 
        <script type="text/javascript" language="javascript"
        function openWin() 
        { 
            var oWnd = $find("<%= rwDialog.ClientID %>");  
            oWnd.show(); 
        } 
         
        function OnClientCommand(sender,args) 
        { 
            if(args.get_commandName() == "Maximize") 
            { 
                //call a function in the content page 
                sender.get_contentFrame().contentWindow.secondFn(); 
            } 
        } 
         
        </script> 
 
        <telerik:RadWindow  
            ID="rwDialog"  
            runat="server"  
            NavigateUrl="Dialog.aspx" 
            OnClientCommand="OnClientCommand" 
            > 
        </telerik:RadWindow> 
        <button id="showDialog" onclick="openWin(); return false;"
            Show Dialog</button> 
    </form> 

and in the content page:
 function GetRadWindow() 
    { 
      var oWindow = null
      if (window.radWindow) oWindow = window.radWindow; 
      else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; 
      return oWindow; 
    } 
     
    function secondFn() 
    { 
        window.setTimeout(function() 
        { 
            var senderElementStyle = GetRadWindow().get_popupElement().style; 
            alert(senderElementStyle.width + "   " + senderElementStyle.height);   
        }, 0); 
    } 


All the best,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Alessio
Top achievements
Rank 1
answered on 11 Feb 2009, 09:10 AM
Now is all Ok!

Very Thank!!

Alessio.
0
Bader
Top achievements
Rank 1
answered on 07 Oct 2010, 11:31 PM
Hi,

Thank you for your code, it was very useful.
But I still have a problem with using the width and height values in the c# code, in other words, after I open the maximized radwindow, I need to get the width and height in pixels and use them in the c# code (Page_Load method),

Plaese, look at the following code:
"

<

 

 

html xmlns="http://www.w3.org/1999/xhtml">

 

<

 

 

 

 

head id="Head1" runat="server">

 

 

 

 

 

<title></title>

 

 

 

 

 

<script language="javascript" type="text/javascript">

 

 

 

 

 

function GetRadWindow() {

 

 

 

 

 

var oWindow = null;

 

 

 

 

 

if (window.radWindow)

 

oWindow = window.RadWindow;

 

 

 

 

//Will work in Moz in all cases, including clasic dialog

 

 

 

 

 

else if (window.frameElement.radWindow)

 

oWindow = window.frameElement.radWindow;

 

 

 

 

//IE (and Moz as well)

 

 

 

 

 

return oWindow;

 

}

 

 

 

 

function GetRadWindowWidth() {

 

 

 

 

 

var senderElementStyle = GetRadWindow().get_popupElement().style;

 

 

 

 

 

var _width = senderElementStyle.width.toString();

 

document.all(

 

 

 

'Label2').innerHTML = _width;

 

}

 

 

 

 

 

</script>

 

 

 

 

 

<style type="text/css">

 

 

 

 

 

#CMapPanel {position:absolute; }

 

 

 

 

 

#content {position:relative; z-index:2;}

 

 

 

 

 

#LayerPanel1 {position:relative; z-index:1;}

 

 

 

 

 

</style>

 

 

 

 

 

<script type="text/javascript">

 

 

 

 

 

function OnClientInitialize(dock, args) {

 

 

 

 

 

var divMap = $get("CMapPanel");

 

divMap.appendChild(dock.get_element());

}

 

 

 

 

</script>

 

</

 

 

 

 

head>

 

<

 

 

 

 

body onload="GetRadWindowWidth()">

 

 

 

 

 

<form id="form1" runat="server">

 

 

 

 

 

<div>

 

 

 

 

 

<asp:ScriptManager ID="ScriptManager1" runat="server" />

 

 

 

 

 

 

<asp:Panel ID="Panel2" Width="100%" Height="100%" runat="server" >

 

 

 

 

 

<asp:Panel ID="CMapPanel" Height="100%" Width="100%" runat="server" >

 

 

 

 

 

<asp:Image ID="CMapImage" runat="server" />

 

 

 

 

 

</asp:Panel>

 

 

 

 

 

<asp:Panel ID="LayerPanel1" Width="100%" runat="server">

 

 

 

 

 

<telerik:RadDockLayout ID="RadDockLayout1" runat="server">

 

 

 

 

 

 

</telerik:RadDockLayout>

 

 

 

 

 

</asp:Panel>

 

 

 

 

 

<asp:Panel ID="content" Width="100%" Height="60px" runat="server">

 

 

 

 

 

<asp:Label ID="Label2" runat="server" Visible="true" Text="Label"></asp:Label>

 

 

 

 

 

<asp:Label ID="Label3" runat="server" Visible="true" Text="Label"></asp:Label>

 

 

 

 

 

</asp:Panel>

 

 

 

 

 

</asp:Panel>

 

 

 

 

 

 

</div>

 

 

 

 

 

</form>

 

 

 

 

</

 

 

body>

 

</

 

 

 

 

html>

 

 

 

"

For now, the "Label2" gets the value of "1024px" , but if I try to set that value for "Label3", then the Label3 will get the value string.Empty.

"

protected

 

 

void Page_Load(object sender, EventArgs e)

 

{

 

 

 

 

  Label3.Text = Label2.Text.ToString();
}

It is very important to handle the returned value of width in the Page_Load method

Please, what is wrong with the above code.
it is apprecited to send me the modified code with an explaination,.

Regards,
Bader 

0
Georgi Tunev
Telerik team
answered on 13 Oct 2010, 09:46 AM
Hello Bader,

The reason for the problem is in the way you built the logic. The asp:label element is rendered as a standard SPAN and will not work for such scenarios - this issue is not related to our controls in any way. More information on the subject is available in various resources on the Net.

What I would suggest is to use a hidden field.
e.g.
<head runat="server">
    <title></title>
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            Label2.Text = HiddenField1.Value;
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:Label ID="Label1" runat="server"></asp:Label>
    <asp:HiddenField ID="HiddenField1" runat="server" />
    <asp:Label ID="Label2" runat="server"></asp:Label>
    <button onclick="setValue(); return false;">
        set value in label1</button>
    <asp:Button ID="Button1" runat="server" Text="Submit" />
    <script type="text/javascript">
 
        function setValue()
        {
            var _width = "500"
            var label2 = document.getElementById("<%= HiddenField1.ClientID %>");
            label2.value = _width;
 
        }
    </script>
    </form>
</body>
</html>


Kind regards,
Georgi Tunev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Bader
Top achievements
Rank 1
answered on 13 Oct 2010, 06:12 PM
Hello,

Thank you very much for your code, it was useful but unforunatily it is not solving my issue,
I have searched for a good resources in order to handle this issue but I didn't find any thing good.

All I need is to get the radwindow width (or height) immediately using the Page_Load method, without clicking the following buttons:
<button onclick="setValue(); return false;">
        set value in label1</button>
    <asp:Button ID="Button1" runat="server" Text="Submit" />

Please, I need your help, I'm stuck here in this point.
It is appreciated to send me the modified code.

Regards,
Bader
0
Bader
Top achievements
Rank 1
answered on 03 May 2011, 07:46 AM
Hello,

I havn't recieve any reply yet regarding the above issue.
"
All I need is to get the radwindow width (or height) immediately using the Page_Load method, without clicking the following buttons:
<button onclick="setValue(); return false;">
        set value in label1</button>
    <asp:Button ID="Button1" runat="server" Text="Submit" />

"

Please, I need your help, I'm stuck here in this point.
It is appreciated to send me the modified code.

Regards,
Bader
0
Bader
Top achievements
Rank 1
answered on 08 May 2011, 07:32 AM
Tags
Window
Asked by
Alessio
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Alessio
Top achievements
Rank 1
Bader
Top achievements
Rank 1
Share this question
or