views:

10

answers:

1

Hi,

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.BeginForm 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?
+1  A: 

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

Clicktricity
But my problem is that the action can be "Create" or "Edit" and the partial view does not know which of them. Should I use ViewData to send the Action from the controller?
Ikaso
Just a clarification the <form> tag is part of the PartialView.
Ikaso
If you don't know what the action will be, then yes, pass that in the viewmodel or viewdata into the partial
Clicktricity