Convert VB to C # Razor Syntax - MVC

can someone tell me the equivalent of VB of this please:

@model DateTime

Using Date Template 

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

I tried:

@model DateTime 

Using a Date Template

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

... but with an error: A NullReferenceException was not thrown by user code Object variable or with a locked block variable.

This is from a tutorial: Using HTML5 and jQuery UI Datepicker Pop-up Calendar with ASP.NET MVC - Part 4

+3
source share
2 answers

Instead of @model, you can try ModelType as shown below,

 @ModelType DateTime

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

thank

Deep

0
source

Can you just make sure that you send a NOT NULL instance of the model to the view from the controller? The rest is all good to me. Example:

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

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

All Articles