public ActionResult UnitType() // STEP 1 : DISPLAY UnitType { UnitTypeModel objModel = new UnitTypeModel(); objModel.TypeOfUnit = new List<string>(); objModel.TypeOfUnit.Add("Evaporative Cooler"); objModel.TypeOfUnit.Add("Gas Ducted Heater"); objModel.TypeOfUnit.Add("Add On Cooling"); objModel.TypeOfUnit.Add("Ducted Reverse Cycle"); return View(objModel); } [AcceptVerbs(HttpVerbs.Post)] [HttpPost] public ActionResult UnitType(BrivisAfterSalesSupport.Models.UnitTypeModel objModel) // STEP 2 : POST { if (ModelState.IsValid) // ALL OK { Session["SelectedUnitType"] = objModel.SelectedUnitType; PropertyTypeModel objModelProp = new PropertyTypeModel(); objModelProp.lstTypeOfProperty = new List<TypeOfProperty>() { new TypeOfProperty {PropertyTypeId=1, PropertyTypeDescription="Single Story"}, new TypeOfProperty {PropertyTypeId=2, PropertyTypeDescription="Double Story or Higher"}, new TypeOfProperty {PropertyTypeId=3, PropertyTypeDescription="Multilevel Apartment"} }; return View("PropertyType", objModelProp); // STEP 3 : GO TO PropertyType VIEW } else { return UnitType(); } } public ActionResult PropertyType(BrivisAfterSalesSupport.Models.PropertyTypeModel objModel) //STEP 4 : DISPLAY PropertyTypes { return View(objModel); } [HttpPost] public ActionResult PropertyType(string SelectedPropertyType) //STEP 5: POST from PropertyType { if (!string.IsNullOrEmpty(SelectedPropertyType)) { return View("UnitLocation"); } else { //This is where I have issue // IF I DO THIS COMMENTED BIT THE VALIDATION SUMMARY DOES NOT WORK // PropertyTypeModel objModelProp = new PropertyTypeModel(); // objModelProp.lstTypeOfProperty = new List<TypeOfProperty>() { // new TypeOfProperty {PropertyTypeId=1, PropertyTypeDescription="Single Story"}, // new TypeOfProperty {PropertyTypeId=2, PropertyTypeDescription="Double Story or Higher"}, // new TypeOfProperty {PropertyTypeId=3, PropertyTypeDescription="Multilevel Apartment"} //}; //return View(objModelProp); return View(); // THIS ONE ALSO FAIL AS lstTypeOfProperty is null which is used in VIEW to display type of properties to select from } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)