Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Designer Property Serialization -- Sycning inner properties to designer property window

Reply
Thread Tools

Designer Property Serialization -- Sycning inner properties to designer property window

 
 
Alexander Higgins
Guest
Posts: n/a
 
      07-21-2007
Hi,

I am just getting started developing custom user controls, and I am
having issues keep the inner properties of nested controls in sync
with the properties in the designer window. When I change a property
of a nested control in the properties window, the designer does not
automatically redraw itself. If I switch to HTML Mode and then return
to design mode, the control is redrawn. But If I switch back to HTML
Mode the inner properties are not updated.

However, If I change a property of my custom control or the font-bold
property of the nested control in the design window, the nested
control is refreshed and the inner properties are correctly updated.
How do I keep the two in sync? Am I missing something here? Do I
need to implement a TypeConverter and set NotifyParentProperty(True)
to keep the designer in sync with the properties window. If I do, how
can I implement one for web controls as I will have several controls
and do not feel like coding a wrapper for every property of every
control on the page. Or, is there some why to manually fire the event
that is raised when the nested control's font-bold is changed in the
properties window.

Also, what is the difference between refresh.repaint and refresh.all.
Does one only redraw the control on the designer while the other
recreates the controls properties and then redraws the control on the
designer?

Here is my code in the simplest form. Thanks for the help in
advance...

Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.WebControls
<Assembly: TagPrefix("Editor", "cms")>
<ParseChildren(True), Designer("System.Web.UI.Design.ControlDesigner,
System.Design"), DefaultProperty("Text"), ToolboxData("<cms:Editor
runat=server></cms:Editor>"),
RefreshProperties(RefreshProperties.Repaint)> Public Class Editor
Inherits System.Web.UI.WebControls.WebControl
Implements INamingContainer

Dim _text As String

<Bindable(True), Category("Appearance"), DefaultValue("")>
Property [Text]() As String
Get
Return _text
End Get

Set(ByVal Value As String)
_text = Value
End Set

End Property
Private _TitleLabel As Label
<Category("CMS"), Bindable(True),
DesignerSerializationVisibility(DesignerSerializat ionVisibility.Visible),
RefreshProperties(RefreshProperties.Repaint),
NotifyParentProperty(True),
PersistenceMode(PersistenceMode.InnerProperty)> _
Public Property [TitleLabel]() As Label
Get

Return _TitleLabel
End Get
Set(ByVal Value As Label)

_TitleLabel = Value
Me.ChildControlsCreated = False
Me.EnsureChildControls()

End Set
End Property

 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      07-22-2007
One thing that pops up is that if the Label exposed by the TitleLabel
property is actually created in CreateChildControls, the property would need
to be read-only. If you change that first, does it help at all?

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net


"Alexander Higgins" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ps.com...
> Hi,
>
> I am just getting started developing custom user controls, and I am
> having issues keep the inner properties of nested controls in sync
> with the properties in the designer window. When I change a property
> of a nested control in the properties window, the designer does not
> automatically redraw itself. If I switch to HTML Mode and then return
> to design mode, the control is redrawn. But If I switch back to HTML
> Mode the inner properties are not updated.
>
> However, If I change a property of my custom control or the font-bold
> property of the nested control in the design window, the nested
> control is refreshed and the inner properties are correctly updated.
> How do I keep the two in sync? Am I missing something here? Do I
> need to implement a TypeConverter and set NotifyParentProperty(True)
> to keep the designer in sync with the properties window. If I do, how
> can I implement one for web controls as I will have several controls
> and do not feel like coding a wrapper for every property of every
> control on the page. Or, is there some why to manually fire the event
> that is raised when the nested control's font-bold is changed in the
> properties window.
>
> Also, what is the difference between refresh.repaint and refresh.all.
> Does one only redraw the control on the designer while the other
> recreates the controls properties and then redraws the control on the
> designer?
>
> Here is my code in the simplest form. Thanks for the help in
> advance...
>
> Imports System.ComponentModel
> Imports System.Web.UI
> Imports System.Web.UI.WebControls
> <Assembly: TagPrefix("Editor", "cms")>
> <ParseChildren(True), Designer("System.Web.UI.Design.ControlDesigner,
> System.Design"), DefaultProperty("Text"), ToolboxData("<cms:Editor
> runat=server></cms:Editor>"),
> RefreshProperties(RefreshProperties.Repaint)> Public Class Editor
> Inherits System.Web.UI.WebControls.WebControl
> Implements INamingContainer
>
> Dim _text As String
>
> <Bindable(True), Category("Appearance"), DefaultValue("")>
> Property [Text]() As String
> Get
> Return _text
> End Get
>
> Set(ByVal Value As String)
> _text = Value
> End Set
>
> End Property
> Private _TitleLabel As Label
> <Category("CMS"), Bindable(True),
> DesignerSerializationVisibility(DesignerSerializat ionVisibility.Visible),
> RefreshProperties(RefreshProperties.Repaint),
> NotifyParentProperty(True),
> PersistenceMode(PersistenceMode.InnerProperty)> _
> Public Property [TitleLabel]() As Label
> Get
>
> Return _TitleLabel
> End Get
> Set(ByVal Value As Label)
>
> _TitleLabel = Value
> Me.ChildControlsCreated = False
> Me.EnsureChildControls()
>
> End Set
> End Property
>



 
Reply With Quote
 
 
 
 
Alexander Higgins
Guest
Posts: n/a
 
      07-23-2007
Thanks for the suggestion. I tries not understanding the logic, but
in any case it did not help. Making the property readonly prevents
the ability to set its properties at all. I must create the control
during the CreateChildControls events and after that what is set can
not be changed.

I am not trying to do anything complex here, I am simply making a
composite control. I need to offer the developers the ability to
modify the composites child controls via HTML Mode,and with the
properties window in Visual Studio.Net.

I just can't figure out why the property changes on the nested control
do not update globally when the changes are made. Even more
frustrating is in VS 2005 the properties chnages via the property
window are not refelected at all.

On Jul 22, 2:11 pm, "Teemu Keiski" <(E-Mail Removed)> wrote:
> One thing that pops up is that if the Label exposed by the TitleLabel
> property is actually created in CreateChildControls, the property would need
> to be read-only. If you change that first, does it help at all?
>
> --
> Teemu Keiski
> AspInsider, ASP.NET MVPhttp://blogs.aspadvice.com/jotekehttp://teemukeiski.net
>
> "Alexander Higgins" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed) ps.com...
>
>
>
> > Hi,

>
> > I am just getting started developing custom user controls, and I am
> > having issues keep the inner properties of nested controls in sync
> > with the properties in the designer window. When I change a property
> > of a nested control in the properties window, the designer does not
> > automatically redraw itself. If I switch to HTML Mode and then return
> > to design mode, the control is redrawn. But If I switch back to HTML
> > Mode the inner properties are not updated.

>
> > However, If I change a property of my custom control or the font-bold
> > property of the nested control in the design window, the nested
> > control is refreshed and the inner properties are correctly updated.
> > How do I keep the two in sync? Am I missing something here? Do I
> > need to implement a TypeConverter and set NotifyParentProperty(True)
> > to keep the designer in sync with the properties window. If I do, how
> > can I implement one for web controls as I will have several controls
> > and do not feel like coding a wrapper for every property of every
> > control on the page. Or, is there some why to manually fire the event
> > that is raised when the nested control's font-bold is changed in the
> > properties window.

>
> > Also, what is the difference between refresh.repaint and refresh.all.
> > Does one only redraw the control on the designer while the other
> > recreates the controls properties and then redraws the control on the
> > designer?

>
> > Here is my code in the simplest form. Thanks for the help in
> > advance...

>
> > Imports System.ComponentModel
> > Imports System.Web.UI
> > Imports System.Web.UI.WebControls
> > <Assembly: TagPrefix("Editor", "cms")>
> > <ParseChildren(True), Designer("System.Web.UI.Design.ControlDesigner,
> > System.Design"), DefaultProperty("Text"), ToolboxData("<cms:Editor
> > runat=server></cms:Editor>"),
> > RefreshProperties(RefreshProperties.Repaint)> Public Class Editor
> > Inherits System.Web.UI.WebControls.WebControl
> > Implements INamingContainer

>
> > Dim _text As String

>
> > <Bindable(True), Category("Appearance"), DefaultValue("")>
> > Property [Text]() As String
> > Get
> > Return _text
> > End Get

>
> > Set(ByVal Value As String)
> > _text = Value
> > End Set

>
> > End Property
> > Private _TitleLabel As Label
> > <Category("CMS"), Bindable(True),
> > DesignerSerializationVisibility(DesignerSerializat ionVisibility.Visible),
> > RefreshProperties(RefreshProperties.Repaint),
> > NotifyParentProperty(True),
> > PersistenceMode(PersistenceMode.InnerProperty)> _
> > Public Property [TitleLabel]() As Label
> > Get

>
> > Return _TitleLabel
> > End Get
> > Set(ByVal Value As Label)

>
> > _TitleLabel = Value
> > Me.ChildControlsCreated = False
> > Me.EnsureChildControls()

>
> > End Set
> > End Property- Hide quoted text -

>
> - Show quoted text -



 
Reply With Quote
 
Teemu Keiski
Guest
Posts: n/a
 
      07-30-2007
It does work if you call EnsureChildControls() in the getter and then expose
the control, it's standard pattern in exposing complex objects in ASP.NEt
Server Controls. (I'm just right now testing with VS200

If there is issue it could be that NotifyParentProperty is not defined on
the Label control at the main class level (and it cannot be since it's
limited to the property).So when something notifiable happens on the
TitleLabel, you should have a parent main prioperty wrapped to the property
of the TitleLabel so that it would work

Anyways the code currently working is:

Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Text
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls


<Assembly: TagPrefix("Editor", "cms")>
<ParseChildren(True), Designer("System.Web.UI.Design.ControlDesigner,
System.Design"), DefaultProperty("Text"), ToolboxData("<cms:Editor
runat=server></cms:Editor>"), _
RefreshProperties(RefreshProperties.Repaint)> _
Public Class Editor
Inherits System.Web.UI.WebControls.WebControl
Implements INamingContainer

'Dim _text As String

'<Bindable(True), Category("Appearance"), DefaultValue("")> _
'Property [Text]() As String
' Get
' Return _text
' End Get

' Set(ByVal Value As String)
' _text = Value
' End Set

'End Property

Protected Overrides Sub CreateChildControls()
_TitleLabel = New Label()
Controls.Add(_TitleLabel)
End Sub

Private _TitleLabel As Label
<Category("CMS"), Bindable(True), _
DesignerSerializationVisibility(DesignerSerializat ionVisibility.Visible), _
RefreshProperties(RefreshProperties.Repaint), _
NotifyParentProperty(True), _
PersistenceMode(PersistenceMode.InnerProperty)> _
Public ReadOnly Property [TitleLabel]() As Label
Get
EnsureChildControls()
Return _TitleLabel
End Get

End Property

End Class


--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net




"Alexander Higgins" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Thanks for the suggestion. I tries not understanding the logic, but
> in any case it did not help. Making the property readonly prevents
> the ability to set its properties at all. I must create the control
> during the CreateChildControls events and after that what is set can
> not be changed.
>
> I am not trying to do anything complex here, I am simply making a
> composite control. I need to offer the developers the ability to
> modify the composites child controls via HTML Mode,and with the
> properties window in Visual Studio.Net.
>
> I just can't figure out why the property changes on the nested control
> do not update globally when the changes are made. Even more
> frustrating is in VS 2005 the properties chnages via the property
> window are not refelected at all.
>
> On Jul 22, 2:11 pm, "Teemu Keiski" <(E-Mail Removed)> wrote:
>> One thing that pops up is that if the Label exposed by the TitleLabel
>> property is actually created in CreateChildControls, the property would
>> need
>> to be read-only. If you change that first, does it help at all?
>>
>> --
>> Teemu Keiski
>> AspInsider, ASP.NET
>> MVPhttp://blogs.aspadvice.com/jotekehttp://teemukeiski.net
>>
>> "Alexander Higgins" <(E-Mail Removed)> wrote in message
>>
>> news:(E-Mail Removed) ps.com...
>>
>>
>>
>> > Hi,

>>
>> > I am just getting started developing custom user controls, and I am
>> > having issues keep the inner properties of nested controls in sync
>> > with the properties in the designer window. When I change a property
>> > of a nested control in the properties window, the designer does not
>> > automatically redraw itself. If I switch to HTML Mode and then return
>> > to design mode, the control is redrawn. But If I switch back to HTML
>> > Mode the inner properties are not updated.

>>
>> > However, If I change a property of my custom control or the font-bold
>> > property of the nested control in the design window, the nested
>> > control is refreshed and the inner properties are correctly updated.
>> > How do I keep the two in sync? Am I missing something here? Do I
>> > need to implement a TypeConverter and set NotifyParentProperty(True)
>> > to keep the designer in sync with the properties window. If I do, how
>> > can I implement one for web controls as I will have several controls
>> > and do not feel like coding a wrapper for every property of every
>> > control on the page. Or, is there some why to manually fire the event
>> > that is raised when the nested control's font-bold is changed in the
>> > properties window.

>>
>> > Also, what is the difference between refresh.repaint and refresh.all.
>> > Does one only redraw the control on the designer while the other
>> > recreates the controls properties and then redraws the control on the
>> > designer?

>>
>> > Here is my code in the simplest form. Thanks for the help in
>> > advance...

>>
>> > Imports System.ComponentModel
>> > Imports System.Web.UI
>> > Imports System.Web.UI.WebControls
>> > <Assembly: TagPrefix("Editor", "cms")>
>> > <ParseChildren(True), Designer("System.Web.UI.Design.ControlDesigner,
>> > System.Design"), DefaultProperty("Text"), ToolboxData("<cms:Editor
>> > runat=server></cms:Editor>"),
>> > RefreshProperties(RefreshProperties.Repaint)> Public Class Editor
>> > Inherits System.Web.UI.WebControls.WebControl
>> > Implements INamingContainer

>>
>> > Dim _text As String

>>
>> > <Bindable(True), Category("Appearance"), DefaultValue("")>
>> > Property [Text]() As String
>> > Get
>> > Return _text
>> > End Get

>>
>> > Set(ByVal Value As String)
>> > _text = Value
>> > End Set

>>
>> > End Property
>> > Private _TitleLabel As Label
>> > <Category("CMS"), Bindable(True),
>> > DesignerSerializationVisibility(DesignerSerializat ionVisibility.Visible),
>> > RefreshProperties(RefreshProperties.Repaint),
>> > NotifyParentProperty(True),
>> > PersistenceMode(PersistenceMode.InnerProperty)> _
>> > Public Property [TitleLabel]() As Label
>> > Get

>>
>> > Return _TitleLabel
>> > End Get
>> > Set(ByVal Value As Label)

>>
>> > _TitleLabel = Value
>> > Me.ChildControlsCreated = False
>> > Me.EnsureChildControls()

>>
>> > End Set
>> > End Property- Hide quoted text -

>>
>> - Show quoted text -

>
>



 
Reply With Quote
 
 
 
Reply

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
Designer Property Serialization -- Sycning inner properties to designer property window Alexander Higgins ASP .Net Web Controls 0 07-21-2007 12:58 AM
Designer Support: How to have user control's properties appear in IDE's properties window? Max2006 ASP .Net 2 07-13-2007 01:45 PM
failing to instantiate an inner class because of order of inner classes Pyenos Python 2 12-27-2006 11:19 PM
Serialization Problems and books on serialization? sinleeh@hotmail.com Java 8 01-02-2005 02:40 PM
inner classes in python as inner classes in Java Carlo v. Dango Python 14 10-19-2003 08:49 AM



Advertisments