I am developing one application in asp.net mvc. I have tab panel on my view in which I am binding two jquery datatables using serverside pagination on each tab. I have custom search panels above each datatable. these search panels have form tag and one search button. Whenever I click on search button from first tab , I am getting values from
Request.Form.GetValues("draw").FirstOrDefault()
, But when I am clicking search button on second form I am not able to get draw, length and start values of datatable.
Here is my first tab search panel form
@using (Html.BeginForm("SearchFilter", "Store", FormMethod.Post))
{
<div class="row">
<div class="col-lg-3">
<label>Search</label>
<div class="form-group">
@Html.TextBoxFor(model => model.SearchPanel.SearchText, new { @class = "form-control" })
</div>
</div>
<div class="col-lg-3">
<label>Brand</label>
<div class="form-group">
@Html.ListBoxFor(model => model.SearchPanel.BrandSelected, new SelectList(Model.SearchPanel.Brands, "Id", "Name"), new { htmlAttributes = new { @class = "form-control" } })
</div>
</div>
<div class="col-lg-4">
<label>City</label>
<div class="form-group">
@Html.ListBoxFor(model => model.SearchPanel.CitySelected, new SelectList(Model.SearchPanel.Cities, "Id", "Name"), new { @class = "form-control" })
</div>
</div>
<div class="col-lg-2">
<button id="btnSearch" type="submit" class="btn btn-info btnshadow">Search</button>
</div>
</div>
}
and here is my secod tab seach panel
<div class="row">
<div class="col-lg-3">
<label>Search</label>
<div class="form-group">
@Html.TextBoxFor(model => model.SearchPanelMaster.SearchText, new { @class = "form-control", id = "SearchTextMaster" })
</div>
</div>
<div class="col-lg-3">
<label>Brand</label>
<div class="form-group">
@Html.ListBoxFor(model => model.SearchPanelMaster.BrandSelected, new SelectList(Model.SearchPanelMaster.Brands, "Id", "Name"), new { @class = "form-control", id = "BrandSelectedMaster" })
</div>
</div>
<div class="col-lg-4">
<label>City</label>
<div class="form-group">
@Html.ListBoxFor(model => model.SearchPanelMaster.CitySelected, new SelectList(Model.SearchPanelMaster.Cities, "Id", "Name"), new { @class = "form-control", id = "CitySelectedMaster" })
</div>
</div>
<div class="col-lg-2">
<button id="btnSearchMaster" type="submit" class="btn btn-info btnshadow">Search</button>
</div>
</div>
}
In controller I have,
[HttpPost]
public ActionResult SearchFilter(StoreListViewModel model)
{
if (Session["AccessInfo"] == null)
{
return RedirectToAction("SessionTimeOut", "Home");
}
ViewBag.Tab = "";
TempData["Query"] = model;
TempData.Keep();
model.SearchPanel.Cities = new SellerBl().GetCities();
model.SearchPanel.Brands = new BrandBl().GetBrands(Constants.Status.Active);
model.SearchPanelMaster.Cities = new SellerBl().GetCities();
model.SearchPanelMaster.Brands = new BrandBl().GetBrands(Constants.Status.Active);
ViewBag.Success = false;
return View("StoreList", model);
}
public ActionResult SearchFilterMaster(StoreListViewModel model)
{
if (Session["AccessInfo"] == null)
{
return RedirectToAction("SessionTimeOut", "Home");
}
ViewBag.Tab = "";
TempData["QueryMaster"] = model;
TempData.Keep();
model.SearchPanel.Cities = new SellerBl().GetCities();
model.SearchPanel.Brands = new BrandBl().GetBrands(Constants.Status.Active);
model.SearchPanelMaster.Cities = new SellerBl().GetCities();
model.SearchPanelMaster.Brands = new BrandBl().GetBrands(Constants.Status.Active);
ViewBag.Success = false;
return View("StoreList", model);
}
[HttpPost]
public ActionResult LoadMasterData()
{
ViewBag.Tab = "";
var draw = Request.Form.GetValues("draw").FirstOrDefault();
var length = Request.Form.GetValues("length").FirstOrDefault();
var start = Request.Form.GetValues("start").FirstOrDefault();
int pageSize = length != null ? Convert.ToInt32(length) : 0;
int skip = start != null ? Convert.ToInt16(start) : 0;
int pageNo = skip == 0 ? 1 : (skip / pageSize) + 1;
var stores = new EPagination<StoreViewModel>();
var model = new StoreListViewModel();
if (TempData["QueryMaster"] != null)
{
model = (StoreListViewModel)TempData["QueryMaster"];
}
ESearchRequest request = new ESearchRequest()
{
ItemCount = pageSize,
Name = model.SearchPanelMaster.SearchText != null ? model.SearchPanelMaster.SearchText : "",
PageNumber = pageNo,
BrandIds = model.SearchPanelMaster.BrandSelected != null ? model.SearchPanelMaster.BrandSelected.ToList() : null,
CityIds = model.SearchPanelMaster.CitySelected != null ? model.SearchPanelMaster.CitySelected.ToList() : null
};
try
{
UserProfileViewModel userProfile = (UserProfileViewModel)System.Web.HttpContext.Current.Session["UserProfile"];
if (userProfile.Roles.Any(r => r.RoleName.Equals(Role.OperationAdmin)))
{
stores = storeBl.GetStores(Constants.Status.Pending, request);
}
else if (userProfile.Roles.Any(r => r.RoleName.Equals(Role.Operation)))
{
stores = storeBl.GetStores(Constants.Status.All, request);
}
else if (userProfile.Roles.Any(r => r.RoleName.Equals(Role.Viewer)))
{
stores = storeBl.GetStores(Constants.Status.All, request);
}
var data = stores.PageData;
return Json(new { draw, recordsFiltered = stores.TotalRecords, recordsTotal = stores.TotalRecords, data }, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
throw ex;
}
}
[HttpPost]
public ActionResult LoadData()
{
ViewBag.Tab = "";
var draw = Request.Form.GetValues("draw").FirstOrDefault();
var length = Request.Form.GetValues("length").FirstOrDefault();
var start = Request.Form.GetValues("start").FirstOrDefault();
int pageSize = length != null ? Convert.ToInt32(length) : 0;
int skip = start != null ? Convert.ToInt16(start) : 0;
int pageNo = skip == 0 ? 1 : (skip / pageSize) + 1;
var approvalStores = new EPagination<ApprovalStoreViewModel>();
var model = new StoreListViewModel();
if (TempData["Query"] != null)
{
model = (StoreListViewModel)TempData["Query"];
}
ESearchRequest request = new ESearchRequest()
{
ItemCount = pageSize,
Name = model.SearchPanel.SearchText !=null? model.SearchPanel.SearchText : "",
PageNumber = pageNo,
BrandIds = model.SearchPanel.BrandSelected != null ? model.SearchPanel.BrandSelected.ToList() : null,
CityIds = model.SearchPanel.CitySelected != null ? model.SearchPanel.CitySelected.ToList() : null
};
try
{
UserProfileViewModel userProfile = (UserProfileViewModel)System.Web.HttpContext.Current.Session["UserProfile"];
if (userProfile.Roles.Any(r => r.RoleName.Equals(Role.OperationAdmin)))
{
approvalStores = storeBl.GetApprovalStores(Constants.Status.Pending, request);
}
else if (userProfile.Roles.Any(r => r.RoleName.Equals(Role.Operation)))
{
approvalStores = storeBl.GetApprovalStores(Constants.Status.All, request);
}
else if (userProfile.Roles.Any(r => r.RoleName.Equals(Role.Viewer)))
{
approvalStores = storeBl.GetApprovalStores(Constants.Status.All, request);
}
var data = approvalStores.PageData;
return Json(new { draw, recordsFiltered = approvalStores.TotalRecords, recordsTotal = approvalStores.TotalRecords, data }, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
throw ex;
}
}
whenever I am clicking on second search panel search button I am not getting
var draw = Request.Form.GetValues("draw").FirstOrDefault();
var length = Request.Form.GetValues("length").FirstOrDefault();
var start = Request.Form.GetValues("start").FirstOrDefault();
these values
What I have tried:
I don't know why this is happening, should I remove tab panel or do something else