AjaxToolKit CalendarExtender 问题
在“摘要”页面中,我有两个 CalendarExtender 控件,使用户能够选择数据库查询的“开始日期”和“结束日期”。
在我的 Summary.aspx 页面的头部,我有以下声明:
<%@ 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"%>
对于页面本身,我有一个 ToolkitScriptManager
、两 (2) 个 TextBox
控件、两个 CalendarExtender
控件和 GridView
控件:
<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" />
在 C# 代码的 Page_Load
事件中,我放置了以下内容:
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;
}
}
那么,为什么我的日历控件不在职的?日历中没有值,并且语言似乎是西班牙语。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需在 ScriptManager 中添加 EnableScriptGlobalization="true" 即可,如下所示:
Just add EnableScriptGlobalization="true" in your ScriptManager like this:
您的语言是西班牙语,我相信是这样,因为您的
UICulture
是UICulture="es"
(ESPañol) 和Culture="es-MX"
(西班牙语墨西哥)。在您的标记上看到这一行:
您的标记的其余部分对我来说看起来不错。
Your language is Spanish and I believe it's so because your
UICulture
isUICulture="es"
(ESpañol) andCulture="es-MX"
(Español México).See this line on your markup:
The rest of your markup looks okay to me.