NerdDinner的ActionResult删除中的“confirmButton”是什么?
在 NerdDinner MVC 应用演示中,在设置 ActionResult Delete
时定义了 confirmButton
:
public ActionResult Delete(int id, string confirmButton) {
confirmButton
的用途是什么,因为它没有在代码?我假设它返回了单击的提交按钮的名称,但它只是一个空白字符串。如何获取按下的按钮(例如,您可以有 archive
和 delete
(或 yes
、 no
)按钮在同一页面上)?
In the NerdDinner MVC app demo, there is confirmButton
defined when setting up ActionResult Delete
:
public ActionResult Delete(int id, string confirmButton) {
What is confirmButton
for, as it is not used in the code? I assumed it returned the name of the submit button that was clicked, but it is just a blank string. How can you get which button was pressed (e.g. you could have archive
and a delete
(or yes
, no
) buttons on the same page)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您查看视图
Delete.aspx
,您将看到以下 html...如您所见,confirmButton 位于此处,并且该值将传递给您指定的 ActionResult。
您还可以指定两个按钮,例如...
confirmButton
参数将具有您单击的任何一个按钮的值...为什么它在 NerdDinner 中不能正常工作很奇怪,但您可以轻松地通过创建一个快速项目并打开默认的 HomeController 并添加来测试这一点
。在 Index.aspx 中您可以添加
,您应该可以开始了。
If you look at the View
Delete.aspx
you'll see the following html...As you can see the confirmButton is located here and the value will be passed to the ActionResult you specified.
You can also specify two buttons like...
The
confirmButton
parameter will have the value of whichever one you clicked...Why it isn't working properly for you in NerdDinner is strange though but you can easily test this by creating a quick project and opening the default HomeController and adding
In the Index.aspx you can add
And you should be good to go.