在剃刀应用程序的视图中使用特殊的法语字符

时间:2013-08-02 14:14:18

标签: html .net css asp.net-mvc html5

我有一个asp .net mvc4应用程序,其中我在此视图中的编码存在问题:

@model Planning.Models.Affaire
@{

    Layout = "~/Views/Shared/Template.cshtml";
}

@section logout {
    <a href='@Url.Action("Index", "Calendar")'><img src="~/Content/images/restart-1.png"/></a>
    <a href='@Url.Action("Logout", "Home")' style="margin-left: 91.3%"><img src="~/Content/images/images.jpg" style="width:37px; height:37px" /></a>
    }
<head>
    <style>
    input {
    border: 1px solid #e2e2e2;
    background: #fff;
    color: #333;
    font-size: 1.2em;
    margin: 5px 0 6px 0;
    padding: 5px;
    width: 300px;
    }
        a {
            font-size:14px;
        }

        </style>
</head>
<br />
<br />
<h2 style="color:red ; margin-left: 40%">Ajouter une séquence</h2>
<br />
<br />

<form action="/Calendar/SaveSequence" method="post" style="margin-left: 33%; ">
           <div >
            <strong style="color:blue ">La description  de la séquence</strong>
            <input type="text" name="description" value="" style="margin-left:15.5%; width:50%" /> 
           </div>
            <br />

        <input type="text" name="id" value="@Model.Id_affaire" style="margin-left:15.5%; width:50%; visibility:hidden" />          <br />

        <p>
            <input type="submit" value="Enregistrer" />
        </p>

</form>
<div>
    @Html.ActionLink("Retour à la liste", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}

我得到了这个结果:

result

问题出现在é字母中:它显示在<strong style="color:blue ">La description de la séquence</strong>中,并在<h2 style="color:red ; margin-left: 40%">Ajouter une séquence</h2>中消失。

为什么会这样?我该如何解决?

1 个答案:

答案 0 :(得分:2)

一个不太好但可行的解决方案是使用代码&eacute;

<strong style="color: blue">La description de la s&eacute;quence</strong>
<h2 style="color: red; margin-left: 40%;">Ajouter une s&eacute;quence</h2>.

更智能的解决方案是在head标签中声明UTF-8编码,如下所示:

<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>