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

Get RadWindow height using code behind

4 Answers 139 Views
Window
This is a migrated thread and some comments may be shown as answers.
Bader
Top achievements
Rank 1
Bader asked on 02 May 2011, 01:16 PM
Hello,

I have a problem,
I have a radwindow control which displays a webpage that contains a label control.
I need to set the height of this radwindow in that label and use it within the c# code of the page.

i'm using rhe following javascript code:
function FocusOnRadWindow() {
window.setTimeout(function () {
GetRadWindow().GetContentFrame().contentWindow.focus();
var wndHeightValue = GetRadWindow().get_popupElement().style.height.toString().replace("px", "");
document.getElementById("TestLabel").innerHTML = wndHeightValue;
}, 100);
}

I call the above function like this:
<body onload="FocusOnRadWindow()">

The height is retrieved without problems, but the issue is I can't access that value in code behind. for example, If I use the following code, I recieve an error message (Attached):
int wndHeight = Convert.ToInt32(TestLabel.Text) - 130;

Please, Can you explain to me how can I solve this problem.
It is very apprecited to send me the modified code with an explaination regarding the above situation.

Regards,
Bader

4 Answers, 1 is accepted

Sort by
0
Cori
Top achievements
Rank 2
answered on 03 May 2011, 01:13 PM
Hello Bader,

Have you examined what the Text property of the label is holding when debugging the code. I would have to assume the conversion fails because it has "px" in it. When accessing the height property, it also includes the unit, so if you remove the unit part, the conversion should succeed.

I hope that helps.
0
Bader
Top achievements
Rank 1
answered on 03 May 2011, 02:37 PM
Hello,

Thank you for your reply,
I did that, but it is not help . I want to indicate that I want to get the height of the radwindow control after maximizing (look at http://www.telerik.com/community/forums/aspnet-ajax/window/get-radwindow-s-height-after-maximize-command.aspx).
Please, Can you send to a sample page which demonstrate the issue.

Regards,
Bader
0
Accepted
Cori
Top achievements
Rank 2
answered on 05 May 2011, 01:26 PM
Hello Bader,

After examining your page in that forum post, it looks like you setting the RadWindow height in a label control during the page's client-side onload event and then trying to access that value from the server-side Page_Load event? Is that correct?

If so, I can understand why you wouldn't be getting the value since the client-side event doesn't happen before a server-side event. You would have to perform a full page postback to get the value set in the Label control (preferably turning it into a HiddenField, since it has a value property). To perform that postback, you could use the RadAjaxManager or RadAjaxPanel in your RadWindow page and pass the height of the RadWindow in the ajaxRequest method. You can then handle the OnAjaxRequest event and perform the code that you were doing in the Page_Load event.

You can refer to this help article: http://www.telerik.com/help/aspnet-ajax/ajax-onajaxrequest.html

I hope that helps.
0
Bader
Top achievements
Rank 1
answered on 08 May 2011, 07:05 AM
Hello Cori,

Thank you very much for your help,
The problem was solved.

Regards,
Bader
Tags
Window
Asked by
Bader
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
Bader
Top achievements
Rank 1
Share this question
or