Mvc 3表单post参数:如何使用name=“Attribute.AttributeID”访问ddl通过控制器中的参数
我有一个如下所示的下拉列表:
@Html.DropDownListFor(
x => x.Attribute.AttributeID,
new SelectList(Model.Attributes, "AttributeID", "Name")
)
在我的控制器中,我尝试了 attributeId 和 attribute_attributeId 等参数,这是我的代码:(
[HttpPost]
public ActionResult Index(int productId, int attributeId)
顺便说一句,我还收到查询字符串中的 ProductID)
我的 ddl 的输出是... id="Attribute_AttributeID" name="Attribute.AttributeID" ...
我也尝试过这个:
@Html.DropDownListFor(
x => x.Attribute.AttributeID,
new SelectList(Model.Attributes, "AttributeID", "Name"),
null,
new { id = "attributeId", name = "attributeId" }
)
但是然后 id 只是改变而不是两者都改变...
所以我的问题是我怎样才能到达dll 无需编写任何东西就像x =>; ddl 中的 x.SelectedAttributeID。
I have a dropdownlist that looks like this:
@Html.DropDownListFor(
x => x.Attribute.AttributeID,
new SelectList(Model.Attributes, "AttributeID", "Name")
)
In my controller I've tried parameters like attributeId and attribute_attributeId, this is my code:
[HttpPost]
public ActionResult Index(int productId, int attributeId)
(Btw, I'm also receiving the ProductID which is in the query string)
The output of my ddl is ... id="Attribute_AttributeID" name="Attribute.AttributeID" ...
I've tried this also:
@Html.DropDownListFor(
x => x.Attribute.AttributeID,
new SelectList(Model.Attributes, "AttributeID", "Name"),
null,
new { id = "attributeId", name = "attributeId" }
)
But then the id just changes and not the both...
So my question is how can I be able to reach the dll without having to write something like x => x.SelectedAttributeID in the ddl.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)