【问题标题】:VB conversion for C# Razor Syntax - MVCC# Razor 语法的 VB 转换 - MVC
【发布时间】:2012-05-10 02:14:36
【问题描述】:

谁能告诉我这个的VB等价物是什么:

@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 未设置对象变量或 With 块变量。

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

【问题讨论】:

    标签: asp.net asp.net-mvc-3


    【解决方案1】:

    你可以试试下面的ModelType,而不是@model,

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

    谢谢

    深浦

    【讨论】:

      【解决方案2】:

      你能确定,你是从控制器向视图发送 NOT NULL 的 Model 实例吗?休息对我来说一切都很好。 例如:

      Function Index() As ActionResult
              ViewData("Message") = "Welcome to ASP.NET MVC!"
      
              Return View(New Employee()) 'See the : New Employee()'
      End Function
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-07-06
        • 1970-01-01
        • 2018-08-01
        • 2012-04-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多