1

I have scenario where I have load data on dropdown selection change and after manipulation I have to submit the page for saving.

I have developed the page but since I new to MVC so can anyone verify me code and can suggest better approach of doing the same.

   @using (Html.BeginForm("Save", "forecast"))
{
    using (Html.BeginForm("YearChange", "forecast", FormMethod.Get, new {@id="frmYearChange" }))
    {
        <div class="span12">
            <div class="well well-sm" style="padding-bottom: 0px !important;">
                <div class="span5">
                    <div class="control-group">
                        <label class="control-label" for="selectGroup">
                            Select Group:</label>
                        <div class="controls">
                            @Html.DropDownListFor(m => m.groupId, Model.groupList, "--Select Group--", new { @id = "selectGroup" })
                        </div>
                    </div>
                </div>
                <div class="span5">
                    <div class="control-group">
                        <label class="control-label" for="selectYear">
                            Select Year:</label>
                        <div class="controls">
                            @Html.DropDownListFor(m => m.yearId, Model.yearList, "--Select Year--", new { @id = "selectYear", onchange = "selectYear_indexChanged();" })
                        </div>
                    </div>
                </div>
                <div class="clearfix">
                    &nbsp;</div>
            </div>
        </div>
    }
.....
}
2
  • 6
    I dont think you can have nested forms [Check this link][1] [1]: stackoverflow.com/questions/379610/can-you-nest-html-forms Commented Dec 19, 2013 at 7:39
  • You could either have two pages, one with the drop downs which when submitted, returns the second page/form. OR instead when submitting the dropdown values, you do an AJAX submit and replace the current form with the result of an action returning a PartialView containing the second form, or replace a div placeholder below the current form with the new form so that you have two forms above/below instead of nested. Commented Dec 23, 2013 at 21:41

1 Answer 1

2

You can't have nested forms. You can however have multiple forms per view. See W3C for more info.

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.