Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Problem with usercontrol/itemplate

Reply
Thread Tools

Problem with usercontrol/itemplate

 
 
Thomas Wagner
Guest
Posts: n/a
 
      08-16-2007
Hi group,

I try to develop a gallery control, that uses templates for displaying.
Everything should (as I can say) be correct, but "InstantiateIn" does not
get the right data from my container-class.

The source looks like this, could someone please help me, I have no idea
what I did wrong!
(Note: When I change "Container.Url" to "Container.XXX", the compiler
recognizes, that XXX is not a member of ImageTemplateContainer.)

Thank you
Thomas

/* Container: */

public class ImageTemplateContainer : Control, INamingContainer
{
private String m_strUrl;
public String Url
{
get
{
return m_strUrl;
}
}

public ImageTemplateContainer(String NavUrl)
{
this.m_strUrl = NavUrl;
}
}

/* Control: */

[ToolboxData("<{0}:Gallery runat=server></{0}:Gallery>")]
[ParseChildren(true)]
[PersistChildren(false)]
public class Gallery : WebControl, INamingContainer
{
private ITemplate m_ImageTemplate = null;

[Browsable(false)]
[PersistenceMode(PersistenceMode.InnerProperty)]
[TemplateContainer(typeof(ImageTemplateContainer))]
public virtual ITemplate ImageTemplate
{
get { return m_ImageTemplate; }
set { m_ImageTemplate = value; }
}

private ImageTemplateContainer m_itcContainer;
public ImageTemplateContainer Container
{
get
{
return m_itcContainer;
}
}

protected override void CreateChildControls()
{
if (m_ImageTemplate != null)
{
Controls.Clear();

m_itcContainer = new ImageTemplateContainer("imagetest.jpg");
m_ImageTemplate.InstantiateIn(m_itcContainer);

Controls.Add(m_itcContainer);
}
else
{
this.Controls.Add(new LiteralControl("Nixda"));
}

//base.CreateChildControls();
}
}
/* aspx */

<cc1:Gallery ID="Gallery1" runat="server" EnableViewState="true" >
<ImageTemplate><%# Container.Url %></imageTemplate>
</cc1:Gallery>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem problem problem :( Need Help Mike ASP General 2 05-11-2004 08:36 AM



Advertisments