1

Hopefully an easy one, I have created a Custom Repeater control that extends System.Web.UI.WebControls.Repeater. I Have added two ITemplate Properties to this control and add these when required and in the desired manner. Everything is working absolutely fine but I'm having a problem in Visual Studio having these new Templates recognised.

When I add the repeater to the page, e.g:

<my:Repeater ID="rpt" runat="server" NewProperty="This works!">
    <NewTemplate>The contents go here...</NewTemplate>
</my:repeater>

Everything is working (woo!) and when I add the attributes 'NewProperty', a property I have added, can be seen in Intellisense in Visual Studio as expected (woo!). Annoyingly though the new ITemplate's are not available via Intellisense and this has to be recalled from my knowledge of them being there (boo!). The new template also has the 'problem' underline with the following message:

Validation (XHTML 1.0 Transitional): Element 'newtemplate' is not supported.

It's not a major issue by any means as when compiled the custom repeater works and the templates behave as they need to, it's more of an annoyance that would be great to sort out.

Thanks for any help!

Steve

stibstibstib
  • 109
  • 7

1 Answers1

2

XHTML requires that Element names begin with a Lower Case. HTML is not case sensitive, while XHTML is.

Source: http://www.w3.org/TR/xhtml1/#h-4.2

In order for the property to be visible, you need to add the PersistenceMode attribute to your ITemplate properties as follows:

[PersistenceMode(PersistenceMode.InnerProperty)]
public ITemplate NewTemplate
{
   get;
   set;
}
Jose Basilio
  • 50,714
  • 13
  • 121
  • 117
  • Hi Jose, I'm not sure you've understood the issue as ItemTemplate, HeaderTemplate etc are capitalised. The problem is the fact that Visual Studio doesn't recognise the Templates so it assumes they are XHTML elements which they are not. I hoped there's a way to ensure that VS knows about them. – stibstibstib Apr 16 '09 at 13:38
  • Is this a user control or a server control? – Jose Basilio Apr 16 '09 at 15:58
  • Public Class Repeater Inherits System.Web.UI.WebControls.Repeater .... It's an enhanced server control – stibstibstib Apr 16 '09 at 16:19
  • 1
    You need to add the following attribute to your ITemplate properties [PersistenceMode(PersistenceMode.InnerProperty)] – Jose Basilio Apr 16 '09 at 16:52