开发者

Forcing controls to contain only certain elements, such as ContentTemplate

Ok, my team has been having issues with the ajaxToolkit Tabs control, it doesn't play nice with parts of our site (mainly jquery issues, some other javascript, too many things to change)

So, I plan to write a different control that uses jQuery to achieve the tabbing functionality: I've done this before, and the jQuery is almost trivial. The thing I am having issues with is getting the Control itself to emulate the AjaxToolkit control, I'd like it to be a proper webcontrol with a content/header template structure.

However, I cannot seem to force asp to only allow these tags inside, as a repeater does with it's various <*template> tags, only get it to display these tags as opti开发者_如何转开发ons inside the markup. How would I achieve this functionality?


The ContentTemplate like say a Repeater uses an ITemplate property with a few attribues, here's the pertinent info:

[ParseChildren(true), PersistChildren(false)]
public class Repeater : Control, INamingContainer
{
  [PersistenceMode(PersistenceMode.InnerProperty)]
  public virtual ITemplate HeaderTemplate { get; set; }

  [PersistenceMode(PersistenceMode.InnerProperty)]
  public virtual ITemplate ItemTemplate { get; set; }
}

It's a combination of ParseChildrenAttribute, PersistenceModeAttribute, and using the PersistChildrenAttribute to display them as inner tags.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜