hi frnds
i want to create page like EMPLoyee there 2 fields like Id and name and next button
2. after fillup the data if i click on nect button Emp_Address page will be come there also use 2 buttons
like prev and next
a>> after fillup the data click on nect button another page should be open..
b>> if i click on Prev button First page like Customer page should be open..
3. now 3 rd page will be there .
here details with 2 button will be there
Prev and Submit
a>> if i click on prev button before page should be open..
b>> if i click on submit button then next page should be open like
data saved successfully and all page summary should be display on this page..
but i want all things without data base in mvc4/mvc5...
Anjali KhanPosted Sep 7, 2016, 7:28 AM
this is my code..
1.i am unable to go previous button.
2. if i will go on next page again if i click on prev button then previous data is not showing which i filled..
3.in the submit button.
page 1
First Model//
public class Customer
{
[Required]
[Display(Name = "ID")]
public int ID { get; set; }
[Required]
[Display(Name = "Name")]
[RegularExpression(@"^.{6,10}$", ErrorMessage = "Name should be of minimum 6 and maximum 10 characters")]
public string Name { get; set; }
}
view//
2nd page
model///
public class CustomerDetails
{
[Required]
[Display(Name = "Address")]
public string Address { get; set; }
[Required]
[Display(Name = "MobNumber")]
public string MobNumber { get; set; }
}
view///
CUSTOMER DETAILS
@using (Html.BeginForm())
{
Address : @Html.TextBoxFor(m => m.Address)
MobNumber : @Html.TextBoxFor(m => m.MobNumber)
@**@
@Html.ActionLink("Prev", "CustDetails")
@Html.ActionLink("Next", "SalaryDetails")
}
3rd page
model
public class Salary
{
[Required]
[Display(Name = "CustSalary")]
public Decimal CustSalary { get; set; }
[Required]
[Display(Name = "Experience")]
public string Experience { get; set; }
}
view ///
SALARY DETAILS
@using (Html.BeginForm())
{
CustSalary : @Html.TextBoxFor(m => m.CustSalary)
Experience : @Html.TextBoxFor(m => m.Experience)
@Html.ActionLink("Prev", "CustDetails")
}
controller for the all///
public class EmpDetailsController : Controller
{
// GET: EmpDetails
public ActionResult Customer()
{
return View();
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Customer(Customer model)
{
if (ModelState.IsValid)
{
//ViewBag.ID = model.ID;
//ViewBag.Name = model.Name;
Customer obj = new Customer();
obj.Name = obj.Name.ToString();
Session["Customer"] = obj;
}
return View(model);
}
[HttpGet]
public ActionResult CustDetails()
{
return View();
}
[HttpPost]
public ViewResult CustDetails(CustomerDetails model)
{
//ViewBag.Address = model.Address;
//ViewBag.MobNumber = model.MobNumber;
if (ModelState.IsValid)
{
CustomerDetails obj = new CustomerDetails();
obj.Address = obj.Address.ToString();
obj.MobNumber = obj.MobNumber.ToString();
Session["CustomerDetails"] = obj;
}
return View("CustDetails");
}
[HttpGet]
public ActionResult SalaryDetails()
{
return View();
}
[HttpPost]
public ViewResult SalaryDetails(Salary model)
{
//ViewBag.CustSalary = model.CustSalary;
//ViewBag.Experience = model.Experience;
if (ModelState.IsValid)
{
Salary obj = new Salary();
obj.CustSalary = obj.CustSalary;
obj.Experience = obj.Experience.ToString();
}
return View("SalaryDetails");
}
[HttpGet]
public ActionResult Summary()
{
return View();
}
[HttpPost]
public ViewResult Summary(Salary model)
{
return View("Record Saved Successfully");
}
}
Bikesh SrivastavaPosted Sep 7, 2016, 5:22 AM
Manas MohapatraPosted Sep 7, 2016, 4:53 AM