How to reference form by name in javascript using an ASP.Net BeginForm Html helper
I'm sure I'm going about this wrong but I'm trying to write a simple javascript method that will set a hidden type value upon a link click.
I'm using the Html.BeginForm() helper that contains two links similar to:
@Html.ActionLink("Delete Review Only", "Delete", new { id = Model.ReviewId }, new { onclick = "SetDeleteType(1);" })
The javascript is this:
<script language="JavaScript" type="text/javascript">
function SetDeleteType(selectedtype) {
document.supportform.deleteType.value = selectedtype;
document.supportform.submit();
}
The supportform name obviously doesn't exists since I'm using BeginForm() and can't specify a form name. Is there a clever way of doing this 开发者_开发知识库without calling Forms(0) using jQuery or something or am I completely off???
Try
@using (Html.BeginForm("Controller", "Action", FormMethod.Post, new { id = "formId", name="formName" }))
精彩评论