473,394 Members | 1,750 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,394 software developers and data experts.

Need help writing special user control

Hi all!

I would like to create a user control that handles an unlimited amount of
templates. I suppose I would like to define the templates kind of like this:

<mycontrol datakeyfield="model" id="ctl" runat="server">
<template key="Ferrari">
<h1><%# Container.DataItem("model") %></h1><br>
<font color="red">Some text</font>
</template>
<template key="Jaguar">
<h1><%# Container.DataItem("model") %></h1><br>
<font color="black">Some text</font>
</template>
<template key="Lamborghini">
<h1><%# Container.DataItem("model") %></h1><br>
<font color="blue">Some text</font>
</template>
</mycontrol>

How do I achieve this? I've tried to declare the Template property of the
usercontrol like this:

<TemplateContainer(GetType(MegaItem))> public Property Template(key as
object) As ITemplate

....but I can't seem to solve it.

Please help

/john
Nov 18 '05 #1
3 898
Hi,

I guess you after Page.LoadTemplate(). Refer to:
http://msdn.microsoft.com/library/de.../en-us/vbcon/h
tml/vbgrfcreatingtemplatecolumnsdynamicallyindatalistw ebservercontrol.as
p

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #2
Hi

But will that let me use a number of different templates within the same
servercontrol? Plus, I would rather design the templates within tags on the
same page, than in files of their own.

/john

"Natty Gur" <na***@dao2com.com> wrote in message
news:uy****************@TK2MSFTNGP11.phx.gbl...
Hi,

I guess you after Page.LoadTemplate(). Refer to:
http://msdn.microsoft.com/library/de.../en-us/vbcon/h
tml/vbgrfcreatingtemplatecolumnsdynamicallyindatalistw ebservercontrol.as
p

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #3
Hi,

1) Yes:
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if (!Page.IsPostBack)
{
DataList1.DataSource = CreateDataSource();
DataList1.DataBind();
}
else
{
DataList1.AlternatingItemTemplate =
Page.LoadTemplate("b.ascx");
DataList1.DataSource = CreateDataSource();
DataList1.DataBind();
//DataList1.DataBind();
}
}

2) I'm not aware of other way, but I'll be happy to learn.

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #4

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

Similar topics

9
by: Robert Schneider | last post by:
Hi to all, I don't understand that: I try to delete a record via JDBC. But I always get the error SQL7008 with the error code 3. It seems that this has something to do with journaling, since the...
3
by: ssb | last post by:
Hello, This may be very elementary, but, need help because I am new to access programming. (1) Say, I have a column EMPLOYEE_NAME. How do I fetch (maybe, cursor ?) the values one by one and...
19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
4
by: Tim::.. | last post by:
I have asked this question several times and can't seem to get the answer I am looking for! I am trying to create a form that responds dynamically to the users choises within the page. At the...
13
by: James Bond | last post by:
Hello. My 80+ year old father has recently decided to get his first computer. Due to his age (and I suspect lack of playing pong as a child like I did) he lacks the manual dexterity to use a mouse...
5
by: Learner | last post by:
Hello, Here is the code snippet I got strucked at. I am unable to convert the below line of code to its equavalent vb.net code. could some one please help me with this? static public...
2
by: | last post by:
I want to use codebehind to pass property values to a control that I've embedded INSIDE of a user control. In other words, let's say I have the following: MyPage.aspx ....with the following...
5
by: Ming Yeung | last post by:
I was wondering if .NET had the equivalent of Frames, Global Objects, and most importantly DataModules like in Delphi?
1
by: shapper | last post by:
Hello, Consider I have a String: Dim MyString As String = "Hello" or an Integer: Dim MyInteger As Integer = 100
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.