Terry

Terry

  • NA
  • 148
  • 0

Add User/Custom Controls in Web Page

Apr 23 2015 1:16 PM

Hello, 

   Using ASP.NET 4.5 WinForms
   Friends I have 3 Models :
public class NameModel {
   
   public NameModel() { }

  [EnumDataType(typeof(Suffix)), Display(Name = "Suffix *")]
   [Required(ErrorMessage = "Suffix is Required")]
   public Suffix NameSuffix { get; set; }

   [Display(Name = "First Name *", Prompt = "First Name")]
   [Required(ErrorMessage = "First Name is Required")]
   [StringLength(50, MinimumLength = 1, ErrorMessage = "First Name cannot be 1 char or longer than 50 characters.")]
   [RegularExpression(@"^[A-Z]+[a-zA-z''-'\s]*$", ErrorMessage = "First Name can only have alphabets and Inital capital")]
   public string FirstName { get; set; }

   [Display(Name = "Last Name *")]
   [Required(ErrorMessage = "Last Name is Required")]
   [StringLength(50, MinimumLength = 1, ErrorMessage = "Last Name cannot be of 1 char or longer than 50 characters.")]
   [RegularExpression(@"^[A-Z]+[a-zA-z''-'\s]*$", ErrorMessage = "Last Name can only have alphabets and Inital capital")]
   public string LastName { get; set; }
}

Address Model
public class AddressModel {
   // Similar like above with Address Properties
}

Inquiry Model
public class Inquiry {

    public Date InquiryDate { get; set; }
    public NameModel Name { get; set; }

    public AddressModel Address { get; set;  }

    // And other properties.
}

My Inquiry Page already inherits from Site.Master page. I may also create a normal web page & add the controls for NameModel & AddressModel respectively. And add that form as a ContentHolder in other form. I am not able to get, how do I in-corporate the NameModel & AddressModel in Inquiry pages that has <InsertTemplete>, <EditTemplate>, <ItemTemplate> .

Can you tell me how can I do this. I need these controls in almost 12-15 pages. So, I believe making it common & inheriting somehow would be definitely beneficial. But I am not able to get it. Kindly guide me thru this. 
Any help is highly appreciated.

Thanks






Answers (2)