Only one instance of a ScriptManager can be added to the page - asp.net

"Only one instance of a ScriptManager can be added to the page." this error appear when I added the script Manager to the password strength of AJAX toolkit.
i added the password strength beside the password field of my createuserwizard.
why this error would appear when this is the only scriptmanager that i had in my website?
here is the code:
<asp:TextBox runat="server" ID="Password" TextMode="Password" MaxLength="20" />
<asp:ScriptManager ID="ScriptManager2" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:PasswordStrength ID="Password_PasswordStrength" runat="server"
Enabled="True" TargetControlID="Password" DisplayPosition="RightSide"
StrengthIndicatorType="BarIndicator"
BarBorderCssClass="barBorder"
BarIndicatorCssClass="barInternal">
</asp:PasswordStrength>
<asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator10" ControlToValidate="Password"
ErrorMessage="Password is required." />
</ContentTemplate> </asp:UpdatePanel>
</td>
</tr>

Just remove this ScriptManager and it will work fine.
<asp:ScriptManager ID="ScriptManager2" runat="server">
</asp:ScriptManager>
You have definitely added a ScriptManager somewhere else in your Page or MasterPage.
ScriptManager Control Overview
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.

Maybe your Masterpage has a Scriptmanager too?
Check your whole aspx page hierarchy...

Related

ASP.NET update panel nested refreshing

This code is in a user control . and i am providing a sample code structure to get an overview .
<Update Panel UpdateMode= "Conditional">
<panel></panel>
<panel>
<button></button>
</panel>
<updatepanel UpdateMode="Conditional"></updatepanel>
</Updatepanel>
so when i click a button in the second panel , i am supposed to hide that panel and it is happening but simultaneously the other panels are getting refreshed . what could be the possible reason for that ?
Based on the code snippet you may have a couple issues to fix:
Make sure you have a ScriptManager on the page with EnablePartialRendering="true"
Correct your markup by making the <UpdatePanel> elements ASP.NET UpdatePanel controls by prefixing them with "asp:".
Add UpdateMode="Conditional" to both of your UpdatePanel controls
Move the sections you want to update asynchronously into the UpdatePanel controls.
Example
<asp:ScriptManager ID="MyScriptManager" EnablePartialRendering="true" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="MyUpdatePanel" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="This is a label!"></asp:Label>
<asp:Button ID="Button1" runat="server" Text="Click Me" />
</ContentTemplate>
</asp:UpdatePanel>
The following article is a great resource to learn more about the UpdatePanel with details on it's capabilities.
Understanding Partial Page Updates with ASP.NET AJAX

Calendar control without postback

I notice the calendar control in ASP.NET does not have an AutoPostBack property. I want that when I select a date from the control, the control must not post back the page. How do I do that?and one thing more when i hover over on the calender it shows me a script. "javascript:__doPostBack('Calendar2','5098')". So my question is how to disable this javascript to don't postback the values
There is no way to turn off the postbacks to the server but you can use updatepanel control which can help you some what.
According to PLBlum at the ASP.NET forums:
The Calendar control included with ASP.NET uses postbacks only. If you
added Microsoft ASP.NET AJAX to the page and put the calendar into an
UpdatePanel, it can reduce the appearance of postbacks by using
callbacks. But it still makes a trip to the server for each click on a
date or month.
Many people have created replacements to the Calendar control that
uses javascript to do the work. I am the author of one, in "Peter's
Date Package". You can locate others in these sites: the Control
Gallery (here under Resources), www.123aspx.com, and www.411asp.net.
You can add like following
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Calendar ID="ad_Cal" runat="server" OnSelectionChanged="ad_Cal_SelectionChanged" ></asp:Calendar>
<asp:Button ID="btn_Del_Day" runat ="server" Text ="Remove Day" OnClick="btn_Del_Day_Click" UseSubmitBehavior="False" BackColor="#4AA3DF" Font-Bold="True" ForeColor="White" />
<asp:Button ID="btn_sort_Date" runat="server" Text="Sort Days" UseSubmitBehavior="False" BackColor="#4AA3DF" Font-Bold="True" ForeColor="White" OnClick="btn_sort_Date_Click" />
<asp:ListBox ID="lst_ad_dates" runat="server"></asp:ListBox>
</ContentTemplate>
</asp:UpdatePanel>
notice that you should use UseSubmitBehavior="False" with buttons also to stop postback for buttons in the same updatePanel
It works fine
I think you can use "CalendarExtender" from AjaxToolkit
<asp:TextBox ID="txtCalendarExtender" runat="server"></asp:TextBox>
<cc3:CalendarExtender ID="Calendar1" PopupButtonID="imgPopup" runat="server" TargetControlID="txtCalendarExtender" Format="dd/MM/yyyy">
</cc3:CalendarExtender>
Remember to add this code at the top of your page:
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc3" %>

ScriptManager required even though it is present

i am getting following error when i am running AJAX enabled ASP.Net application
The control with ID 'FilteredTextBoxExtender1' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.
even though i have ScriptManager in my page
what wrong i am doing please give suggestions
thanks in advance
<form id="form1" runat="server">
<asp:scriptmanager id="ScriptManager1" runat="server" />
<div>
<cc1:filteredtextboxextender id="FilteredTextBoxExtender1" targetcontrolid="textbox1"
filtertype="Numbers" runat="server"> </cc1:filteredtextboxextender>
<asp:textbox id="TextBox1" runat="server"></asp:textbox>
</div>
</form>
What version of the toolkit? With recent versions at the time of writing, you need to use toolkitscriptmanager instead of the "normal" scriptmanager.
Place ScriptManager right before UpdatePanel

Checkbox inside user control in repeater doesn't fire

I have user control inside a page with single repeater. The problem is when this control is placed inside repeater check box doesn't fire CheckedChanged event. If this would be a dynamically added control I would check whether CheckedCanged event has a handle assigned in Init() but here the event is specified in ascx so I imagine asp.net is responsible for doing all the assignments in right place. I'm lost here :/
By the way. Placing single checkbox inside repeater doesn't fire to. But I can at least use OnItemCommand there
User Control
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="QuoteContainer.ascx.cs" Inherits="EhdSite.Controls.QuoteContainer" %>
<asp:TableRow runat="server" ID="trQuoteRow">
<asp:CheckBox runat="server" ID="cbxConfirm" AutoPostBack="true" OnCheckedChanged="CbxConfirmCheckedChanged" />
</asp:TableRow>
Page
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager2" runat="server" />
<asp:UpdatePanel runat="server" ID="upQuotes" UpdateMode="Conditional" ChildrenAsTriggers="false">
<ContentTemplate>
<asp:Repeater runat="server" ID="rptQuotes">
<ItemTemplate>
<ehd:QuoteContainer
runat="server"
ID="qcQuote"
RowCssClass="rowStyle"
HighlightedRowCssClass="selectedRowStyle"
Quote="<%# Container.DataItem %>"
OnQuoteSelectedChanged="QuoteSelectedChanged" />
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
It has to do with the event-chain in ASP.Net, this MSDN page helps to understand it.
The .Net framework resolves the ViewState between the Init- and the Load-event. So if the control is not there after the Init-event, it's ViewState will never be loaded and also it's events will never be fired.
This can get quite tricky at times, especially if one dynamically loaded control should affect the loading of another one...

ASP.net scriptmanager and AJAX control

im making a username availability check in ASP.net using ajax updatepanel, but i keep getting the following error
The control with ID 'UserNameUP' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.]
im using the create user wizard, to create a new user but i want to check if the user already exists, i have the following code in the aspx file
<asp:UpdatePanel runat="server" ID="UserNameUP">
<ContentTemplate>
<asp:TextBox ID="UserName" runat="server" Width="200px" AutoPostBack="true" OnTextChanged="Username_Changed"></asp:TextBox></ContentTemplate> </asp:UpdatePanel><br />
but i keep getting that error, can any one help
thanks
Before your update panel, make sure you have a scriptmanager:
<asp:ScriptManager id="ScriptManager1" runat="server">
</asp:ScriptManager>
Do you have a script manager inside a master page? That can cause the "Only one instance of a ScriptManager can be added to the page" error?
Or, if its DNN, there is one on each "page" by default.

Resources