DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Fri, 20 Jul 2007 17:59:57 -0700,    posted on: microsoft.public.dotnet.framework.aspnet.buildingcontrols        back       

Thread Index
  1    Alexander Higgins
          2    Teemu Keiski
          3    Alexander Higgins
                 4    Teemu Keiski


Designer Property Serialization -- Sycning inner properties to designer property window   
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(DesignerSerializationVisibility.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
Date:Fri, 20 Jul 2007 17:59:57 -0700   Author:  

Re: Designer Property Serialization -- Sycning inner properties to designer property window   
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"  wrote in message 
news:1184979597.280413.64640@m3g2000hsh.googlegroups.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(DesignerSerializationVisibility.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
> 
Date:Sun, 22 Jul 2007 21:11:21 +0300   Author:  

Re: Designer Property Serialization -- Sycning inner properties to designer property window   
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"  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"  wrote in message
>
> news:1184979597.280413.64640@m3g2000hsh.googlegroups.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(DesignerSerializationVisibility.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 -
Date:Mon, 23 Jul 2007 07:50:19 -0700   Author:  

Re: Designer Property Serialization -- Sycning inner properties to designer property window   
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 VS2008)

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(DesignerSerializationVisibility.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"  wrote in message 
news:1185202219.471969.14580@r34g2000hsd.googlegroups.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"  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"  wrote in message
>>
>> news:1184979597.280413.64640@m3g2000hsh.googlegroups.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(DesignerSerializationVisibility.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 -
>
> 
Date:Tue, 31 Jul 2007 00:09:22 +0300   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us