views:

313

answers:

3

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?)

A: 

Make sure to put the texbox and extender in an UpdatePanel (I don't see this in the code you provided).

o6tech
Thanks! That solved the problem. However I haven't seen any documentation saying that I had to put the extender inside an UpdatePanel to make it work... (the example page for CalendarExtender on Microsoft's site doesn't say anything about UpdatePanel)
logain
Update - didn't work. After adding the UpdatePanel the value immediately reverts so the initial value and refuses to left me change.
logain
A: 

I'm running into the same issue. Logain - have you found a solution for this yet? The UpdatePanel doesn't seem to be working for me either...

nimarii
Unfortunately, no-one seems to have any idea... I guess the best bet would be to keep waiting and hope someone comes along.
logain
A: 

Guys, I'm running into the same problem. I did try putting the Extender and the TextBox within an UpdatePanel but it didn't solve the issue. and I guess that is not the solution in the first place. I say this because, I put the same markup on a different page with and without UpdatePanels and it works absolutely fine.

My findings so far compel me to state that this kind of behaviour (rather mis-behaviour :)) is primarily due to some kind of mess within the markup. In some cases it could be binding error.

Still working would update as soon as I get something.

Noman Siddiqui