amiry jd
amiry jd

Reputation: 27585

Razor encodes everything

Razor is encoding every unicode character. How to prevent that?

Example:

This is my Razor:

@Html.DropDownListFor(model => model.Category,
    (IEnumerable<SelectListItem>) ViewBag.CategoriesList,
    "موضوع صفحه را انتخاب کنید...", new{
        @class = "form-control some-css"
    })

And this the rendered html:

<select class="form-control&#32;some-css" id="Category" name="Category">
    <option value="">
        &#1605;&#1608;&#1590;&#1608;&#1593; &#1589;&#1601;&#1581;&#1607; &#1585;&#1575; &#1575;&#1606;&#1578;&#1582;&#1575;&#1576; &#1705;&#1606;&#1740;&#1583;...
    </option>
    <option value="SomeValue">
        &#1605;&#1608;&#1586;&#1607;
    </option>
    <!-- some other options -->
</select>

Upvotes: 3

Views: 435

Answers (1)

Alex
Alex

Reputation: 38499

You could use Html.Raw()

@Html.DropDownListFor(model => model.Category,
    (IEnumerable<SelectListItem>)ViewBag.CategoriesList,
    Html.Raw("موضوع صفحه را انتخاب کنید..."), new
    {
        @class = "form-control some-css"
    })

Upvotes: 1

Related Questions