lazyPower
lazyPower

Reputation: 267

Duplicate Script Managers

I'm working on an ASP.Net webforms app, and I've run into a unique issue. There is a script manager for an update panel on the MasterPage, as well as a script manager in a sub-page calling the master page. This as i'm sure you will note cause an exception to be thrown and crash the webapp.

I've tried programatically excluding the scriptmanager + update panel from the code as follows:

<% If Not (Result.RawURL.Contains("ExcludedPageDirectory") Then %>
<!-- all that code goes here -->
<% End If%>

However I think just the presence of the script manager tag in the source is causing the error. How would I programatically handle this?

Upvotes: 1

Views: 288

Answers (3)

lazyPower
lazyPower

Reputation: 267

I ended up duplicating the master page and left out the update panel/scriptmanager code. This seems to have been the most elegant solution for the given situation. However I feel that the ScriptManagerProxy answer held the best possible solution had the duplication of the masterpage not been possible.

Upvotes: 0

Ta01
Ta01

Reputation: 31610

A page can contain only one ScriptManager control in its hierarchy. To register services and scripts for nested pages, user controls, or components when the parent page already has a ScriptManager control, use the ScriptManagerProxy control (Source: MSDN)

Upvotes: 3

Praneeth
Praneeth

Reputation: 2547

You don't require a script manager again in the page if you have it in the master page. Remove it and try

Upvotes: 0

Related Questions