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

Window position reseting on postback

3 Answers 61 Views
Window
This is a migrated thread and some comments may be shown as answers.
Bob Fenton
Top achievements
Rank 1
Bob Fenton asked on 27 Nov 2012, 06:39 PM
Hi,

I have built as UserControl (.ascx) as a component for handling radwindows.

The windows are created dynamically server side and I use VisibleOnPageLoad=true and everything is working with one exception.   If an open window is moved or resized by the user as soon as a subsequent radwindow is opened a postback occurs and the first window defaults back to its original size and position.

I would appreciate some assistance in resolving this.

Thank you.

Regards.

Bob

3 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 30 Nov 2012, 03:11 PM
Hi Bob,

The RadWindow renders entirely via JavaScript, on the client, and this is one of its main features. It allows instances to be created during runtime without any additional requests to the server which can effectively boost the performance of the application. This also means that it does not have the server render markup and send it over the wire. The price for this benefit is the fact that a postback that disposes the RadWindow will effectively destroy it, so it cannot preserve its properties (size, position).

The best way to use the RadWindow is through its client-side API and to keep it out of any postbacks (if possible), including partial ones.

All that being said, you can give the PreserveClientState property of the RadWindowManager a shot. Note that it keeps the size and position of RadWnidows from its collection in a cookie, so it works not only for postbacks but for different sessions as well. Also, a cookie may be rejected by the client's browser.


Kind regards,
Rumen
the Telerik team
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 their blog feed now.
0
Bob Fenton
Top achievements
Rank 1
answered on 30 Nov 2012, 03:36 PM
Hi Rumen

Thanks for that. However, I want to use the skins feature and, as far as I can ascertain, I must therefore create the window server side.

SInce my original post, I have kind of fixed the problem by writing out my own cookie whenever the window position of size is changed.

I do have one other question: Is there any kind of custom attribute that can be added to a radwindow created server side that will be preserved on postback or does this also come down to the "client side" nature of the radwindow component?

Regards

Bob
0
Marin Bratanov
Telerik team
answered on 03 Dec 2012, 12:23 PM
Hello Bob,

It is good to hear that you have the desired functionality working. I would just like to clarify that a RadWindow generated with JavaScript by its manager will inherit the skin used by the manager. This means that skins will still work, only that you would have to use the one set to the manager. You can add another manager with another skin should you need a second one in your site's design. How to handle multiple managers is explained here.

Regarding your question - if you set some attribute in the RadWindow markup it will also be transferred to the rendered HTML markup. 
<telerik:RadWindow myCustomAttribute="someValue" ID="RadWindow1" runat="server">
</telerik:RadWindow>
function pageLoad()
{
    var oWnd = $find("<%=RadWindow1.ClientID %>");
    alert(oWnd.get_element().getAttribute("myCustomAttribute"));
}
note how I use get_element() to get the basic element with which the script control instance is associated. Should you need to modify the actual RadWindow you would need to use the get_popupElement() method.

Another thing that is important to note that when you create server controls dynamically they cannot be automatically persisted across postbacks, the developer must recreate them each time if needed by his/her logic. This is the general way ASP works and more information on that is available in the net, e.g. here.


Greetings,
Marin Bratanov
the Telerik team
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 their blog feed now.
Tags
Window
Asked by
Bob Fenton
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Bob Fenton
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or