Problem with RadScriptManager

1 Answer 46 Views
Ajax Button ScriptManager and StyleSheetManager
El Ghali
Top achievements
Rank 1
El Ghali asked on 02 Aug 2022, 01:15 PM

Hello,

I have a problem with RadScriptManager

I have an exisiting ASP.Net Web Forms web application.

There is Default.aspx and used Main.Master master page

I did the necessary to integrate Telerik UI Web correctly.

In the master page there is <asp:ScriptManager ID="ScriptManager...

and in the Default.aspx I added <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

and <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />

and <telerik:RadWindowManager RenderMode="Lightweight"....

and <button onclick="openReqForm(); return false;">hello</button>

in code behind:

string fctOpenReqForm = "<script type=\"text/javascript\">function openWin {var oWnd = radopen(\"Request.aspx\", \"RadWindow1\"); } </script>";

Page.ClientScript.RegisterStartupScript(this.GetType(), "openReqForm", fctOpenReqForm);

 

When I execute I have an error message: "Only one instance of script manager can be added to the page...

I need to add a Telerik button and other telerik things to the page and use javascript methods...

Any help? thanks

 

1 Answer, 1 is accepted

Sort by
0
Peter Milchev
Telerik team
answered on 02 Aug 2022, 01:58 PM

Hello El Ghali,

The RadScriptManager is inheriting and extending the default ScriptManager and that explains why you get the error you shared. 

To fix that, you can simply replace the asp:ScriptManager with the telerik:RadScriptManager in the Master page and you would not need to add any script managers in the content pages.

Also, the Telerik controls could work with an asp:ScriptManager on the page. The RadScriptManager gives some features and benefits you can leverage over the asp:ScriptManager:

Regards,
Peter Milchev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

El Ghali
Top achievements
Rank 1
commented on 02 Aug 2022, 02:14 PM

Thank you for your answer.

I did what you said, and I don't have the error anymore.

Now I tried to add a button that must open a window: I added the following ont the Default.aspx page:

<telerik:RadWindowManager RenderMode="Lightweight" ID="RadWindowManager1" ShowContentDuringLoad="false" VisibleStatusbar="false" ReloadOnShow="true" runat="server" EnableShadow="true">
		<Windows>
			<telerik:RadWindow RenderMode="Lightweight" ID="RadWindow1" runat="server" Width="650" Height="480" Modal="true" Behaviors="Close" OnClientClose="OnClientClose" NavigateUrl="Request.aspx">
			</telerik:RadWindow>
		</Windows>
	</telerik:RadWindowManager>

and:

<button onclick="openReqForm(); return false;">hello</button>


and in the on-load method of code behind's page:

string fctOpenReqForm = "<script type=\"text/javascript\">function openWin {var oWnd = radopen(\"Request.aspx\", \"RadWindow1\"); } </script>";
Page.ClientScript.RegisterStartupScript(this.GetType(), "openReqForm", fctOpenReqForm);

The result is that the button appears, but the other asp.net existing components are impacted and not appears correctly as before. how can I add the button that open Request.aspx window while keeping existing page's component working fine? can I avoid using javascript to meet the need?

Regards

Peter Milchev
Telerik team
commented on 05 Aug 2022, 09:31 AM

Hello, there seems to be an issue with the script you have in the fctOpenReqForm string - there are no "()" brackets after the function name. In general, when you do not have any server-side dependent info for a function, it is better to declare the function directly on the page or external script file. 

If you want to show the window from the server-side, you can either set VisibleOnPageLoad="true" for the RadWindow or use a script as explained in the articles below:

In any case, please keep an eye on the browser's console, as JavaScript errors can break the appearance and functionality of many controls.

Tags
Ajax Button ScriptManager and StyleSheetManager
Asked by
El Ghali
Top achievements
Rank 1
Answers by
Peter Milchev
Telerik team
Share this question
or