title: User Control and constructor
body: <p>i have built a user control with web controls in ascx page.
  //ascx file</p>
  
  <pre><code> &lt;%@ Control Language="C#" AutoEventWireup="true" ClassName="Product"CodeFile="Product.ascx.cs" Inherits="Usercontrols_Product" %&gt;
  &lt;link href="../StyleSheet/StyleSheet.css" rel="stylesheet" type="text/css" /&gt;
  &lt;div&gt;
  &lt;asp:Panel ID="box" CssClass="productBox" runat="server"&gt;
   &lt;asp:Image ID="imgProduct"  CssClass="productImage"  runat="server" /&gt;&lt;br /&gt;
   &lt;asp:Label ID="lblProductName" CssClass="productLbl"  runat="server"&gt;&lt;/asp:Label&gt;&lt;br/&gt;
   &lt;asp:Label ID="lblProductPrice" CssClass="productLbl"  runat="server"&gt;&lt;/asp:Label&gt;
  &lt;/asp:Panel&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>in the cs file of user control i created acontructor which get another class reference.
  whith the class i get in contructor i want insert data to child controls.
  //ascx.cs file</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  
  public partial class Usercontrols_Product : System.Web.UI.UserControl
  {
      public EventHandler cmdDetailsClick;
      protected Product thisProduct; 
      public Usercontrols_Product( Product pr)
      {
  
          thisProduct = pr;
          imgProduct.ImageUrl = thisProduct.ImageUrl;
          lblProductName.Text = thisProduct.CompanyName + "&lt;br/&gt;" +      thisProduct.ProductName + "&amp;nbsp" + thisProduct.Model;
          lblProductPrice.Text = thisProduct.Price.ToString() + "&amp;nbsp" + "israeli shekel";
  
      }
      public Usercontrols_Product()
      {
  
      }
  
      protected void cmdContinue_clicked(object sender, EventArgs e)
      {
          //we send to event product class of sender
          if (cmdDetailsClick != null)
              cmdDetailsClick(thisProduct, EventArgs.Empty);
      }
  }
  </code></pre>
  
  <p>the problem is that now with spesial constructor web controls from aspx file are not being 
  initiallized. i tried initiallize them in code with new keyword but than they are with no attributes from ascx file. with no special constructor its works fine .but i need this special constructor. how can i initiallize this webcontrols whith their attributes from ascx file </p>