Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Building Controls (http://www.velocityreviews.com/forums/f59-asp-net-building-controls.html)
-   -   Persisting properties in templates and not the control itself (http://www.velocityreviews.com/forums/t756066-persisting-properties-in-templates-and-not-the-control-itself.html)

Alessandro Zifiglio 11-09-2003 11:31 AM

Persisting properties in templates and not the control itself
 
hi,

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>
</mycontrol:name>

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"
Headerstyle-BorderColor="darkolivegreen">

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

</mycontrol:name>


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 vs.net does this for me when i prefix
PersistenceMode(PersistenceMode.InnerProperty) to the property HeaderStyle.
Whereas if i prefixed
DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content)
vs.net 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 :

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


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]

<PersistenceMode(PersistenceMode.InnerProperty),
TemplateContainer(GetType(TemplateItem))> Public Property MessageTemplate()
As ITemplate
Get
Return _messageTemplate
End Get
Set(ByVal Value As ITemplate)
_messageTemplate = Value
End Set
End Property

[C#]
[PersistenceMode(PersistenceMode.InnerProperty),
TemplateContainer(typeof(TemplateItem))]
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 asp.net 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.

Thanks
Alessandro




All times are GMT. The time now is 08:23 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.