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

AutoResize after failed validation

2 Answers 64 Views
Window
This is a migrated thread and some comments may be shown as answers.
Neil
Top achievements
Rank 1
Neil asked on 23 Mar 2011, 10:20 PM
I noticed that after I submit a form that fails validation, my window (with autosize="true" set) does not auto-resize to account for the validation summary.

In my click event, I am trying to call autoSize() directly if IsValid id false without much success.  

private void Save_Click(object sender, EventArgs e)
        {
            if (this.IsValid)
            {
                    // save
            }
            else
            {
                    string autoSize = "getRadWindow().autoSize(true);";
                    // Register a startup script which will manually call autoSize() on radWindowActivity
                    RadScriptManager.RegisterStartupScript(
                    this,
                    this.GetType(),
                    "resizeWindow",
                    autoSize,
                    true);
            }

2 Answers, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 28 Mar 2011, 03:30 PM
Hello Neil,

The provided information is not enough to completely understand the setup and the problem.

One possible reason for such a problem is that the controls in the RadControls for ASP.NET AJAX suite are built upon the MS AJAX framework and the framework itself creates its controls (including RadWindow) in the Sys.Application.add_init() method.

Here is how the client events are fired in the page life cycle:

window.onload -> Sys.Application.init -> Sys.Application.load

You can see that the client object representation of MS AJAX controls are created just as the last code on the page in the Sys.Application.init event, which is raised after the window.onload event.

That is why when you call your code in window.onload by registering the client script, the RadWindow will still not be created on the page and you will get an error. To avoid this problem, you can either execute your code with a small timeout, or use the Sys.Application.add_load method.

You can find additional information about this here:

http://blogs.telerik.com/blogs/posts/09-05-05/executing_javascript_function_from_server-side_code.aspx


In case you need further assistance, please prepare a fully runnable simple reproduction demo along with detailed reproduction instructions, open a new support ticket and send it to us and we will modify it in order to meet your requirements so that you will be then able to apply the same logic in your original application.

Kind regards,
Svetlina
the Telerik team
0
Neil
Top achievements
Rank 1
answered on 05 Apr 2011, 04:31 PM
Thanks Svetlina , that got me in the right direction.

Neil
Tags
Window
Asked by
Neil
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Neil
Top achievements
Rank 1
Share this question
or