For some reason, any CalendarExtenders on an ASP.NET site that is being worked on will not be updated. I have already checked all the obvious places (such as AutoPostBack and AutoEventHandler). The problem is that when I select a date from the Calendar and post it to the form, the TextBox that is being extended IS being updated, but the calendar extender's date is simply not being being updated (e.g. SelectedDate is still the same as before). I have googled for any possible solutions but none have worked.
Here is the code:
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master"
AutoEventWireup="true" CodeBehind="ThePage.aspx.cs" Inherits="ThePage" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:TextBox runat="server" ID="txtBlah" />
<asp:CalendarExtender ID="txtBlahExtender" runat="server" TargetControlID="txtBlah" Format="MMMM d, yyyy" />
<asp:Button runat="server" ID="btnSubmit" CausesValidation="false" />
and the codebehind:
public partial class ThePage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
txtBlahExtender.SelectedDate = DateTime.Today.AddDays(4);
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
//do postback actions
}
}
}
When my code reaches "do postback actions", txtBlahExtender.SelectedDate is ALWAYS DateTime.Today.AddDays(4). It simply doesn't register the change.
Any ideas?
Thanks, Logain Smith
(Is it possible to do formatting on a question?)