473,405 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Programmaticly load a custom UserControl with in a custom class which implements an ITemplate

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.

Oct 5 '06 #1
0 1536

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Nick | last post by:
My client uses a SQL Database to store their usernames and passwords, and I do not believe they have AD...no big deal... I wrote a class to create a generic identity and generic principal so that...
8
by: Tinus | last post by:
Hello all, I've create a custom control (UserControl) and have a custom Item Collection. The control is a custom calendar which is draw using the Graphics Rectangle etc. functions. It is drawn...
1
by: Big Dave | last post by:
Good morning. This group has been a great help so far, and it is much appreciated. Here's my new question. I want to be able to create a datagrid at runtime, which will have template columns...
2
by: Alex Nitulescu | last post by:
Hi. I have a web.config which says that all files with the "axd" extension should by a special handler. The handler writes some stats to the "axd" page. Public Class WhosOnHandler Implements...
0
by: Shapper | last post by:
Hello, I have a class which I am calling as follows: ... column.ItemTemplate = CreateItemTemplate() ... Function CreateItemTemplate() As ITemplate Return New ItemTemplate End Function ...
0
by: Syed Zaidi via .NET 247 | last post by:
I am working on a small project in which i want to develop acustom toolbar skeleton for handling database navigation. I havecreated a usercontrol consist of a toolbar inherits fromusercontrol and...
2
by: AMDRIT | last post by:
Hello everyone, I have created a custom component and one of its properties is a class object with it's own properties. During runtime, I can assign values to the class object properties just...
0
by: Isz | last post by:
PROBLEM: This problem is related to the postback and handling events correctly. BACKGROUND: I have a datalist which acts as a tabbes list with horizontal layout. This datalist is bound to a...
1
by: wojski696969 | last post by:
Hi, i've made my own Custom Server Control, wich inherits from WebControl class. Inside of my control I've create three ITemplate properties wich should be used as containers for Head, Content and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.