i have written the following code in my view and when user click on image button the form should be submitted but it is not submitting
<% using (Html.BeginForm("Resumename", "Resumewizard",
FormMethod.Post, new { name = "Resumetitle",OnLoad="Error();"})){ %>
<%=Html.Label("Step 1.Resume Name")%><br />
<%=Html.Label("Please Enter Resume Name,Job Title and Objective")%&g开发者_高级运维t;<br />
<%=Html.Label("Resume Name")%><br />
<%=Html.TextBox("ResTitle")%><br />
<%=Html.Label("Desired Job Title/Position")%><br />
<%=Html.TextBox("DesPos")%><br />
<%=Html.Label("Objective")%><br />
<%=Html.TextArea("ResObjective")%><br />
<% string str = ViewData["Errormsg"].ToString(); %>
<div id="msgblock">
<%=Html.Label(str)%>
<%=Html.Hidden("error", ViewData["Errormsg"])%>
<%=Html.Hidden("resumeid",ViewData["resumeid"])%>
</div>
<input id="SaveForwardButton" type="image"
src="../../Content/img/buttons/SaveForwardButton.gif" />
<% } %>
The button type
is set to image
. I think you should change it to submit
.
Personally I do it with jQuery, something like below:
<%using (Html.BeginForm("Resumename", "Resumewizard", FormMethod.Post, new { name = "Resumetitle",OnLoad="Error();"}))
{%>
<%=Html.Label("Step 1.Resume Name")%><br />
<%=Html.Label("Please Enter Resume Name,Job Title and Objective")%><br />
<%=Html.Label("Resume Name")%><br />
<%=Html.TextBox("ResTitle")%><br />
<%=Html.Label("Desired Job Title/Position")%><br />
<%=Html.TextBox("DesPos")%><br />
<%=Html.Label("Objective")%><br />
<%=Html.TextArea("ResObjective")%><br />
<% string str = ViewData["Errormsg"].ToString();
%>
<div id="msgblock">
<%=Html.Label(str)%>
<%=Html.Hidden("error", ViewData["Errormsg"])%>
<%=Html.Hidden("resumeid",ViewData["resumeid"])%>
</div>
<img class="SaveForwardButton" src="../../Content/img/buttons/SaveForwardButton.gif" />
<script type="text/javascript">
$(".SaveForwardButton").click(function () {
$(this).parents("form").trigger("submit");
});
</script>
<% }%>
Normally I would declare this in my main .js file and apply the submit class to whatever element I like.
精彩评论