1

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

enter image description here

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.

1 Answer 1

2

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>
Sign up to request clarification or add additional context in comments.

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.