Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
132
rated 0 times [  137] [ 5]  / answers: 1 / hits: 103881  / 15 Years ago, sun, june 7, 2009, 12:00:00

I have a form on one of my ASP.Net MVC views that I created using the following code



 <% using (Html.BeginForm(null, null, FormMethod.Post))


Using this code I have no control as far as I am aware of setting the name of the form. I'm now trying to write a javascript function to submit the form, is this possible without knowing the forms name?



Thanks


More From » asp.net-mvc

 Answers
11

You can use jquery to submit the form:



<% using (Html.BeginForm(null, null, FormMethod.Post, new { id = myForm})) { %>


(the last part is for htmlAttributes parameter)



just do this:



$(#myForm).submit();


and do not forget to include jquery-1.2.6.js that comes with mvc (or use a higher version).


[#99360] Thursday, June 4, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
vaughns

Total Points: 20
Total Questions: 112
Total Answers: 112

Location: Falkland Islands
Member since Mon, Jul 13, 2020
4 Years ago
;