I am having some trouble. How would one load a custom UserControl fro
within a class which impements the ITemplate interface.
Currently I have the following:
public class SmallProductViewTemplate : ITemplate
{
public void InstantiateIn(Control container)
{
HyperLink productImage = new HyperLink();
productImage.CssClass = "ProductImage";
productImage.DataBinding += new
EventHandler(ProductImage_DataBinding);
container.Controls.Add(productImage);
//other asp.net controls are loaded here...
}
...
private void ProductImage_DataBinding(object sender, EventArgs e)
{
HyperLink image = (HyperLink)sender;
DataListItem container = (DataListItem)image.NamingContainer;
image.ImageUrl = String.Format("{0}{1}{2}",
SiteConstants.ImageBaseUrl, SiteConstants.SmallImagePath,
DataBinder.GetPropertyValue(container.DataItem,
"ImageSmallFileName").ToString());
image.NavigateUrl = String.Format("{0}?productID={1}",
PageConstants.Product, DataBinder.GetPropertyValue(container.DataItem,
"ProductID").ToString());
image.Text = DataBinder.GetPropertyValue(container.DataItem,
"DisplayName").ToString();
}
}
Instead of loading a bunch of asp.net controls, I would like to load a
single user control, which encapsulates the design, to use inside the
template.