且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

调用 MVC 控制器和操作方法的 HTML 按钮

更新时间:2022-12-31 11:21:39

根本不需要使用表单,除非您想发布到操作.输入按钮(不是提交)可以解决问题.

No need to use a form at all unless you want to post to the action. An input button (not submit) will do the trick.

  <input type="button"
         value="Go Somewhere Else"
         onclick="location.href='<%: Url.Action("Action", "Controller") %>'" />