ASP.net scriptmanager and AJAX control - asp.net

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.

Related

AjaxControlToolkit & RequiredFieldValidator compatibility issue

I had a ASP.NET webpage with several text boxes (WebControls) with mandatory data entry. Hence, the text boxes have an associated RequiredFieldValidator & this form was working fine.
Recently, I had to add an additional textbox which accepts date as input. To enforce correct date format, I decided to associate this textbox to the CalendarExtender of the AjaxControlToolkit, so that on clicking the textbox a pop up calendar appears. After successful build of the project, when I navigate to the page an error message “Assembly AjaxControlToolkit does not contain a web resource with name jquery” is returned.
It was also observed that when I deleted all the text boxes & their associated RequiredFieldValidators the Form is working fine. That is when the textbox with CalendarExtender is clicked the Calendar appears without any problem.
It appears that AjaxControlToolkit (ToolkitScriptManager) & RequiredFieldValidator cannot co-exist on a web form. I am using Visual Studio Professional 2012.
Any suggestions ?. Thanks in advance.
Please follow the following steps:
Register Assembly, Namespace and TagPrefix
Than put ScriptManager
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
Try the following code for calendar popup:
<asp:TextBox ID="myTextBox" runat="server" CssClass="textBoxStyle" Width="282px">
</asp:TextBox>
<asp:ImageButton ID="myImg" runat="server" ImageUrl="~/myImage.png"/>
<cc1:CalendarExtender ID="calendarId" runat="server" PopupButtonID="myImg"
TargetControlID="myTextBox" Enabled="True">
</cc1:CalendarExtender>

Only one instance of a ScriptManager can be added to the page

"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...

An extender can't be in a different UpdatePanel than the control it extends asp.net

I am getting this error "An extender can't be in a different UpdatePanel than the control it extends". what could be the reason and how to tackle this problem.
You are using an AJAX ToolKit Extender Control to extend the functionality of one of your ASP.NET Controls. You have placed the Extender Control in a different UpdatePanel than the one the Extended Control resides in.
Both Extender and Extended controls must reside in the same UpdatePanel to avoid this exception.
Both Extender and Extended controls must reside in the same UpdatePanel to avoid the exception, this solved my problem.
I had an extra UpdatePanel that was giving this error, so I just had to remove the extra update panel lines of my aspx web page code.
What it says really - you've got an extender control that relates to a control that is in a different updatepanel. This means the extender is unable to act properly on the control it extends. You'll need to move your extender to be within the same updatepanel as the main control
In my case I was using button...outside the Update panel as below shown....
<asp:Button ID="btnClub" runat="server" Text="Club" OnClick="btnClub_Click" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
I just solved it by putting the <asp:Button ID="btnClub" runat="server" Text="Club" OnClick="btnClub_Click" /> inside the
update Panel
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="btnClub" runat="server" Text="Club" OnClick="btnClub_Click" />
Here you make your panel code
</ContentTemplate>
</asp:UpdatePanel>
Reason :Your iD is mis matching Ex:Text box id or dropdown id mismatch in Calender extender or RequiredFieldValidator
Ex:
Hear Id Value And Target Control Id Must Match .....
Check for controls with extenders that are have the same ID especially if you copy pasted from another form
Hi I got the solution of my problem by myself. The problem occurred when the target
control id of the extender control was different from the control it
had extend inside update panel. I resolved this proble a long time
back and replying now.

AjaxControlToolkit CalendarExtender Control not working in my website

I' using the AjaxControlToolkit CalendarExtender in my web site but after uploading it does how show the calendar control. I have registered the control on the page itself. The page postback when I click the image on which I applied the control.
What can be the reason of this?
Check whether you added ToolkitscriptManager in your page, which is in AjaxToolkit
If you are using an ImageButton to show the calendar,
then use ajax control toolkit and put these controls
<asp:ToolkitScriptManager runat="server" />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:ImageButton ID="ImageButton1" runat="server"
ImageUrl="calIcon.jpg" />
<asp:CalendarExtender ID="CalendarExtender1" TargetControlID="TextBox1"
PopupButtonID="ImageButton1" runat="server">
</asp:CalendarExtender>
If you are still getting the page postback when clicking the ImageButton, you can add onClientClick='return false;' to the imageButton
<asp:ImageButton ID="ImageButton1" runat="server"
ImageUrl="calIcon.jpg"
OnClientClick="return false;" />
Drag and place Script manager at top of the ajax control or at top of the form.
As you said that ajax calender works fine on local but when you uploaded it it started creating problems following are the workarounds give them a try.
Check that whether you uploaded the ajax toolkit dll on the server or not.
secondly make sure that you uploaded updated web.config file.
let me know if its helpful otherwise i will try finding other workarounds

unable to use ajaxcalender control with master page

I have created one simple aspx page using ajax calnder control-- page working fine
but i am creating a user control with ajax calender control and trying to use it with master page its not workng -- after click on button no popup apperring and page got post back,
I am not sure how it works in asp.net, but at MVC to enable calendar, simply add anywhere on the View
<form id="Form1" runat="server" >
<asp:ScriptManager ID="ScriptManager1" runat="server" EnableScriptLocalization="true" EnableScriptGlobalization="true">
</asp:ScriptManager>
</form>
HTH.

Resources