tags:

views:

25

answers:

1
+1  Q: 

How to submit ?

Can I have a submit in <% using (Ajax.BeginForm("ChangePassword", new AjaxOptions { OnComplete = "ChangePasswordComplete" })) without having a submit button on the form?

I yes, how? Let`s say I want to submit the above when a user click on an input of type button simply?

A: 

You'd have to use Javascript to post back the form, jQuery has a submit method you can use.

$("#FormId").submit();

But really, an input of type button is the same as submit, only it submits automatically so you might as well use that.

Progressive Enhancement

Alternatively, you can use the jQuery Form plug-in to post a standard form (using Html.BeginForm or manually outputting the <form />) and that will work for people who don't have Javascript enabled on their browser.

Kieron
Where do I include the form Id in the above?
Either inspect it in the browser to see it's id/ name or provide one using the htmlAttributes (http://msdn.microsoft.com/en-us/library/dd493048(v=VS.100).aspx). You can also give it a class and use the jQuery class selector `.FormClass`, again, use the htmlAttributes to provide the class name like this `new { @class = "form-class-name" }` (the @ is required in C# as class is a keyword)
Kieron