2012-03-15 8 views
0

Umbracoについては初心者です。とても簡単なテンプレートを設定しようとしています。Umbraco 5で日付フィールドをレンダリングする

私はUmbraco 5を使用しており、ドキュメントタイプを作成し、 'Date'プロパティを追加しました。そのプロパティはDate Time Picker型のものです。

は、私は、テンプレートを作成し、私は上記のドキュメントタイプに基づいてコンテンツアイテムをプレビューする場合、すなわち@Umbraco.Field("Date")

は、型のオブジェクトをキャストすること

できません。次のエラーを取得するumbracoページフィールドを挿入しました'System.DateTimeOffset'を入力して 'System.String'と入力します。

スタックトレース:

[InvalidCastExceptionが: '可能System.String' を入力するタイプ 'System.DateTimeOffset' のオブジェクトをキャストすることができません]
Umbraco.Cms.Web.FieldRenderer.RenderField(IRoutableRequestContext routableRequestContext 、controllerContext controllerContext、コンテンツ 項目、文字列fieldAlias、文字valueAlias、文字列altFieldAlias、 文字列altValueAlias、文字列でalttext、文字列のinsertBefore、文字列 insertAfter、ブール再帰、ブールconvertLineBreaks、ブール removeParagraphTags、UmbracoRenderItemCaseTypeケーシング、 UmbracoRenderItemEncodingTypeエンコード)464
Umbraco.Cms.Web.UmbracoHelper.Field(コンテンツcurrentPageに、文字列 fieldAlias、文字valueAlias、文字altFieldAlias、列 altValueAlias、文字列でalttext、列のinsertBefore、列 insertAfter、ブール再帰ブールconvertLineBreaks、ブール removeParagraphTags、UmbracoRenderItemCaseTypeケーシング、 UmbracoRenderItemEncodingTypeエンコード)187
Umbraco.Cms.Web.UmbracoHelper.Field(文字列fieldAlias、列 valueAlias、文字altFieldAlias、文字altValueAlias、列 でalttext、文字列のinsertBefore、列insertAfter、ブール回帰、 CでブールconvertLineBreaks、ブールremoveParagraphTags、 UmbracoRenderItemCaseTypeケーシング、UmbracoRenderItemEncodingType エンコーディング)137 ASP._Page_Views_Umbraco_blogPost_cshtml.Execute():\ INETPUB \ wwwrootの\ Umbraco \ビュー\ Umbraco \ blogPost.cshtml:14
System.Web.WebPages .WebPageBase.ExecutePageHierarchy()280
System.Web.Mvc.WebViewPage.ExecutePageHierarchy()104
System.Web.WebPages.StartPage.ExecutePageHierarchy()143
System.Web.WebPages.WebPageBase.ExecutePageHierarchy( WebPageContext pageContext、TextWriterライター、WebPageRenderingBase startPage)+157
System.W eb.Mvc.ViewResultBase.ExecuteResult(ControllerContextコンテキスト) +378 System.Web.Mvc。 <> C_ DisplayClass1c.b _19() +33 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter フィルタ、ResultExecutingContext preContext、のFunc 1 continuation) +728112 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func 1続き) 728112 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext、IList`1フィルタ、ActionResult actionResult)+265
System.Web.Mvc.ControllerActionInvoker。InvokeAction(ControllerContext controllerContext、ストリングactionNameの)728068
System.Web.Mvc.Controller.ExecuteCore()159
System.Web.Mvc.ControllerBase.Execute(RequestContextのRequestContextの) 334 System.Web.Mvc。 <> c_ DisplayClassb.b _5()+62 System.Web.Mvc.Async。 <> c_ DisplayClass1.b _0()+15
System.Web.Mvc。 <> C_ DisplayClasse.b _d()+52
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 514 System.Web.HttpApplication.ExecuteStep(IExecutionStepステップ、ブール& completedSynchronously) +354

私は間違っていますか?

感謝の気持ちで助けてください!

乾杯

ピート

答えて

3

私はあなたのビュー/テンプレートにそうのようなフィールドを取得推薦する

DynamicModel.Date

@

か、Model.Field @モデル を使用することができます( "日付")

より良い回答を得るために、私はあなたの質問をour.umbに投稿しますraco.orgコミュニティフォーラム

+0

偉大な、素晴らしい仕事。そして、チップre:our.umbraco.orgのおかげで! –

関連する問題