0

As i have not created a field for the current date in a database table, and not also in model class also, but i want to display only the view of that field?

<div class="editor-label">
  @Html.Label("Date")
</div>                     
<div class="editor-field">
  //here is the problem what to do??
??
</div>
2
  • When the field is available in model then only you can use the html helpers like EditorFor or ValidationMessageFor or any html helper that has the suffix For. Hence you must use the html helpers like @Html.TextBox for your situation. Commented Aug 20, 2015 at 7:36
  • Unclear what your wanting to so. Why would you create a form control and associated validation message when there is nothing to edit and nothing to validate. If you just want to display the current date use <div>@DateTime.Now</div> (and format it with .ToString() if you want) Commented Aug 20, 2015 at 7:37

2 Answers 2

4

if you just want to show a field you can add input tag give it a name and id, Or you can use the razor syntax to add a text field !! if you want to use that field for datepicker then use Jquery DatePicker This Link might help you Jquery DatePicker

Sign up to request clarification or add additional context in comments.

Comments

0
@Html.TextBox("SomeName","SomeValue")

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.