Multiple instances of a ScriptManager - asp.net

I have a master page and hundreds of content pages. Every content page contains ToolKitScript Manager for every UpdatePanels on each content page. Right now, I want to add Script Manager on the master page and when I try to execute, error shows "Only one instance of a ScriptManager can be added to the page." So I comment/remove every ToolKitScript line on each content page. What I want to ask, is there any solution so I don't have to comment/remove every single line of code on my hundreds of content page?
Here is the following code on every single content pages which I have to remove one by one.
<AjaxControl:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></AjaxControl:ToolkitScriptManager>
Here is the following code on my master page which I have to add.
<asp:ScriptManager ID="scriptManagerNotif" runat="server" >
<Scripts>
<asp:ScriptReference Path="~/js/jquery-1.2.6.js" />
</Scripts>
</asp:ScriptManager>

You could only have one ScriptManager and ToolkitScriptManager comes with Ajax tool kit, which is a later version of ScriptManager. therefore if you use ToolkitScriptManager instead of the ScriptManager in your Master page it should work fine. You don't need ToolkitScriptManager in each content page then.

Related

Why does my MasterPage UpdatePanel call a Page_Load on my ContentPage?

My code in my MasterPage is causing a full page_load on my content pages every 5 seconds. Sadly, that means it is breaking some of my content pages and how they are programmed. My hope was that a separate UpdatePanel would allow only that region to be updated and not refresh the other UpdatePanels and resources on the content pages.
I've attempted moving the Timer out of the UpdatePanel, changing the UpdatePanel to UpdateMode="Conditional" and even using a third party AjaxPanel (Telerik).
All results are the same, the content page reloads every 5 seconds clearing the title template (Shown below) and sometimes breaking some functions on the site.
Until I can figure out a way to ONLY have the literal update without reloading the other resources I have to leave the Timer disabled.
I'll be happy to post more code if needed, but I didn't want to provide information that may not have any importance.
MasterPage - Site.Master
<title><%: Page.Title %> - My ASP.Net Site</title>
<asp:UpdatePanel ID="UpdatePanelMenu" runat="server">
<ContentTemplate>
<span>Tickets<asp:Literal ID="LiteralUnassignedTickets" runat="server"></asp:Literal></span>
<asp:Timer ID="TimerAutoRefreshMenu" runat="server" Interval="5000" Enabled="true"></asp:Timer>
</ContentTemplate>
</asp:UpdatePanel>
if you have to use update panels make the update panel update conditional and set the timer as an asynchronous trigger(very important).
update panels are even worse when they are on master pages then when they are on the content page
a better option for minimal change is setTimeout to a function that does an ajax call to update the number of unassigned tickets. you can grow this to update a whole bunch of fields/elements using a json object. Plus the techniques can be very useful if you move to MVC.

enablepagemethods in ajaxcontroltoolkit

Hi I'm using in my application with ASP.NET WebForms and VB.NET (code behind) the ajaxcontroltoolkit so, i need use enable a page method but if I add
< asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="True" EnablePageMethods="True" > < /asp:ScriptManager >
to the code this mark error:
You can only add one instance of ScriptManager to the page.
My question is in ajaxcontroltoolkit exist a function equal to EnablePageMethods of ScriptManager?
It may likely that you would have definitely added a ScriptManager somewhere else in your .aspx Page or MasterPage or UserControl.
If you have declared a ScriptManager on your Master page, then in your content pages you would use a ScriptManagerProxy. This will act as a proxy to the real ScriptManager on your master page.
Here is the MSDN link that describes about ScriptManagerProxy
Only one instance of the ScriptManager control can be added to the page. The page can include the control directly, or indirectly inside a nested component such as a user control, content page for a master page, or nested master page. If a page already contains a ScriptManager control, but a nested or parent component needs additional features of the ScriptManager control, the component can include a ScriptManagerProxy control. For example, the ScriptManagerProxy control enables you to add scripts and services that are specific to nested components.
Ensure that you have only one asp:Scriptmanager on the
masterpage.
If you don't need a asp:Scriptmanager in materpage then remove it and declare it in content pages whichever needs it.
If you have a ScriptManager in masterpage then make sure you also have only one
asp:ScriptManagerProxy on every content page that might require a script manager.

How to use AJAX in master page when content pages have ScriptManager?

In my ASP.NET 3.5 project, most content pages have ScriptManager control but the Master Page does not have. I now want to use UpdatePanel in the master page but it is not permitting to put another ScriptManager.
I cannot change to ScriptManagerProxy in content pages as the change needs to be replicated to around fifty pages.
Is there any way to use UpdatePanel in Master Page by either sharing content page's ScriptManager or something else?
three ways I can think.
First way is to use place the ScriptManager inside the ContentPlaceHolder, on the other pages that also have ScriptManager this will be overwrite, in the one that you want to exist, just not use this ContentPlaceHolder, if this is possible.
<asp:ContentPlaceHolder ID="PlaceHolderID" runat="server" >
<asp:ScriptManager ID="ScrMang" runat="server" >
</asp:ScriptManager>
</asp:ContentPlaceHolder>
Second way is to make a second master page, come from the first, and use this second master page with ScriptManager and all the rest, if this is possible.
And last, change all 50 pages, move the ScriptManager to master page, remove it from the rest. Some time we do that :)

ASP.NET Master Page not updating Child Page

I have made a site that is based off of a MasterPage and after creating a few pages I added a new <asp:ContentPlaceHolder> but it seems the existing pages wont update to include it, however new pages do.
Is there a way to force an update, or is there a proper way to do this? I just saved the Master Page and hoped for the best.
You need to add the new <asp:ContentPlaceHolder> to your old aspx pages manually.
in your master page:
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
<asp:ContentPlaceHolder ID="new_one" runat="server"></asp:ContentPlaceHolder>
in your old aspx pages, add:
<asp:Content ID="Content3" ContentPlaceHolderID="new_one" runat="server">
</asp:Content>
If you create a new content placeholder in your master page, your content pages don't NEED to have a corresponding <asp:Content>. They only need one if you want to replace the default content placed in the master page.
And if you're going to update each page with its own content, then adding the <asp:Content> tags is likely a relatively small inconvenience.
Unfortunately there is not a way for Visual Studio to search out all your content pages and update them with new <asp:Content> controls.
However, you could do it fairly quickly by finding using the id of an existing <asp:Content> control, and do a ctrl+shift+F and replace with your new <asp:Content> plus what you searched for.
For example, if your content pages already all had a
<asp:Content ID="Content3" ContentPlaceHolderID="old_one" ... />
then you could search for that and replace with
<asp:Content ID="Content4" ContentPlaceHolderID="new_one" runat="server" /><asp:Content ID="Content3" ContentPlaceHolderID="old_one" ... />
Not exactly pretty, but it could save some time.

What is the best way to include content within an AJAX TabContainer?

I didn't want to have a ton of code on one page, but to keep the code modular and simple. So in my TabContainer I have the following where each tab refers to a web page and my code is inside each web page. My TabContainer itself is inside the default.aspx page.
<asp:TabContainer ID="tabTOL" runat="server" ActiveTabIndex="0" CssClass="tol">
<asp:TabPanel ID="tabHome" runat="server" TabIndex="0" HeaderText="Home">
<ContentTemplate>
<iframe src="Home.aspx"></iframe>
</ContentTemplate>
</asp:TabPanel>
...
Of course, the problem is that I cannot refer to other tabs or the TabContainer/default page from within any tab. I'm trying to update a TextBox on the default.aspx page from a tab, but there is no reference to it.
Should I bite the bullet and have one huge web page with all the html and code behind? There are a dozen tabs in my TabContainer. I would think this would slow down processing as well. Or, is there a cleaner way to do this and still retain the ability to reference controls on the main page or other tabs?
I'm working in VS2008 and .Net 3.5 and AJAX 3.5.
Thanks!!
Larry
I would suggest that you change the structure of Home.Aspx into a Web User Control (*.ascx). The advantage is that you are now running within the context of the parent page. Therefore all it's functionality is within reach. For example, to acces a textbox on the parent page, from the Home.Ascx, you would do this:
((Default)this.Parent).txtMyTextBox.Text = "Hello";

Resources