Reputation: 1808
I have created an extension using formbuilder. Now I have used it in my view. My view looks like:
@using (Html.BeginForm("addDataInd", "CustInformations", FormMethod.Post))
{
<fieldset class="field">
<legend>Addresses</legend>
<table>
<tr>
@Html.EditorFor(model => model.addresses)
</tr>
</table>
</fieldset>
}
where
@Html.EditorFor(model=>model.addresses)
calls my EditorTemplate which looks like:
<td>
@Html.hSearch("txtSearch", "", "lblsrch", "Search Text: ", "Search", "Fetch", "LookUp", new { script = "Select Aid, FullAreaName from fGetAreaTB()" }, null)
</td>
When i run the program the page looks like
i used fire bug to know the error. All I found was that, the code generated for the first upper image (i.e. for permanent address) it doesn't create a form, but for other two it creates a form. So when I click the first search button, it doesn't work but when i click the second and third button it works well.
I just want when i run the program all the button must be in form.
Upvotes: 1
Views: 243
Reputation: 1038710
You cannot nest HTML forms. For this reason you will have to use multiple forms and put them inside the template. Like this:
<fieldset class="field">
<legend>Addresses</legend>
<table>
<tr>
@Html.EditorFor(model => model.addresses)
</tr>
</table>
</fieldset>
and inside the editor template:
@model Address
<td>
@using (Html.BeginForm("addDataInd", "CustInformations", FormMethod.Post))
{
@Html.hSearch("txtSearch", "", "lblsrch", "Search Text: ", "Search", "Fetch", "LookUp", new { script = "Select Aid, FullAreaName from fGetAreaTB()" }, null)
}
</td>
Upvotes: 2