Answered by:
Itemplate help

Question
-
User-334574633 posted
Hello,
I have an application that uses the INamingContainer and i allow the user to design some part of the design like this:
<myControl:Control1 id="test" runat="server">
<PhotoTemplate>
<<PHOTO>><br />
<<DATE>>
</PhotoTemplate>
</myControl>i capture this in my webcontrol like this:
[
ParseChildren(false)]
public class myControl : WebControl, INamingContainer
{
ITemplate m_Photos = null;
[PersistenceMode(PersistenceMode.InnerProperty), TemplateContainer(typeof(TemplateItem))]
public ITemplate PhotoTemplate
{
get
{
return m_Photos;
}
set
{
Photos = value;
}
}
}class
TemplateItem : Control, INamingContainer
{
private String _message = null;
public TemplateItem(String message)
{
_message = message;
}
public String Message
{
get
{
return _message;
}
set
{
_message = value;
}
}
}2 questions.
1) Do i need something else to use this m_Photos variable?, i want to get the design and put in the data where the user has entered the datatag, like in the case above, i would want to change the <<PHOTO>> to a string that contains the actual photo and the same with <<DATE>>
I have a function that loops thru a list of all the available photos and in there i want to incorperate this design function, to print the photos according to the users wish.
2) How do i add categories to the designs? like:
<myControl:Control1 id="test" runat="server">
<Photo>
<PhotoTemplate>
<<PHOTO>><br />
<<DATE>>
</PhotoTemplate>
<PhotoSeperator>
<hr />
</PhotoSeperator>
</Photo>
</myControl>Patrick
Friday, April 25, 2008 11:37 AM
Answers
-
User-1136466523 posted
Hi,
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>From your description, it seems that you are going to create the template in your custom control, right?
<o:p> </o:p>I suggest that you should try to following link which shares a step by step tutorial guide on how to create the a Non-Databound Templated Server Control.
<o:p> </o:p><o:p> </o:p>http://msdn.microsoft.com/en-us/library/aa478964.aspx
Building a Non-Databound Templated Server Control
<o:p> </o:p>Thanks.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, April 29, 2008 1:42 AM
All replies
-
User-1136466523 posted
Hi,
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>From your description, it seems that you are going to create the template in your custom control, right?
<o:p> </o:p>I suggest that you should try to following link which shares a step by step tutorial guide on how to create the a Non-Databound Templated Server Control.
<o:p> </o:p><o:p> </o:p>http://msdn.microsoft.com/en-us/library/aa478964.aspx
Building a Non-Databound Templated Server Control
<o:p> </o:p>Thanks.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, April 29, 2008 1:42 AM -
User-16411453 posted
Those are called collections. It's really complicated.
You need 3 files
One is your control - control.cs - The actual control file
Two is the collection editor - Control_CollectionEditor.cs - The actual property collections
Three is Items - Control_Items.cs - All the functions to add, edit and delete items
here's a bad example of collections
http://msdn.microsoft.com/en-us/library/ms178654.aspx
I have a post on it from a few weeks ago, look it up
Wednesday, April 30, 2008 7:49 PM