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>
    }
.....
}
tereško
  • 58,060
  • 25
  • 98
  • 150
Jagz W
  • 855
  • 3
  • 12
  • 28
  • 6
    I dont think you can have nested forms [Check this link][1] [1]: http://stackoverflow.com/questions/379610/can-you-nest-html-forms – mattematico Dec 19 '13 at 07: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. – AaronLS Dec 23 '13 at 21:41

1 Answers1

2

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

Stacked
  • 6,892
  • 7
  • 57
  • 73
Sam
  • 15,336
  • 25
  • 85
  • 148