开发者

Passing the form action attribute to a Partial View

开发者 https://www.devze.com 2023-01-19 05:48 出处:网络
I have a partial view that I am using from 2 different forms. In order to use jQuery validation I would like to use thetag instead of the Html.BeginFo开发者_StackOverflowrm helper. This means that I s

I have a partial view that I am using from 2 different forms. In order to use jQuery validation I would like to use the tag instead of the Html.BeginFo开发者_StackOverflowrm helper. This means that I should specify the action attribute myself just like ASP.NET MVC 2 does when I call the Html Helpers. My questions are:

  1. How can I do it?
  2. Are there better ways to do what I want to do?


Its relatively easy, simply write your form tag as follows:

<form id="myform" method="post" action='<%= Url.Action("myAction") %>'>

If you are calliing the partial from separate places this is the easiest way to achieve what you want

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号