locked
Mvc Html.DisplayNameFor decode special characters RRS feed

  • Question

  • User1991482975 posted

    Hi,

    i have this link :

    <th>
                    @Html.ActionLink(Html.DisplayNameFor(model => model.FirstOrDefault().SalonBookingDate).ToHtmlString(), "Index", new { sortOrder = ViewBag.DateSortParm, currentFilter = ViewBag.CurrentFilter, searchYear = ViewBag.CurrentYear, searchMonth = ViewBag.CurrentMonth, page = Model.PageCount < Model.PageNumber ? 1 : Model.PageNumber })
                </th>

    and i the web result is this :

    Date de r&#233;servation

    how can i decode html special characters?

    Thanks

    Saturday, November 28, 2020 4:29 PM

Answers

  • User503812343 posted

    Try

    @Html.Raw(WebUtility.HtmlDecode(someString))

    like

     @Html.ActionLink(Html.DisplayNameFor(model => @Html.Raw(WebUtility.HtmlDecode(model.FirstOrDefault().SalonBookingDate))).ToHtmlString(), "Index", new { sortOrder = ViewBag.DateSortParm, currentFilter = ViewBag.CurrentFilter, searchYear = ViewBag.CurrentYear, searchMonth = ViewBag.CurrentMonth, page = Model.PageCount < Model.PageNumber ? 1 : Model.PageNumber })

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, November 29, 2020 2:52 AM
  • User1991482975 posted

    Thanks,

    i achived this like this :

                    @Html.ActionLink(WebUtility.HtmlDecode(Html.DisplayNameFor(model => model.FirstOrDefault().SalonBookingDate).ToHtmlString()), "Index", new { sortOrder = ViewBag.DateSortParm, currentFilter = ViewBag.CurrentFilter, searchYear = ViewBag.CurrentYear, searchMonth = ViewBag.CurrentMonth, page = Model.PageCount < Model.PageNumber ? 1 : Model.PageNumber })
    

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, November 29, 2020 12:43 PM

All replies

  • User1120430333 posted

    If the date data is some kind of valid date data, then why can't you use a ToString("mm/dd/yyyy") to format the date or one of the many other date formatting strings? 

    Saturday, November 28, 2020 8:45 PM
  • User503812343 posted

    Try

    @Html.Raw(WebUtility.HtmlDecode(someString))

    like

     @Html.ActionLink(Html.DisplayNameFor(model => @Html.Raw(WebUtility.HtmlDecode(model.FirstOrDefault().SalonBookingDate))).ToHtmlString(), "Index", new { sortOrder = ViewBag.DateSortParm, currentFilter = ViewBag.CurrentFilter, searchYear = ViewBag.CurrentYear, searchMonth = ViewBag.CurrentMonth, page = Model.PageCount < Model.PageNumber ? 1 : Model.PageNumber })

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, November 29, 2020 2:52 AM
  • User1991482975 posted

    Thanks,

    i achived this like this :

                    @Html.ActionLink(WebUtility.HtmlDecode(Html.DisplayNameFor(model => model.FirstOrDefault().SalonBookingDate).ToHtmlString()), "Index", new { sortOrder = ViewBag.DateSortParm, currentFilter = ViewBag.CurrentFilter, searchYear = ViewBag.CurrentYear, searchMonth = ViewBag.CurrentMonth, page = Model.PageCount < Model.PageNumber ? 1 : Model.PageNumber })
    

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, November 29, 2020 12:43 PM