D
davidr
Hi,
I creted a usercontrol which has an ITemplate in it named ItemTemplate.
I am using ASP 2.0.
When I drag the user control on to my .aspx page everything looks fine.
Once I add the
<ItemTemplate></ItemTemplate> tags the control no longer displays
inside the design viewer. I can add any asp, html or other controls in
between the <ItemTemplate></ItemTemplate> and they appear when I run
the webpage. Why do these not appear in my designer view? Also, is
there a way so I can make the <ItemTemplate> editable in the designer
view like you can with the asp:gridview. In the asp:gridview you are
able to click Edit Templates, select one and put whatever HTML you want
right there in the designer view. Then click End Editing and it goes
back to the normal control view. I am doing this with a User Control
because it saves a lot of time of trying to create my own web user
control. I know when you create a web control you have to set up the
GetDesignerHTML() in order to see it in design view, but I didn't read
about anything like that for user controls. All the Item template is a
place holder for the HTML that will be defined in the .aspx page
between <ItemTemplate></ItemTemplate>.
Also, Yes I did instantiate the ItemTemplate as shown below.
private ITemplate _itemTemplate;
[PersistenceMode(PersistenceMode.InnerProperty),
TemplateContainer(typeof(TemplateControl))]
public ITemplate ItemTemplate
{
get { return _itemTemplate; }
set { _itemTemplate = value; }
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
if (_itemTemplate != null)
{
_itemTemplate.InstantiateIn(this.AspPlaceHolder);
}
}
Thank you,
David
I creted a usercontrol which has an ITemplate in it named ItemTemplate.
I am using ASP 2.0.
When I drag the user control on to my .aspx page everything looks fine.
Once I add the
<ItemTemplate></ItemTemplate> tags the control no longer displays
inside the design viewer. I can add any asp, html or other controls in
between the <ItemTemplate></ItemTemplate> and they appear when I run
the webpage. Why do these not appear in my designer view? Also, is
there a way so I can make the <ItemTemplate> editable in the designer
view like you can with the asp:gridview. In the asp:gridview you are
able to click Edit Templates, select one and put whatever HTML you want
right there in the designer view. Then click End Editing and it goes
back to the normal control view. I am doing this with a User Control
because it saves a lot of time of trying to create my own web user
control. I know when you create a web control you have to set up the
GetDesignerHTML() in order to see it in design view, but I didn't read
about anything like that for user controls. All the Item template is a
place holder for the HTML that will be defined in the .aspx page
between <ItemTemplate></ItemTemplate>.
Also, Yes I did instantiate the ItemTemplate as shown below.
private ITemplate _itemTemplate;
[PersistenceMode(PersistenceMode.InnerProperty),
TemplateContainer(typeof(TemplateControl))]
public ITemplate ItemTemplate
{
get { return _itemTemplate; }
set { _itemTemplate = value; }
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
if (_itemTemplate != null)
{
_itemTemplate.InstantiateIn(this.AspPlaceHolder);
}
}
Thank you,
David