Hi I am using multiple begin forms. I am not sure if this is a good Idea. This is my code.
<% using (Html.BeginForm("TagManagement", "InternalTag",FormMethod.Post))
{%>
<%: Html.AntiForgeryToken() %>
<table>
<tr>
<td><%:Html.Label("Type") %></td>
<td style="text-align:left"><%:Html.DropDownList("ObjectType",ViewData["TagObjects"] as IEnumerable<SelectListItem>)%></td>
</tr>
<tr>
<td><%:Html.Label("Search ID")%></td>
<td style="text-align:left"><%:Html.TextBox("ObjectID2")%></td>
</tr>
<tr>
<td></td>
<td><input id="Search" type="submit" value="Search" /> <input id="Create" type="button" value="Add to New Tag" onclick="AddTagElements()" /></td>
</tr>
</table>
<br />
<% } %>
<% using (Html.BeginForm("CreateTag","InternalTag",FormMethod.Post)) { %>
<%: Html.AntiForgeryToken() %>
<div id="AddTag">
<input id='SaveTag' type='submit' value='Save' style='width: 125px' />
</div>
<% } %>
routing code
"Tags/{controller}/{action}/{id}/{type}",
new { action = "Index", id = UrlParameter.Optional, type = UrlParameter.Optional }
my controller methods:
public ActionResult TagManagement(FormCollection FC,Guid? ID,InternalTagRef_Types? Type)
public ActionResult CreateTag(FormCollection FC, Guid ID, InternalTagRef_Types Type)
when I click on search TagManagement Actions parameters get properly populated. When I click on SaveTag it tries call the CreateTag action but cannot because it is missing ID and Type. I get the error The parameters dictionary contains a null entry for parameter 'ID' of non-nullable type 'System.Guid'. It should get these values from the URL i.e. http://localhost:1338/Tags/InternalTag/TagManagement/D104EBF5-470B-4FAA-9FC7-5391922CCE94/Projects like TagManagement. Please help.