开发者

ASP.NET MVC2 Multiple submit buttons, submit value null with FireFox and Chrome

I have a form with multiple submit buttons:

using(Ajax.Begi开发者_如何学CnForm("Submit", "myController", new AjaxOptions { HttpMethod = "Post" }))
{ %>
<button type="submit" name="submitType" value="submit_a">a</button>
<button type="submit" name="submitType" value="submit_b">b</button>
<% } %>

The controller method is as follows:

[Authorize, HandleError, HttpPost]
public ActionResult Submit(string submitType)
{
  //placeholder
}  

With IE (js on or off) the buttons post back with their respective submitType value, however with Chrome and FireFox submitType is null (when js is on, it's fine when js is off)

Does anyone know how I can fix this behaviour please?

(Please note I need to use the Ajax form as it does partial postbacks/updates)


Crap, the previous developer had placed the BeginForm() tags in invalid places (start of form tag in the middle of a div, end of form tag in an entirely seperate div) and whilst VS didn't throw any errors, it resulted in an invalid markup, which caused FireFox and Chrome to ignore and not return the submit value! Once I corrected the tag positions it started working correctly.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜