I have used an javascript for country,state,city for create client form.
@Html.DropDownListFor(model => model.Country, new SelectList(new List<object>{
new { value="Select", text= "--Select--" },
}, "value", "text", 0), new { @class = "countries",id="countryId" })
@Html.DropDownListFor(model => model.State, new SelectList(new List<object>{
new { value="Select", text= "--Select--" },
}, "value", "text", 0), new { @class = "states",id="stateId" })
@Html.DropDownListFor(model => model.City, new SelectList(new List<object>{
new { value="Select", text= "--Select--" },
}, "value", "text", 0), new { @class = "cities",id="cityId" })
For edit view, i simply loaded that country,state,city initially after that try to change onclick event
@Html.DropDownListFor(model => model.Country, new SelectList(new List<object>{
new { value=@ViewBag.country, text=@ViewBag.country },
}, "value", "text", 0), new { @class = "countries", id = "countryId" })
@Html.DropDownList("State", new SelectList(new List<object>{ new { value=@ViewBag.states, text=@ViewBag.states },
}, "value", "text", 0), new { @class = "states", id = "stateId" })
@Html.DropDownListFor(model => model.City, new SelectList(new List<object>{
new { value=@ViewBag.city, text=@ViewBag.city },
}, "value", "text", 0), new { @class = "cities", id = "cityId" })
in edit view i tried by following:
$("#countryId").click(function () {
alert('test');
@*<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://lab.iamrohit.in/js/location.js"></script>*@
});
in jquery i call api in create page as following,
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://lab.iamrohit.in/js/location.js"></script>
}
In edit page how can i call this api, so that i can reload country,state,city.. Can anyone help me to solve this.. Thanks in advance...