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

current height in c#

3 Answers 65 Views
Window
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 11 Sep 2013, 07:47 PM
I need to get the current height of a RadWindow in codebehind.  The "Height" property seems to be always the original height of the window, not the current height.

Failing that, I need some function on the client that fires after every postback on the client.

3 Answers, 1 is accepted

Sort by
0
Slav
Telerik team
answered on 16 Sep 2013, 01:45 PM
Hello John,

The height of the RadWindow is always the original one, because the control is reopened after a postback and its configuration is reset. You could utilize the custom settings of the Persistence Framework to store the state of the window thus keeping it height after a postback.

If you want to execute a JavaScript function after a postback, you can use the RegisterStartupScript method in order to register the desired function from the code-behind.

Regards,
Slav
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
John
Top achievements
Rank 1
answered on 16 Sep 2013, 02:03 PM
The actual size of the radwindow sticks during a postback as in the window does not resize back to the original size, the Height property, however, is the original size.  I see this is a bit of a problem.
0
Marin Bratanov
Telerik team
answered on 18 Sep 2013, 09:03 AM
Hi John,

The Width and Height properties of the RadWindow control are server properties that define its default size. If the control is disposed on the client and shown after a postback it will have these dimensions, regardless of the previous size it had in the browser (e.g. after the user had it resized) In your case the postbacks are most likely partial and the RadWindow is not disposed.

The entire rendering and user interaction with the control are done on the client, even its popup element is created with JavaScript (which greatly reduces its footprint on the server and in the HTTP response) and the price for that is the fact that you cannot access its current state on the server. The server cannot know what happens in the browser.

In the same manner you cannot know how large the browser viewport is on the server without adding some custom code that will store this information (e.g. in a hidden field) in order to pass it to the server.

So, what I an suggest is using the OnClientResizeEnd event of the control and its getWindowBounds() client-side method to get and store the current dimensions in order to use them on the server.


Regards,
Marin Bratanov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Window
Asked by
John
Top achievements
Rank 1
Answers by
Slav
Telerik team
John
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or