[英]Button click not working in MVC3?
Hi all here is my aspx page 大家好,这是我的aspx页面
<body>
<% Html.BeginForm("AssignWork", "Project", FormMethod.Post); %>
<form action="AssignWork.aspx" method="post"></form>
<%:Html.ValidationSummary(true)%>
<div>
<div></div><div style="margin:62px 0 0 203px;"><a style="color:Orange;">Projects : </a><%:Html.DropDownList("Projects")%></div>
<fieldset style="color:Orange;">
<legend>Employees</legend>
<% foreach (var item in Model)
{ %>
<div>
<%:Html.CheckBox("EmployeId",new { value=item.EmployeeName})%>
<%:Html.LabelForModel(item.EmployeeName)%>
</div>
<%} %>
<p>
</p>
</fieldset>
<input type="button" value="Assign" name="Assign" />
</div>
<% Html.EndForm(); %>
</body>
And here is my problem that when I click on Assign button its not going to my post method in my control. 这是我的问题,当我单击“分配”按钮时,它不会进入我控件中的post方法。 I am showing this page in a popup window.
我在弹出窗口中显示此页面。 Can any one tell me where did I do wrong.
谁能告诉我我在哪里做错了。 Thank you.
谢谢。
尝试提交输入而不是按钮
<input type="submit" value="Assign" name="Assign" />
将按钮的类型更改为“提交” :)
You're not using Html.BeginForm()
correctly. 您没有正确使用
Html.BeginForm()
。 Instead of 代替
<% Html.BeginForm("AssignWork", "Project", FormMethod.Post); %>
<form action="AssignWork.aspx" method="post"></form>
try this: 尝试这个:
<% using (Html.BeginForm("AssignWork", "Project", FormMethod.Post) { %>
<!-- your form markup -->
<% } %>
You don't need to use a <form>
tag since its rendered by Html.BeginForm()
, and Html.EndForm()
isn't necessary because of the using
statement - the end tag is rendered at the end of the using
control block. 您不需要使用
<form>
标记,因为它是由Html.BeginForm()
呈现的,而Html.EndForm()
由于using
语句是不必要的Html.EndForm()
标记在using
控件的结尾呈现块。
And you probably also need to change the input type to submit
. 您可能还需要更改输入类型以
submit
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.