in mvc i m adding partial view using ajax,but that partila view contains footer of view, means now there are 2 footer.how we can hide footer of partial view.
var cntry = db.Country_Name.ToList();
List<SelectListItem> countre = new List<SelectListItem>();
foreach (Country_Name item in cntry)
{
countre.Add(new SelectListItem
{
Text = item.Country,
Value = item.Country_Id.ToString()
});
}
ViewBag.country = countre;
<div class="form-group">
@Html.LabelFor(model => model.First_Name, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.First_Name, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.First_Name, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Country, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(model => model.Country, (IEnumerable<SelectListItem>)ViewBag.country, new { @class = "form-control col-md-3", @id = "ddrcountry", onchange = "javascript:return getstates()" })
@Html.ValidationMessageFor(model => model.Country, "", new { @class = "text-danger" })
</div>
</div>
<div id="partialStateView">
</div>
<div class="col-md-5">
@Html.EditorFor(model => model.Mobile, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Mobile, "", new { @class = "text-danger" })
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="SignUp" onclick="javascript: return checkdate()" class="btn btn-default" />
</div>
</div>
@section Scripts{
<script>
function getstates() {
var drpvalue = document.getElementById("ddrcountry").value;
// alert(drpvalue);
if (drpvalue == 0) {
return false;
}
$.ajax({
url: '@Url.Action("GetStates", "Home")',
dataType: "html",
data: { "sb": drpvalue },
type: "GET",
contentType: "application/json",
success: function (response) {
$('#partialStateView').html(response);
},
error: function (err) {
alert(err.responseText);
}
});
}
</script>
}
public ActionResult GetStates(int sb)
{
var states = db.State_Name.Where(s => s.Country_Id == sb).ToList();
List<SelectListItem> statelst = new List<SelectListItem>();
foreach (State_Name item in states)
{
statelst.Add(new SelectListItem
{
Text = item.State,
Value = item.State_Id.ToString()
});
}
ViewBag.Statelist = statelst;
return View();
}
<div class="row col-md-6">
<div class="form-group col-md-12">
@Html.LabelFor(model => model.State, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(model => model.State, (IEnumerable<SelectListItem>)ViewBag.Statelist, "Select State", new { @class = "form-control col-md-3", @id = "ddrstate", onchange = "javascript:return getcity()" })
@Html.ValidationMessageFor(model => model.State, "", new { @class = "text-danger" })
</div>
</div>
<div id="partialCityView" class="col-md-12">
</div>
</div>
@section Scripts{
<script>
/////Get states according to Country
function getcity() {
alert("ok");
var drpvalue = document.getElementById("ddrstate").value;
// alert(drpvalue);
if (drpvalue == 0) {
return false;
}
$.ajax({
url: '@Url.Action("GetCity", "Home")',
dataType: "html",
data: { "sb": drpvalue },
type: "GET",
contentType: "application/json",
success: function (response) {
$('#partialCityView').html(response);
},
error: function (err) {
alert(err.responseText);
}
});
}
</script>
}
public ActionResult GetCity(int sb)
{
var cities = db.City_Name.Where(s => s.State_Id == sb).ToList();
List<SelectListItem> citylst = new List<SelectListItem>();
foreach (City_Name item in cities)
{
citylst.Add(new SelectListItem
{
Text = item.City,
Value = item.City_Id.ToString()
});
}
ViewBag.Citylist = citylst;
return View();
}
@{
Layout = null;
}
<div class="form-group col-md-6">
@Html.LabelFor(model => model.City, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(model => model.City, (IEnumerable<SelectListItem>)ViewBag.Citylist, "Select City", new { @class = "form-control col-md-3", @id = "ddrcity" })
@Html.ValidationMessageFor(model => model.City, "", new { @class = "text-danger" })
</div>
</div>
[HttpPost]
public ActionResult SignUp(FormCollection form)
{
User usr = new User();
usr.Name = form["First_Name"].ToString();
usr.Country = Convert.ToInt32(form["Country"].ToString());
usr.State = Convert.ToInt32(form["State"].ToString());
usr.City = Convert.ToInt32(form["City"].ToString());
}
Problem in design and on HttpPost not able to find value of selected state and city