下拉列表的名称会自动重命名吗?

发布于 2024-10-09 22:44:00 字数 753 浏览 0 评论 0原文

我在 ASP.NET MVC 中遇到 DropDownlist 名称问题

在我的 EditorTemplate 中,我

  <%: Html.DropDownList("PoolGeometry",Model.selectVm.PoolGeometry, new { id = "poolgeometry" })%>

生成了 html,

<select name="Pool.PoolGeometry" id="poolgeometry">

通常情况下,“PoolGeometry”是 db 中的一个字段。如果我的下拉列表名称具有相同的名称,则所选值是字段的值。

我不明白这个自动重命名!

编辑:

名称取决于 EditorTemplate :

如果 EditorTemplate 像这样调用:

<%: Html.EditorFor(model => model.Pool,"SwimmingPool","")%>

下拉列表的名称是“PoolGeometry”并且选定的值可以。

但如果这样调用:

<%: Html.EditorFor(model => model.Pool,"SwimmingPool")%>

下拉列表的名称是“Pool.PoolGeometry”

I've a problem with DropDownlist Name in ASP.NET MVC

In my EditorTemplate, I've

  <%: Html.DropDownList("PoolGeometry",Model.selectVm.PoolGeometry, new { id = "poolgeometry" })%>

In generate html, I've

<select name="Pool.PoolGeometry" id="poolgeometry">

Normally, "PoolGeometry" is a field in db. If my dropdownlistname has the same name, selected value is value of field.

I don't understand this automatic rename!

EDIT :

Name is dependent on EditorTemplate :

if EditorTemplate called like this:

<%: Html.EditorFor(model => model.Pool,"SwimmingPool","")%>

Name of dropdownlist is "PoolGeometry" and selectedvalues are ok.

But if it is called like this:

<%: Html.EditorFor(model => model.Pool,"SwimmingPool")%>

Name of dropdownlist is "Pool.PoolGeometry"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文