Search code examples
c#ajaxcontroltoolkitcalendarextender

AjaxToolKit CalendarExtender Problems


In my Summary page, I have two CalendarExtender controls to enable someone to select Start Date and End Date for database queries.

In the head of my Summary.aspx page, I have the following declarations:

<%@ MasterType VirtualPath="~/Site.Master" %>
<%@ Page Title="ACP Sheet Metal - Summary" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Summary.aspx.cs" Inherits="AcpSheetMetal.Summary" UICulture="es" Culture="es-MX" %>
<% @Import Namespace="System.Globalization" %>
<%@ Register TagPrefix="asp" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit"%>

For the page itself, I have a ToolkitScriptManager, two (2) TextBox controls, two CalendarExtender controls, and a GridView control:

<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager2" runat="server" EnableScriptGlobalization="true" EnableScriptLocalization="true" />
<asp:TextBox ID="txtStartDate" runat="server" />
<asp:CalendarExtender ID="calExStartDate" runat="server" TargetControlID="txtStartDate" OnClientShown="ChangeCalendarView" OnClientDateSelectionChanged="checkDate" />
<asp:TextBox ID="txtEndDate" runat="server" />
<asp:CalendarExtender ID="calExEndDate" runat="server" TargetControlID="txtEndDate" OnClientShown="ChangeCalendarView" OnClientDateSelectionChanged="checkDate" DaysModeTitleFormat="MM/dd/yyyy" DefaultView="Months" Enabled="True" TodaysDateFormat="MMMM dd, yyyy" />
<asp:GridView ID="summaryGridView" runat="server" />

In the Page_Load event in the C# code, I have placed the following:

protected void Page_Load(object sender, EventArgs e) {
  MasterPage = (SiteMaster)Page.Master;
  if (!Page.IsPostBack) {
    calExEndDate.TodaysDateFormat = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;
    calExStartDate.TodaysDateFormat = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;
  }
}

So, why are my Calendar controls not working? There are no values in the calendars and the language appears to be Spanish.

enter image description here


Solution

  • Your language is Spanish and I believe it's so because your UICulture is UICulture="es" (ESpañol) and Culture="es-MX" (Español México).

    See this line on your markup:

    <%@ Page Title="ACP Sheet Metal - Summary" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Summary.aspx.cs" Inherits="AcpSheetMetal.Summary" UICulture="es" Culture="es-MX" %>
    

    The rest of your markup looks okay to me.