Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8662271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:41:40+00:00 2026-06-12T16:41:40+00:00

I have a view in 2 sections. The top section I input fields and

  • 0

I have a view in 2 sections.
The top section I input fields and submit to save them.
In the second section I have an autocomplete textbox. I select an item in autocomplete, and when I click submit I want to add that item to a datatable.
So for the first part when I click submit I save the details via a HttpPost method on the controller.
For the second part I intend to save it via an Ajax call for the controller and then bring back a partial view with the results. I have not coded the partial view yet, that is next.
Now I am new to Ajax.BeginForm and I am struggling with it.
I was hoping that the submit button inside the Ajax.BeginForm would only apply to that part of the form.
But in fact it calls the HttpPost method for the whole form.
So how do I fix this?
My view looks like;

@using ITOF.HtmlHelpers
@model ITOF.Models.OngoingContractViewModel
@{
    ViewBag.Title = "EditOngoingContractDetails";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
    @using (Html.BeginForm("EditOngoingContractDetails", "Contract", FormMethod.Post,
         new { enctype = "multipart/form-data" }))
    {
        @Html.ValidationSummary(true)
        @Html.HiddenFor(model => model.Contract.ContractId)
        <h1>Edit Ongoing Contract Details</h1>
        <fieldset>
            <legend>@Model.Contract.Heading</legend>
            <p>Where you see <span class="error">*</span> you must enter data.</p>
            <table>
                <tr>
                    <td style="text-align: right">
                        @Html.LabelFor(model => model.Contract.EndDate)
                    </td>                    
                    <td>
                        @Html.EditorFor(model => model.Contract.EndDate)
                    </td>
                </tr>
                <tr>
                    <td style="text-align: right">
                        @Html.LabelFor(model => model.Contract.Organogramme)    
                    </td>
                    <td>
                        <input type="file" id="PDF" name="file" />
                        @Html.HiddenFor(model => model.Contract.Organogramme)
                    </td>
                </tr>
                @if (!string.IsNullOrWhiteSpace(Model.Contract.Organogramme))
                {
                    <tr>
                        <td></td>
                        <td>
                            The current organogramme is <span class="HighlightTextRed">@Model.GetOrganogrammeName()</span> 
                            for the contract <span class="HighlightTextRed">@Model.Contract.ContractName</span><br/>
                            <a href="@Model.Contract.Organogramme" target="_blank">Click here to see the last saved organogramme</a> 
                        </td>
                    </tr>
                }
                <tr>
                    <td style="text-align: right">
                        @Html.LabelFor(model => model.Contract.AssistantRLOManagerId)
                    </td>                    
                    <td>
                        @Html.DropDownListFor(model => model.Contract.AssistantRLOManagerId, Model.AssistantRloManagerSelectList, "--N/A--")
                    </td>                   
                </tr>
                @if (this.TempData["SuccessMessage"] != null)
                {
                    <tr>
                        <td colspan="2" class="success">@this.TempData["SuccessMessage"].ToString()</td>
                    </tr>
                }
                <tr>
                    <td colspan="2" style="padding-top: 20px; text-align: center;"><input type="submit" value="Save" /></td>
                </tr>
            </table>
        </fieldset>


        <fieldset>
            <legend>Add an existing Site to this contract: </legend>
            @using (Ajax.BeginForm("AddExistingSite", new AjaxOptions { UpdateTargetId = "siteRows" }))
            {

                <input type="text" name="q" style="width: 800px" 
                       data-autocomplete="@Url.Action("SiteSearch", "DataService", new { contractId = @Model.Contract.ContractId })" />
                <input type="submit" value="Add site to contract" />
            }

            @if (Model.SiteList.Count > 0)
            {
                <table id="siteDataTable" class="display">
                    <thead>
                        <tr>
                            <th>Main Site?</th>
                            <th>Type</th>
                            <th>Address</th>
                            <th>Map</th>
                            <th>Telephone</th>
                            <th>Email</th>
                        </tr>
                    </thead>
                    <tbody id="siteRows">
                        @foreach (var item in Model.SiteList)
                        {
                            <tr id="@item.SiteContract.SiteContractId">
                                <td>@item.SiteContract.MainSiteFlag</td>
                                <td>@item.Site.SiteType</td>
                                <td>@item.Site.Address</td>
                                <td>@item.Site.MapUrl</td>
                                <td>@item.Site.Telephone</td>
                                <td>@item.Site.Email</td>
                            </tr>
                        }
                    </tbody>
                </table>
                <div class="add_delete_toolbar" />
            }
            @Html.ListLink("Back to List") 
        </fieldset>
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T16:41:42+00:00Added an answer on June 12, 2026 at 4:41 pm

    Oh no, you just cannot nest HTML forms. That’s not supported. You will have to rethink your design. This really has absolutely nothing to do with ASP.NET MVC and things like Html.BeginForm or Ajax.BeginForm. The HTML specification simply tells you that the <form> tag cannot be nested and if you nest it you will get undefined behavior that could vary between browsers.

    For example you could implement the autocomplete functionality using jquery UI autocomplete plugin and get rid of the Ajax.BeginForm.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 sections within a table view and I have loaded one section
I see this quite often, where you have sections view on top and then
I have table View with grouped style with three sections. Get information from dictionary
When I have a table view with some sections which have their own headers
I have this view (DetailsContainer, first class in code section of this question) with
I have an ASP MVC view where have the following statement #if DEBUG //section
I have to create my own Section Header View of a UITableView, with a
I have a simple UITableView with two sections. Each section has a header which
I have a table view section with two custom cells. I want to swap
I have a view that adds another view on top in this manner: -

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.