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

Open master page RadWindow from content page

1 Answer 251 Views
Window
This is a migrated thread and some comments may be shown as answers.
Bruce Mendonza
Top achievements
Rank 1
Bruce Mendonza asked on 04 Apr 2011, 12:46 PM

Hello,

I have a window (used to display error messages) which resides on the master page. This window is then called by a publically accessable function on the master code behind which can be accessed by the child pages. Now, if I attempt to use the RadGrid RowDrop function and an error occurs, the master window does not display. The window does appear if I force an error (give an invalid stored procedure name) on the population method, but in this situation a full page laod accurs.

I would greatly appreciate your assistance.


See sample code example below:

Master Page
--------------------
public void Show_Error_Msg(String strLocation, String strError)
{           
            RadWindow objWindow = RadWindowManager1.Windows[0];
            (objWindow.ContentContainer.FindControl("lbl_error_local") as Label).Text = strLocation;
            (objWindow.ContentContainer.FindControl("lbl_error_msg") as Label).Text = strError;
            objWindow.VisibleOnPageLoad = true;
 }  

Content Page
---------------------

protected void RadGrid1_RowDrop(object sender, GridDragDropEventArgs e)
{
      try{
            throw new Exception("This is the error from the RowDrop function");
      }
      catch(exception err){ Master.Show_Error_Msg("Row Drop", err.Message.ToString()); }
}
           

1 Answer, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 05 Apr 2011, 09:57 AM
Hi Bruce,

I already answered your other thread and for your convenience and for others who might encounter teh same problem I pasted my reply below:

Hello Bruce,

As far as I understand from your explanations, you face a problem when trying to reference the RadWindow client object from a script which is executed from the code-behind. If so, please note 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

I hope that the provided explanation and resource are helpful, let me know how it goes. In case the issue persists, please send a very simple, fully runnable reproduction page (no need for grid - a button will be enough to demonstrate the issue) and I 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
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
Tags
Window
Asked by
Bruce Mendonza
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Share this question
or