0

Hi all here is my aspx page

          <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. I am showing this page in a popup window. Can any one tell me where did I do wrong. Thank you.

1
  • Hope you have associated controller & action in place Commented Jul 23, 2012 at 13:00

3 Answers 3

1

Try a submit input instead of a button

<input type="submit" value="Assign" name="Assign" />
Sign up to request clarification or add additional context in comments.

1 Comment

On top of this, you likely want your <form> to enclose all of your field elements, otherwise they will not post when you submit.
0

change the type of your button to 'submit' :)

Comments

0

You're not using Html.BeginForm() correctly. 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.

And you probably also need to change the input type to submit.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.