I have a form which have one
@using (Html.BeginForm("Details", "Home", FormMethod.Post))
{
<div class="FormContainer">
<table>
<tr>
<td class="Label">
@Html.Label("*Name of District")
</td>
<td>
<div class="ddl1">
@Html.Partial("_District")
</div>
</td>
</tr>
<tr>
<td class="Label">
@Html.Label("*Name of Tehsil")
</td>
<td>
<div id="tehsil" class="ddl2">
@Html.Partial("_Tehsil")
</div>
</td>
</tr>
<tr>
<td class="Label">
@Html.Label("*Name of Sub Tehsil")
</td>
<td>
<div id="Subtehsil">@Html.Partial("_SubTehsil", Model)</div>
</td>
</tr>
<tr>
<td class="Label">
@Html.Label(" Village")
</td>
<td class="txbox">
@Html.TextBox("Village", null, new { @class = "txtbox" })
</td>
</tr>
<tr>
<td class="Label">
@Html.Label("*Name of Applicant")
</td>
<td class="txbox">
@Html.TextBox("NameOfApplicant", null, new { @class = "txtbox" })
</td>
</tr>
<tr>
<td class="Label">
@Html.Label("*Name of Land Owners / Owners")
</td>
<td class="txbox">
@Html.TextBox("NameOfLandOwners", null, new { @class = "txtbox" })
</td>
</tr>
</table>
}</div>
and in _District , _tehsil, _subtehsil partial view i have following
Quote:
</blockquote>
@using (Ajax.BeginForm("Selecttehsil", "Home", new AjaxOptions { UpdateTargetId = "tehsil" }))
{
@Html.DropDownListFor(m => m.SelectedDistrictId,
new SelectList(Model.Districts, "DistrictId", "DistrictName"),
"----Select District----",
new { @class = "ddl" }
)
}
<script type="text/javascript">
$('#SelectedDistrictId').change(function () {
$(this).parents('form').submit();
});
</script>
_tehsil partial view
@if (Model.Tehsils != null && Model.Tehsils.Count() > 0)
{
using (Ajax.BeginForm("Selectsubtehsil", "Home", new AjaxOptions { UpdateTargetId = "Subtehsil" }))
{
@Html.HiddenFor(m => m.SelectedDistrictId)
@Html.DropDownListFor(m => m.SelectedTehsilId, new SelectList(Model.Tehsils, "TehsilId", "TehsilName"), "----Select Tehsil-----", new {@class = "ddl" })
}
}
<script type="text/javascript">
$('#SelectedTehsilId').change(function () {
$(this).parents('form').submit();
});
</script>
_subtehsil Partial view
@if (Model.SubTehsils != null && Model.SubTehsils.Count()>0)
{
@Html.DropDownList("SubTehsils", new SelectList(Model.SubTehsils, "SubTehsilId", "SubTehsilName"), "----Select SubTehsil---", new { @class = "ddl"})
}
when i select an item from dropdownlist it get posted to "Details" action method which i want it to do when i click on submit button. Please tell me a way out here.