PdfPrep.com

Which code segment should you use?

The date of the run must be displayed in ViewsRunlogGetLog.cshtml. The timestamp must not be displayed.

You need to display the date of the run according to the business requirements.

Which code segment should you use?
A . @Html.DisplayFor(model => log.ShortDate)
B . @log.RunDate.ToString()
C . @log.RunDate.ToShortDateString()
D . @Html.DisplayFor(model => log.RunDate)

Answer: A

Explanation:

The log file has the ShortDate function which is defined as:

Return RunDate.ToLocalTime().ToShortDateString();

This meets the requirement.

Note:

Scenario:

* The application uses the ModelsLogModel.cs model.

* The Html.DisplayFor method is typically used to display values from the object that is exposed by the Model property.

The DisplayExtensions.DisplayFor<TModel, TValue> method (HtmlHelper<TModel>, Expression<Func<TModel, TValue>>)

Returns HTML markup for each property in the object that is represented by the Expression expression.

Incorrect:

Not D: The RunDate attribute is defined as DateTime, but the timestamp (the time of day), should not be displayed.

References:

https://msdn.microsoft.com/en-us/library/system.web.mvc.html.displayextensions.displayfor(v=vs.118).aspx

Exit mobile version