MVC 3模板编辑器日期时间带 [英] MVC 3 Editor Template with DateTime

查看:90
本文介绍了MVC 3模板编辑器日期时间带的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想改变这个MVC2 code

 <%@控制语言=C#继承=System.Web.Mvc.ViewUserControl<&System.DateTime的GT;? %GT;  <%= Html.TextBox(?(Model.HasValue Model.Value.ToShortDateString()的String.Empty),新{@class =日期选择器})%GT;

要MVC 3使用剃刀。

您可以找到完整的帖子是我想要做的<一个href=\"http://geekswithblogs.net/michelotti/archive/2010/02/05/mvc-2-editor-template-with-datetime.aspx\">here


解决方案

  @model日期时间?@ Html.TextBox(,(Model.HasValue Model.Value.ToShortDateString():的String.Empty),新{@class =日期选择器})

I want to change this code from MVC2

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.DateTime?>" %>

  <%=Html.TextBox("", (Model.HasValue ? Model.Value.ToShortDateString() : string.Empty), new { @class = "datePicker" }) %>

To MVC 3 using Razor.

You can find the full post of what I want to do here

解决方案

@model DateTime?

@Html.TextBox("", (Model.HasValue ? Model.Value.ToShortDateString() : string.Empty), new { @class = "datePicker" })

这篇关于MVC 3模板编辑器日期时间带的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆