Ideal model strurcture for an mvc project for handeling multiple partial views
I have two partial views named as _centerDetails.cshtml and _centerRights.cshtml .I am passing data from centerdetails when i click on submit and want to show this when other partial view is switched but without posting it to server.
Question Update
I found that my question was not well explained.
This is my model class which i have created to handling my data via controler.
namespace ADWP_AdminWebPortal.Models {
public class CountryList
{
[Required(ErrorMessage = "Select a Country.")]
public int CountryId { get; set; }
[Required]
public string Country { get; set; }
[Required(ErrorMessage = "Select a State.")]
public int StateId { get; set; }
[Required]
public string State { get; set; }
[Required(ErrorMessage = "Select a City.")]
public int CityId { get; set; }
[Required]
public string City { get; set; }
}
public class CustomerDetails: CountryList
{
public int ClientId { get; set; }
[Required (ErrorMessage="Eneter the First name")]
[DataType(DataType.Text)]
public string FirstName { get; set; }
[Required(ErrorMessage = "Eneter the Middle name")]
[DataType(DataType.Text)]
public string MiddleName { get; set; }
[Required(ErrorMessage="Please Enter Valid Mobile No")]
[DataType(DataType.PhoneNumber)]
public string MobileNo { get; set; }
[Required(ErrorMessage = "Please Enter Valid Mobile No")]
[DataType(DataType.PhoneNumber)]
public string MobileNo2 { get; set; }
[Required(ErrorMessage = "Please Enter Valid Mobile No")]
[DataType(DataType.PhoneNumber)]
public string LandLine { get; set; }
[Required(ErrorMessage = "Please Enter Valid Mobile No")]
[DataType(DataType.PhoneNumber)]
public string LandLine2 { get; set; }
[Required(ErrorMessage = "Eneter the Last name")]
[DataType(DataType.Text)]
public string LastName { get; set; }
public string NickName { get; set; }
[Required(ErrorMessage = "Enter The Address")]
[MaxLength(300)]
public string Address { get; set; }
[Required (ErrorMessage ="Enter the Zipcode.")]
[DataType(DataType.PostalCode)]
[Range(4,6)]
public string ZipCode { get; set; }
[Required(ErrorMessage = "Please Enter Email Id")]
[DataType(DataType.EmailAddress)]
[MaxLength(50)]
[RegularExpression(@"[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}", ErrorMessage = "Please enter correct email")]
public string EmailId { get; set; }
[Required(ErrorMessage = "Please Enter Email Id")]
[DataType(DataType.EmailAddress)]
[MaxLength(50)]
[RegularExpression(@"[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}", ErrorMessage = "Please enter correct email")]
public string ConfirmEmailId { get; set; }
public string RefferalId { get; set; }
[Required(ErrorMessage="Select Any Occupation.")]
public string Occupatioin { get; set; }
public string NatureOfOccupation { get; set; }
public string AgentId { get; set; }
[Required(ErrorMessage ="Select a Client Type.")]
public string ClientType { get; set; }
public int TariffId { get; set; }
public string TariffName { get; set; }
public int ServiceId { get; set; }
public string ServiceName { get; set; }
public string OrderId { get; set; }
public int PaymentMethodId { get; set; }
public string PaymentMethodName { get; set; }
}
}
Here you can see the mess i have created. My problem is how to handle multiple models when you are working with multiple models in same controler?
Here i did not created all the data in a single class because i wanted it to reuse as per my need.
Have you guys any idea about handling data in a model this is the main problem that is coming to me while i am creating the partial views in my project.