2012-04-30 137 views
3

誰能告訴我什麼VB相當於這個是請:VB轉換爲C#剃刀語法 - MVC

@model DateTime 

Using Date Template 

@Html.TextBox("", String.Format("{0:d}", Model.ToShortDateString()), 
    new { @class = "datefield", type = "date" }) 

我想:

@model DateTime 

使用日期模板

@Html.TextBox("", String.Format("{0:d}", Model.ToShortDateString()), New With {Key .class = "datefield", Key .type = "date"}) 

...但錯誤發生在: NullReferenceException未被用戶代碼處理 Obj ect變量或未設置塊變量。

這是從教程:Using the HTML5 and jQuery UI Datepicker Popup Calendar with ASP.NET MVC - Part 4

回答

0

相反@model的,可以嘗試ModelType像下面,

@ModelType DateTime 

@Html.ActionLink("Edit", "Edit", New With {.id = item.ID}) 

感謝

迪普

0

你能只要確保你正在從控制器發送模型的NOT NULL實例到視圖?休息一切似乎對我好。 例如:

Function Index() As ActionResult 
     ViewData("Message") = "Welcome to ASP.NET MVC!" 

     Return View(New Employee()) 'See the : New Employee()' 
End Function