C# Html.BeginRouteForm接受字符集属性
我正在用Razor创建一个表单,如下所示:C# Html.BeginRouteForm接受字符集属性,c#,asp.net-mvc-3,razor,C#,Asp.net Mvc 3,Razor,我正在用Razor创建一个表单,如下所示: @using (Html.BeginRouteForm("foo", new { controller = "foo", action = "bar" }, FormMethod.Post, new { id="foo", enctype="multipart/form-data", accept-charset="utf-8" })) { <label for="file">File</label>
@using (Html.BeginRouteForm("foo", new { controller = "foo", action = "bar" }, FormMethod.Post, new { id="foo", enctype="multipart/form-data", accept-charset="utf-8" }))
{
<label for="file">File</label>
<input type="file" name="file" id="file" />
<input type="submit" value="Send"/>
}
@使用(Html.BeginRouteForm(“foo”,new{controller=“foo”,action=“bar”},FormMethod.Post,new{id=“foo”,enctype=“multipart/form data”,accept charset=“utf-8”}))
{
文件
}
我需要在表单标签中获得一些属性。但是编译器不喜欢accept字符集中的破折号。如何允许C中的对象属性带有破折号?在属性名称中使用下划线:accept\u charset MVC自动将html属性属性中的下划线转换为破折号:
@using (Html.BeginRouteForm("foo", new { controller = "foo", action = "bar" }, FormMethod.Post, new { id="foo", enctype="multipart/form-data", accept_charset="utf-8" }))
{
<label for="file">File</label>
<input type="file" name="file" id="file" />
<input type="submit" value="Send"/>
}
@使用(Html.BeginRouteForm(“foo”,new{controller=“foo”,action=“bar”},FormMethod.Post,new{id=“foo”,enctype=“multipart/form data”,accept_charset=“utf-8”}))
{
文件
}
学分: