AjaxControlToolkit CalendarExtender Control not working in my website - asp.net

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

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>

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

Calendar control is not popping-up when clicked on image

I'm using a CalendarExtender control with the help of <img> to populate a TextBox with a date. I am using this in EditItemTemplate of GridView. But when I click on the image, the calendar control is not poping up.
I have used this CalendarExtender control in four or five other places (in this project) also. Everywhere else it is working fine. I have compared the code from the well working version to this code. No difference at all.
I have written the code like below:
<EditItemTemplate>
<asp:TextBox ID="txtDateDelivered" runat="server"
Text='<%# Bind("DateDelivered","{0:dd/MM/yy}") %>'
CssClass="DateTextBoxInGridView" >
</asp:TextBox>
<asp:CalendarExtender ID="calexDateDelivered" runat="server"
Format="dd/MM/yy"
TargetControlID="txtDateDelivered"
PopupButtonID="calDateDelivered">
</asp:CalendarExtender>
<img src="Images/calendar.gif"
id="calDateDelivered"
alt="Calendar" />
</EditItemTemplate>
Can anybody please tell where could be the problem?
how many row do you have in grid? also probably you have more than one image with such id
The image tag which you have used is not a server control.
It is simple html control, this is the reason why the calender control does not reconise this image control..
Try using asp.net image button over here instead of .
It should work then.
cheers....
Rahul C.

ASP.NET - Ajax Control Toolkit - TabContainer always hidden

I used the following code to add TabContainer to page
<asp:TabContainer ID="TabContainer1" runat="server">
<asp:TabPanel runat="server" HeaderText="tab one" ID="TabPanel0">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel runat="server" HeaderText="tab two" ID="TabPanel1">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Button" />
</ContentTemplate>
</asp:TabPanel>
</asp:TabContainer>
but when the page is rendered TabPanel is always Hidden,I wateched the html code by Firebug and found visibility is hidden... what is the problem?
http://i.stack.imgur.com/m1eSW.jpg
Have you tried to set the ActiveTab-Property(from codebehind) or the ActiveTabIndex from codebehind or aspx?
You could also check if it works if you explicitly set the display to visible:
ActiveTabIndex="0" style="display:block;visibility:visible;"
Are you sure that the Ajax libraries are loaded correctly? Do you have other Ajax-Controls inside of your TabContainer? Check if all of your html in that page is valid.
Are you using the latest AjaxToolkit and the ToolkitScriptManager instead of the ScriptManger?
You need to use the Script Manager from the Ajax Control Toolkit, add it after the form tag.
i had the same issue and after 2 hours of googling i found a solution. In my case I had to change asp:ScriptManager to ajaxToolkit:ToolkitScriptManager.
You may want check that you have used ToolkitScriptManager instead of ScriptManager. This will solve your problem.
We've solved this problem at our company, after trying everything found on websites by changing the website's appPool from Classic to Integrated.
In my case: The active tab was hidden (server side: Visible="false").
It seems if you activate in server side a hidden tab, it'll add visibilty:hidden to the tabcontainer!
Try setting ActiveTabIndex="0" on the TabContainer

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