English 中文(简体)
GMDatePicker 形式问题
原标题:GMDatePicker Format problem

I m 采用GM 的日期是Picker。 我的法典如下:

<cc1:GMDatePicker ID="DatePicker" AutoPosition="false" runat="server" CalendarTheme="Blue"
Style="z-index: 252; left: 0px; position: absolute; top: 0px" DateFormat="dd/MM/yyyy"
TodayButtonText="">

我在前面提到的日期格式。 但是,它没有采用这种格式。 它只是以这种形式进行。 当我节省费用时,它正值此日期。 如果以MM/dd/YYYY格式提供,则计算准确的日期价值。

如何解决这一问题?

最佳回答

在从案文箱读到日期时,不考虑日期格式价值时,这种控制在财产获得方法的日期有点。 这里有一个确切的“日期财产”方法,可以例外:

 DateTime time = DateTime.Parse(this.dateTextBox.Text, this.Culture);

你重新获得目前日期的原因是,如果发生这种情形,所有例外情况的管制点都是目前的日期。

因此,除了寻找另一种控制或要求供应商确定这种控制之外,你做了些什么。 工作将是在没有使用控制文本箱的情况下直接从控制文本箱获得日期。 财产通过思考和分配。 下面是你如何做到这一点的一个例子:

TextBox textBox = (TextBox)DatePicker.GetType().InvokeMember("dateTextBox",
    BindingFlags.GetField | BindingFlags.Instance | BindingFlags.NonPublic,
    null, DatePicker, null);
if (textBox != null)
{
    DateTimeFormatInfo format = (new CultureInfo(DatePicker.Culture.Name)).DateTimeFormat;
    format.ShortDatePattern = DatePicker.DateFormat;
    DateTime date = DateTime.Parse(textBox.Text, format);
    Console.WriteLine(date.ToString());
}

希望这一帮助,

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签