开发者

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" }))
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜