.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Set Calendar Extender's SelectedDate="<%=DateTime%>"

Posted By:      Posted Date: October 05, 2010    Points: 0   Category :ASP.Net

Hi.  How do you set an AJAX Calendar Extender's SelectedDate property equal to the current date, using HTML?  I've tried this:


But it generates the runtime error ""Parser Error Message: Cannot create an object of type 'System.Nullable`1[[System.DateTime, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' from its string representation '<%=DateTime%>' for the 'SelectedDate' property.


Is it possible to set this property in HTML without writing code?


View Complete Post

More Related Resource Links

calendar extender


i want to put date into 2 combo box

combo1 = date, and combo2= month

can you help me?

MaterPage Ajax calendar extender not working


AJAX with MasterPage not working.

Setup simple test site below, no error just not working. TIA

    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">

<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="ajaxDev.WebForm1" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
  <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
  <asp:CalendarExtender ID="TextBox1_CalendarExtender" runat="server" 
    Enabled="True" TargetCo

Problem with Ajax calendar extender visibility

sir i am using ajax calender extender in textbox below this textbox i am using a panel there is a gridview that show data.problem is when i click the textbox half of the calender id hiden behind the panel how to solve this problem. 

Ajax Calendar Extender Question (about disable pass date)

HiI am wondering if it has anyway to disable the past day on the Ajax Calendar Control, previously, when we use CalendarExtender, we need to put a asp:Calendar and a textbox. we can use FindControl to find the calendar control and disable the past days.I am wondering is there anyway  could do the same stuff?Another question is how could I read the user selected date to the Date variable?Do i need to convert the date from the TargetControl ? E.g. Convert.ToDateTime(txt_DATE.text) ?Please let me know if you want me to explain more.Many thanksChi 

Ajax Calendar Extender Within Gridview

I'm tasked with creating an editable gridview which contains several columns for input including a Start Date and End Date column. All columns are created dynamically at runtime based on a user's selection in a dropdown list. I would like to have an Ajax Calendar Extender attached to all text boxes in the Start and End Date Columns but since the table is made dynamically I need to add it in code behind. Most examples I've seen add ajax calendars to a gridview using template columns but i can not do this in my case. The following is my handling of the rowdatabound event - How do i edit this to attach a calendar extender to columns 1 and 2?1 protected void GridView1_RowDataBound(Object sender, GridViewRowEventArgs e) 2 { 3 TextBox txt; 4 if (e.Row.RowType == DataControlRowType.DataRow) 5 { 6 for(int i = 0; i < e.Row.Cells.Count; i++) 7 { 8 for (int j = 0; j < e.Row.Cells[i].Controls.Count; j++) 9 { 10 if (e.Row.Cells[i].Controls[j] is TextBox) 11 { 12 txt = (TextBox)e.Row.Cells[i].Controls[j]; 13 if (txt != null && Page.IsPostBack) 14 { 15 txt.Text = Request.Form[txt.UniqueID]; 16

Calendar Extender is not working in IE7 after Postback

We have implemented ajaxtoolkit version: 3.5.40412.0, and my web application is not AJAX enabled. We have included ajaxtoolkit binary reference in our web application. In one of the page, calendar extendar is working fine when it rendar first, after postback it's not working at all in IE7, but it's working fine in Mozilla. The sample code is as below, [ We are not getting any javascript or HTML tag error ]   <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %><asp:Content ID="MyTest" ContentPlaceHolderID="MainContentPlaceHolder" runat="server"><ajaxToolkit:ToolkitScriptManager id="ScriptManager1" runat="server"/><table><td><asp:TextBox ID="txtDate" TabIndex="8" runat="server" Width="144px"></asp:TextBox><ajaxToolkit:CalendarExtender ID="calDate" Format="MM/dd/yyyy" runat="server" TargetControlID="txtDate" PopupPosition="BottomRight" /><asp:RangeValidator ID="DateRangeValidator" runat="server" Display="None" EnableClientScript="false" ControlToValidate="txtDate" ErrorMessage="Selected date is not within range." Type="Date" /><

Calendar Extender Not working

Ok, I have done this before but for the life of me I can not figure out why this is not working. I am trying to use a calendar extender on a field in Formview Insert. The page will load fine but no calendar. Advise? Thank You <%@ Page Language="VB" MasterPageFile="~/buildingpermit.master" AutoEventWireup="false" CodeFile="request_inspection.aspx.vb" Inherits="request_inspection" title="Untitled Page" %> <%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %> <%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> <style type="text/css"> .style13 { width: 100%; } .style14 { background-color: #003300; } .style15 { width: 196px; color: #FFFFCC; background-color: #003300; } .style16 { color: #FFFFCC; } .style17 { text-align: left; color: #FFFFCC; background-color: #003300; } </style> </asp:Content> <asp:

How to display the date only till current date in ajax calendar extender .

Hi,1) How can i display the date only till current date in ajax calendar extender ?2)How to validate the date in one TextBox with the Date in another TextBox ?    Please Help me ...

Adding functionality to the Toolkit Calendar Extender

Folks, I have not yet done a deep dive into the Toolkit code.  I need to try and make a couple of changes to the Calendar. The first one feels like an "it can't only be me that needs this" problem.  I have EarliestDate and LatestDate parameters floating around.  The requirement is to prevent the user clicking (ie they display as text rather than hyperlinks) any dates which fall outside of the two date limits.  An extension of that (not essential, more of a luxury) would be to prevent the user moving to months or years where the dates within that month/year are completely outside of the allowable range. The second one relates to when the initial view of the Calendar is Years.  I need to either be able to specify that the initial display starts for a given historical year (without showing that year in the textbox); or [better] to be able to squeeze a larger number of years onto the display, so that the user can move back a greater number of years with fewer clicks. I hope the questions make sense - all pointers welcome. Thanks,  Nick.

Calendar extender doesn't work

I have an as-simple-as-possible implementation of the Calendar extender; and when I click the text box, nothing happens.<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <%@ Register TagPrefix="Ajax" Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="scriptManager1" runat="server"></asp:ScriptManager> <asp:TextBox ID="txtBeginDate" runat="server" ></asp:TextBox> <Ajax:CalendarExtender TargetControlID="txtBeginDate" runat="server" ID="CE1"></Ajax:CalendarExtender> </div> </form> </body> </html> I have referenced the AjaxControlToolkit.dll; I know that's working because I get auto-complete on "<Ajax:"Also the rendered page does have<script type="text/javascri

Ajax Calendar extender tool -How to disable cells?



I am using an Ajax Calendar Extender  tool in my application.I do wanna disable the past days calendar cells so that the user wont be able to click or select those cells .Can anybody help me ??


i wanna like.....
1. http://air.irctc.co.in



Calendar control - disable dates? (calendar extender)


Hi there,

Does anyone know if it is possible to disable some of the dates available for selection.  For example, on opening the calendar all the dates before today are grayed out so that it is only possible to select dates in the future.

On my site I am using two calendar controls which are representing a start date of an event and an end date.  In the end date calendar I would like to disable all dates before the selected start date.

Is anything like this possible with the calendar control?

Thanks for your help,

Open Calendar Extender on Focus


OK, I'm trying to get the Calendar Extender to open / show the calendar on focus.  It works fine if I click on the text box, but when the user selects an option from a drop down list I'm tring to enable the text box and calendar extender and set focus after the page_load.  For exmple see below:

        If Session("Status") = 3 And Session("Closed") = False Then
        End if

The problem is if I put a break point on the Page_LoadComplete then hit F5 to continue it works fine, but If I run it without stopping for my break point it sets focus (puts the cursor) in the text box but doesn't open the calendar.  How can I  set focus and have the calendar open automaticlly?

Is there some way to simulate a click event on a text box after the page_loadComplete?


ajax calendar extender problem


I have a problem with Ajax calendar extender (version 3.5).
What i do is post from a form to the specific form and i have a textbox an image
and the cal extender.
When the page i post to is loading i get an error on

Sys.Application.add_init(function() {
    $create(Sys.Extended.UI.CalendarBehavior, {"button":$get("Image1"),"id":"CalendarExtender1"}, null, null, $get("YearsTextBox"));

The error is
Microsoft JScript runtime error: 'Sys.Extended.UI' is null or not an object

Here is my markup:
<asp:TextBox ID="YearsTextBox" runat="server" ReadOnly="true"
            style="z-index: 1; left: 167px; top: 113px; position: absolute"></asp:TextBox><asp:Image ID="Image1" runat="server" ImageUrl="images/calendar17189.GIF" height="16" width="16"
             style="z-index: 1; left: 330px; top: 113px; position: absolute" />
        <asp:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="YearsTextBox" PopupButtonID="Image1">

Now the image picture is showing

datetime conversions (en-GB) (en-US) giving errors using calendar extended textbox


I have a site which is in en-GB culture (cannot be changed) and provides dates via a textbox with a calendar extender in this format  DD/MM/YYYY. This then populates an sqlparameter

The db server is in en-US and expects dates in this format:  YYYY-MM-DD 00:00:00.000

I have tried many many different methods to get this converted, ready to submit to db but am being presented with errors. Please can you show me the necessary syntax?



Calendar Extender Hijacks Submit Functionality


I have the typical date text box and I added the AJAX.NET Toolkit Calendar Extender to this text box.  However, whenever the user presses the enter key, instead of the page being submitted the calendar control gets displayed.

If I remove the calendar extender the enter button works like it should (the page gets submitted).

What is going on and can I get my enter key submit functionality back?

Can't get SelectedDate before SelectionChanged Event @ WebControls.Calendar



I'm currently working with the View-ViewModel pattern. In addition to that I composed a base page:

public abstract class BasePage : Page
protected override void OnLoad(EventArgs e)
if (IsPostBack)

protected override void OnPreRender(EventArgs e)

protected abstract void PushLayout();
protected abstract void PullLayout();

The intention: On every page call the PullLayout() fetches all necessary data from the ViewModel object behind and updates the controls (textboxes, listboxes, etc.). After changing and submitting the the data PushLayout() writes everything back! All I have to do now is implementing these two methods for each concrete page and handle some further server control events, if any.

An example (assume ViewModel is the backend object):

public class TestPage : BasePage
protected override void PushLayout()
ViewModel.SelectedBoxItem =

protected overrid
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend