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

RegisterClientScriptBlock not inserting script in RadWindow

5 Answers 386 Views
Window
This is a migrated thread and some comments may be shown as answers.
hkdave95
Top achievements
Rank 2
hkdave95 asked on 21 Oct 2007, 01:57 PM
Hi

I have put the following RegisterClientScriptBlock into a Window to automate closing of the window after a login has been Authenticated.

Call Telerik.Web.UI.RadScriptManager.RegisterClientScriptBlock(Me.Page, Me.Page.GetType, "RadCloseWindow", "alert('Hello'); RadCloseWindow();", True) 

NB: I am using Membership with this login and therefore I have a "Login" control and "LayoutTemplate" on this page.

Kind Regards

David

5 Answers, 1 is accepted

Sort by
0
Erjan Gavalji
Telerik team
answered on 22 Oct 2007, 04:24 PM
Hi hkdave95,

I just checked the code and did not have the problem. Please, find my sample page attached.

I want to note that RadScriptManager (although appearing in the Toolbox in the first release) is not public yet. You should use ScriptManager.RegisterClientScriptBlock instead.

Let me know if I am missing something.

Kind regards,
Erjan Gavalji
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
hkdave95
Top achievements
Rank 2
answered on 22 Oct 2007, 06:06 PM
Hi

Could you try putting a simple "Login" form onto your webpage.

Mabye this is causing the incorrect behaviour.

Kind REgards

David
0
Georgi Tunev
Telerik team
answered on 25 Oct 2007, 03:21 PM
Hi David,

We were not able to reproduce the problem even with the Login form - everything is working as expected.

Please open a new support ticket and send us a small sample application where the problem can be reproduced. We will check it and do our best to help.




Sincerely yours,
Georgi Tunev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Beth
Top achievements
Rank 1
answered on 11 Feb 2008, 03:54 PM
Hi All,
I'm wondering if my problem is related to this or if I should open a new thread.

We would also like to use the radalert to popup when the login attempt is unsuccessful (also using the asp.net login control).  I tried to use the OnLoginError method and the RegisterClientScriptBlock method to render the 'radalert' javascript call.  I was getting an "object not found" or similar error.

I then realized when looking at the source that the alert call was generated at the top of the page and the include source for the javascript for the RadWindow control is at the bottom of the page.  So the function to popup the alert isn't available when the alert is called (from the top of the page).

Is there anyway to get the RegisterClientScriptBlock to generate the code at the bottom of the page or the javascript includes for the rad controls to be at the top?

Please let me know if that wasn't clear and thanks for your time,
Beth
0
Georgi Tunev
Telerik team
answered on 11 Feb 2008, 04:19 PM
Hello Beth,

Indeed you are right - the fact that the RadWindowManager is not fully rendered on the page when you call radalert is the most likely reason for such problem.

The recommended solutions vary depending on the type of the control that you are using:
  1. RadWindow for ASP.NET: Please check the following KB article: http://www.telerik.com/support/kb/article/b454K-gtd-b454T-cec-b454c-cec.aspx
  2. RadWindow for ASP.NET AJAX: The controls in the Prometheus suite are built upon the MS AJAX framework and the framework itself creates its controls (including RadWindow Prometheus) in the Sys.Application.add_init() method - you can check this for yourself by examining the HTML dump of a page with RadControls Prometheus included in it (or any other ASP.NET AJAX control).
    That is why when you call your code when the page is loaded, the RadWindowManager will still not be fully rendered on the page and you will get the error. To avoid this issue, you can either execute your code with a small timeout or better - to add your code in the Sys.Application load handler as shown below:

      protected void RadAlertButton_Click(object sender, EventArgs e)  
        {  
            ScriptManager.RegisterStartupScript(Page, typeof(Page), "RadAlertScript""Sys.Application.add_load(function(){radalert('test');});"true);  
        } 




Best wishes,
Georgi Tunev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Window
Asked by
hkdave95
Top achievements
Rank 2
Answers by
Erjan Gavalji
Telerik team
hkdave95
Top achievements
Rank 2
Georgi Tunev
Telerik team
Beth
Top achievements
Rank 1
Share this question
or