ASP.NET MVC 4倍率发出HTML姓名和身份证 [英] ASP.NET MVC 4 override emitted html name and id

查看:125
本文介绍了ASP.NET MVC 4倍率发出HTML姓名和身份证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图改变由 @ Html.HiddenFor 创建HTML输入的发射名。

I'm trying to change the emitted name of the html input created by @Html.HiddenFor.

在code我用这样的:

The code I'm using this:

@Html.HiddenFor(e => e.SomeProperty, new { @id = "some_property", @name = "some_property" }

现在这个作品为 ID ,但它不为名称的工作。现在,我真的不关心 ID 现在,我需要的名称来改变,因为这是一个得到的回发到目标服务器。

Now this works for the id, however it doesn't work for the name. Now I don't really care for the id now, I need the name to change, because that's the one that get's posted back to the target server.


  • 我可以在我的模型上 SomeProperty 适用的属性?

  • Html.HiddenFor 覆盖名称属性的方法吗?

  • A property I can apply on SomeProperty in my model?
  • A way in the Html.HiddenFor to override the name property?

还是我坚持做一个简单的<输入...> 手动

Or am I stuck to do a plain <input ...> by hand?

推荐答案

如果您使用的:

@ Html.HiddenFor(E => e.SomeProperty,新{@id =some_property
  @Name =some_property});

@Html.HiddenFor(e => e.SomeProperty, new { @id = "some_property", @Name = "some_property" });

通知@Name资本N。稍后即工作。

Notice the capital "N" in @Name. It´ll work.

这篇关于ASP.NET MVC 4倍率发出HTML姓名和身份证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆