Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Persisting properties in templates

Thread Tools

Persisting properties in templates

Alessandro Zifiglio
Posts: n/a

I'm creating a custom web control and I'm pretty much stuck in templates.
Everything is working great, I have no problems, even if the documentation
on templates is not very clear most of the time and this being my first
custom control I had to scratch my head plenty before I could implement this
feature into my custom control. Ok now I need to implement style properties
in my template.

To really cut this short, I need my style properties to be properties that
you can set in the template itself like :
<mycontrol:name id="bla" runat="server">
<HeaderTemplate border="bla" backcolor="bla" ... .></HeaderTemplate>

as of now i can make these style properties show in the control itself as
subproperties like PropertyName-SubPropertyName for example :

<mycontrol:name id="bla" . . . runat="server"

<HeaderTemplate border="bla" backcolor="bla" ... .></HeaderTemplate>


HeaderStyle being a public expandable property declared in mycontrol class.
Now HeaderStyle is presented as PropertyName-SubPropertyName in mycontrol.
However this is not what i want and does this for me when i prefix
PersistenceMode(PersistenceMode.InnerProperty) to the property HeaderStyle.
Whereas if i prefixed
DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content) creates an element for that particular property and displays all sub
properties within it. Again this is not what i want.

What i want is for the properties to show in my custom template. I have
tried declaring the property Headerstye in my template class and then
prefixing PersistenceMode(PersistenceMode.InnerProperty) to my templates
declaration in mycontrol class which didnt do the trick. I've done various
experiments and i must say my efforts were useless

Like if any of you has looked at the datagrid, its got templates and within
the template you can specify the style attributes there like :

<aspataGrid id="DataGrid1" . . . . .runat="server">
<HeaderStyle BackColor="#FFC0C0"></HeaderStyle>
<ItemStyle BackColor="#FFFFC0"></ItemStyle>
<FooterStyle BackColor="#C0C0FF"></FooterStyle>

In the docs i see an example under PersistenceMode Enumeration which looks
like what i might want to do but its incomplete EEEEEEEEEEE.. .ks!!!

[Visual Basic]

TemplateContainer(GetType(TemplateItem))> Public Property MessageTemplate()
As ITemplate
Return _messageTemplate
End Get
Set(ByVal Value As ITemplate)
_messageTemplate = Value
End Set
End Property

public ITemplate MessageTemplate {
get {
return _messageTemplate;
set {
_messageTemplate = value;

How do i associate the properties to persist . . .it does not elaborate any
further. I have looked into almost anything i could get my hands on and i
always come to a dead end.

I'm hoping that someone has already been able to achieve this. I have looked
on the forums too, nothing. I'm desperate. Hopefully if nobody knows
the answer to this maybe someone from microsoft might want to join in and
let me on this well kept secret .. hhaha

This is a very basic implementation anybody might want to achieve when using
templates. And there is no article, content, documentation related to
properties in templates.


Reply With Quote

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
how to Specializations of function Templates or Overloading Function templates with Templates ? recover C++ 2 07-25-2006 02:55 AM
Persisting Properties? eNew ASP .Net 1 11-21-2005 04:09 PM
Templates templates templates JKop C++ 3 07-21-2004 11:44 AM
extender provider properties not persisting ! JezB ASP .Net 1 06-22-2004 10:04 AM
Persisting properties in templates and not the control itself Alessandro Zifiglio ASP .Net Building Controls 0 11-09-2003 11:31 AM