Professional Web Applications Themes

Custom control code serialization to class file - ASP.NET Building Controls

I have a custom control that includes a custom collection. In the collection editor, I add a new item to the collection and that item gets persisted as desired to the aspx page that contains the control but it does not persist to the aspx.cs page. As I have tested different combinations of methods, overrides, custom collectioneditors, custom type converters, etc. at some times, and intermittently, I have had collection items persist as fields in the page class but I have not been able to pin it down or reproduce the behavior in any consistent fashion. The attributes I have ...

  1. #1

    Default Custom control code serialization to class file

    I have a custom control that includes a custom collection. In the collection
    editor, I add a new item to the collection and that item gets persisted as
    desired to the aspx page that contains the control but it does not persist to
    the aspx.cs page.

    As I have tested different combinations of methods, overrides, custom
    collectioneditors, custom type converters, etc. at some times, and
    intermittently, I have had collection items persist as fields in the page
    class but I have not been able to pin it down or reproduce the behavior in
    any consistent fashion.

    The attributes I have on the collection property within my custom control
    class are:

    [DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content),
    Editor(typeof(MyCollectionEditor), typeof(UITypeEditor))
    NotifyParentProperty(true),PersistenceMode(Persist enceMode.InnerDefaultProperty),
    Category("Data")]

    Is there an attribute that I am missing that controls declaring the control
    as a field in the page class? Any other suggestions?

    Thanks,

    --
    Dale Preston
    MCAD C#
    MCSE, MCDBA
    Dale Guest

  2. #2

    Default RE: Custom control code serialization to class file

    Hi Dale,

    Welcome to ASPNET newsgroup.
    From your description, you're developing a custom web server control which
    has a collection propety which is of custom collection type. And you're
    wondering how to make the control's this propety be persisted in it's
    container page's class field?

    As you mentioned that
    =========
    I have had collection items persist as fields in the page
    class but I have not been able to pin it down or reproduce the behavior in
    any consistent fashion
    =========

    I'm not quite sure on this, do you mean your custom control's collection
    property will be stored in it's contianer page's field/property? Based on
    my understanding, currently for ASP.NET custom server control, the
    design-time feature only allow us to persist the properties in the inline
    HTML (inside control tag). Also, if we can make control's property become a
    direct field of it's host page's field, that may occur field conflicting
    there're multi such controls in a single page. Anyway, it would be much
    helpful if you can provide a certain demo so that we can perform some test
    on our side.

    Thanks,

    Steven Cheng
    Microsoft Online Support

    Get Secure! [url]www.microsoft.com/security[/url]
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)







    --------------------
    | Thread-Topic: Custom control code serialization to class file
    | thread-index: AcWPjE3jWtQF7EuRRw2+ThV5AJyGOA==
    | X-WBNR-Posting-Host: 63.235.249.11
    | From: "=?Utf-8?B?RGFsZQ==?=" <dale0973nospam.nospam>
    | Subject: Custom control code serialization to class file
    | Date: Sat, 23 Jul 2005 06:42:01 -0700
    | Lines: 28
    | Message-ID: <6B11F337-8A1E-4234-83F8-222941853358microsoft.com>
    | MIME-Version: 1.0
    | Content-Type: text/plain;
    | cht="Utf-8"
    | Content-Transfer-Encoding: 7bit
    | X-Newsreader: Microsoft CDO for Windows 2000
    | Content-Class: urn:content-classes:message
    | Importance: normal
    | Priority: normal
    | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
    | Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingc ontrols
    | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
    | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
    | Xref: TK2MSFTNGXA01.phx.gbl
    microsoft.public.dotnet.framework.aspnet.buildingc ontrols:3908
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingc ontrols
    |
    | I have a custom control that includes a custom collection. In the
    collection
    | editor, I add a new item to the collection and that item gets persisted
    as
    | desired to the aspx page that contains the control but it does not
    persist to
    | the aspx.cs page.
    |
    | As I have tested different combinations of methods, overrides, custom
    | collectioneditors, custom type converters, etc. at some times, and
    | intermittently, I have had collection items persist as fields in the page
    | class but I have not been able to pin it down or reproduce the behavior
    in
    | any consistent fashion.
    |
    | The attributes I have on the collection property within my custom control
    | class are:
    |
    | [DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content),
    | Editor(typeof(MyCollectionEditor), typeof(UITypeEditor)),
    NotifyParentProperty(true),PersistenceMode(Persist enceMode.InnerDefaultPrope
    rty),
    | Category("Data")]
    |
    | Is there an attribute that I am missing that controls declaring the
    control
    | as a field in the page class? Any other suggestions?
    |
    | Thanks,
    |
    | --
    | Dale Preston
    | MCAD C#
    | MCSE, MCDBA
    |

    Steven Cheng[MSFT] Guest

  3. #3

    Default RE: Custom control code serialization to class file

    I have sent the sample to you directly in a zip file to avoid posting
    attachments to the group but it is really pretty simple to describe. I
    apologize if my first post wasn't more clear.

    My control, ClientScripts has a collection of ClientScript objects. The
    collection items do get persisted properly to the ASPX page's HTML. What I
    am trying to get is for them to be declared as fields in the page's class
    file. I have not been able to pin this behavior down. For instance, I want
    them to be added to the class as:

    protected ClientScript clientScript1;
    protected ClientScript clientScript2;

    and so on.

    Thanks,
    --
    Dale Preston
    MCAD C#
    MCSE, MCDBA


    "Steven Cheng[MSFT]" wrote:
    > Hi Dale,
    >
    > Welcome to ASPNET newsgroup.
    > From your description, you're developing a custom web server control which
    > has a collection propety which is of custom collection type. And you're
    > wondering how to make the control's this propety be persisted in it's
    > container page's class field?
    >
    > As you mentioned that
    > =========
    > I have had collection items persist as fields in the page
    > class but I have not been able to pin it down or reproduce the behavior in
    > any consistent fashion
    > =========
    >
    > I'm not quite sure on this, do you mean your custom control's collection
    > property will be stored in it's contianer page's field/property? Based on
    > my understanding, currently for ASP.NET custom server control, the
    > design-time feature only allow us to persist the properties in the inline
    > HTML (inside control tag). Also, if we can make control's property become a
    > direct field of it's host page's field, that may occur field conflicting
    > there're multi such controls in a single page. Anyway, it would be much
    > helpful if you can provide a certain demo so that we can perform some test
    > on our side.
    >
    > Thanks,
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! [url]www.microsoft.com/security[/url]
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
    >
    >
    >
    >
    >
    >
    > --------------------
    > | Thread-Topic: Custom control code serialization to class file
    > | thread-index: AcWPjE3jWtQF7EuRRw2+ThV5AJyGOA==
    > | X-WBNR-Posting-Host: 63.235.249.11
    > | From: "=?Utf-8?B?RGFsZQ==?=" <dale0973nospam.nospam>
    > | Subject: Custom control code serialization to class file
    > | Date: Sat, 23 Jul 2005 06:42:01 -0700
    > | Lines: 28
    > | Message-ID: <6B11F337-8A1E-4234-83F8-222941853358microsoft.com>
    > | MIME-Version: 1.0
    > | Content-Type: text/plain;
    > | cht="Utf-8"
    > | Content-Transfer-Encoding: 7bit
    > | X-Newsreader: Microsoft CDO for Windows 2000
    > | Content-Class: urn:content-classes:message
    > | Importance: normal
    > | Priority: normal
    > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
    > | Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingc ontrols
    > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
    > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
    > | Xref: TK2MSFTNGXA01.phx.gbl
    > microsoft.public.dotnet.framework.aspnet.buildingc ontrols:3908
    > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingc ontrols
    > |
    > | I have a custom control that includes a custom collection. In the
    > collection
    > | editor, I add a new item to the collection and that item gets persisted
    > as
    > | desired to the aspx page that contains the control but it does not
    > persist to
    > | the aspx.cs page.
    > |
    > | As I have tested different combinations of methods, overrides, custom
    > | collectioneditors, custom type converters, etc. at some times, and
    > | intermittently, I have had collection items persist as fields in the page
    > | class but I have not been able to pin it down or reproduce the behavior
    > in
    > | any consistent fashion.
    > |
    > | The attributes I have on the collection property within my custom control
    > | class are:
    > |
    > | [DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content),
    > | Editor(typeof(MyCollectionEditor), typeof(UITypeEditor)),
    > NotifyParentProperty(true),PersistenceMode(Persist enceMode.InnerDefaultPrope
    > rty),
    > | Category("Data")]
    > |
    > | Is there an attribute that I am missing that controls declaring the
    > control
    > | as a field in the page class? Any other suggestions?
    > |
    > | Thanks,
    > |
    > | --
    > | Dale Preston
    > | MCAD C#
    > | MCSE, MCDBA
    > |
    >
    >
    Dale Guest

  4. #4

    Default RE: Custom control code serialization to class file

    Well, surprise, surprise. The email on your post doesn't work. I guess I
    should have expected that, mine doesn't either. Anyway, you won't get the
    zip file so here's a link to the project on my blog:

    [url]http://www.dalepreston.com/Blog/2005/07/visually-add-client-scripts-to-your.html[/url]

    It works pretty well like it is, but I just want to find that one last
    answer about having the designer add the field declaration to the page class.

    Thanks,
    --
    Dale Preston
    MCAD C#
    MCSE, MCDBA


    "Steven Cheng[MSFT]" wrote:
    > Hi Dale,
    >
    > Welcome to ASPNET newsgroup.
    > From your description, you're developing a custom web server control which
    > has a collection propety which is of custom collection type. And you're
    > wondering how to make the control's this propety be persisted in it's
    > container page's class field?
    >
    > As you mentioned that
    > =========
    > I have had collection items persist as fields in the page
    > class but I have not been able to pin it down or reproduce the behavior in
    > any consistent fashion
    > =========
    >
    > I'm not quite sure on this, do you mean your custom control's collection
    > property will be stored in it's contianer page's field/property? Based on
    > my understanding, currently for ASP.NET custom server control, the
    > design-time feature only allow us to persist the properties in the inline
    > HTML (inside control tag). Also, if we can make control's property become a
    > direct field of it's host page's field, that may occur field conflicting
    > there're multi such controls in a single page. Anyway, it would be much
    > helpful if you can provide a certain demo so that we can perform some test
    > on our side.
    >
    > Thanks,
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! [url]www.microsoft.com/security[/url]
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
    >
    >
    >
    >
    >
    >
    > --------------------
    > | Thread-Topic: Custom control code serialization to class file
    > | thread-index: AcWPjE3jWtQF7EuRRw2+ThV5AJyGOA==
    > | X-WBNR-Posting-Host: 63.235.249.11
    > | From: "=?Utf-8?B?RGFsZQ==?=" <dale0973nospam.nospam>
    > | Subject: Custom control code serialization to class file
    > | Date: Sat, 23 Jul 2005 06:42:01 -0700
    > | Lines: 28
    > | Message-ID: <6B11F337-8A1E-4234-83F8-222941853358microsoft.com>
    > | MIME-Version: 1.0
    > | Content-Type: text/plain;
    > | cht="Utf-8"
    > | Content-Transfer-Encoding: 7bit
    > | X-Newsreader: Microsoft CDO for Windows 2000
    > | Content-Class: urn:content-classes:message
    > | Importance: normal
    > | Priority: normal
    > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
    > | Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingc ontrols
    > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
    > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
    > | Xref: TK2MSFTNGXA01.phx.gbl
    > microsoft.public.dotnet.framework.aspnet.buildingc ontrols:3908
    > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingc ontrols
    > |
    > | I have a custom control that includes a custom collection. In the
    > collection
    > | editor, I add a new item to the collection and that item gets persisted
    > as
    > | desired to the aspx page that contains the control but it does not
    > persist to
    > | the aspx.cs page.
    > |
    > | As I have tested different combinations of methods, overrides, custom
    > | collectioneditors, custom type converters, etc. at some times, and
    > | intermittently, I have had collection items persist as fields in the page
    > | class but I have not been able to pin it down or reproduce the behavior
    > in
    > | any consistent fashion.
    > |
    > | The attributes I have on the collection property within my custom control
    > | class are:
    > |
    > | [DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content),
    > | Editor(typeof(MyCollectionEditor), typeof(UITypeEditor)),
    > NotifyParentProperty(true),PersistenceMode(Persist enceMode.InnerDefaultPrope
    > rty),
    > | Category("Data")]
    > |
    > | Is there an attribute that I am missing that controls declaring the
    > control
    > | as a field in the page class? Any other suggestions?
    > |
    > | Thanks,
    > |
    > | --
    > | Dale Preston
    > | MCAD C#
    > | MCSE, MCDBA
    > |
    >
    >
    Dale Guest

  5. #5

    Default RE: Custom control code serialization to class file

    Thanks for your response Dale,

    Is the link you mentioned the "ClientScripts" project on your blog? If so,
    I''ve found it and will have a look.
    I'll update you if I got any new info. Thanks,

    Steven Cheng
    Microsoft Online Support

    Get Secure! [url]www.microsoft.com/security[/url]
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
    --------------------
    | Thread-Topic: Custom control code serialization to class file
    | thread-index: AcWReboZabUXoXYHSUmjI5dU11WP0g==
    | X-WBNR-Posting-Host: 24.116.7.58
    | From: "=?Utf-8?B?RGFsZQ==?=" <dale0973nospam.nospam>
    | References: <6B11F337-8A1E-4234-83F8-222941853358microsoft.com>
    <9XidqBPkFHA.940TK2MSFTNGXA01.phx.gbl>
    | Subject: RE: Custom control code serialization to class file
    | Date: Mon, 25 Jul 2005 17:34:04 -0700
    | Lines: 120
    | Message-ID: <A5108CF3-C801-4D4A-A152-6F5F7ECC8A87microsoft.com>
    | MIME-Version: 1.0
    | Content-Type: text/plain;
    | cht="Utf-8"
    | Content-Transfer-Encoding: 7bit
    | X-Newsreader: Microsoft CDO for Windows 2000
    | Content-Class: urn:content-classes:message
    | Importance: normal
    | Priority: normal
    | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
    | Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingc ontrols
    | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
    | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA02.phx.gbl!TK2MSF TNGXA03.phx.gbl
    | Xref: TK2MSFTNGXA01.phx.gbl
    microsoft.public.dotnet.framework.aspnet.buildingc ontrols:3911
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingc ontrols
    |
    | Well, surprise, surprise. The email on your post doesn't work. I guess
    I
    | should have expected that, mine doesn't either. Anyway, you won't get
    the
    | zip file so here's a link to the project on my blog:
    |
    [url]http://www.dalepreston.com/Blog/2005/07/visually-add-client-scripts-to-your[/url].
    html
    |
    | It works pretty well like it is, but I just want to find that one last
    | answer about having the designer add the field declaration to the page
    class.
    |
    | Thanks,
    | --
    | Dale Preston
    | MCAD C#
    | MCSE, MCDBA
    |
    |
    | "Steven Cheng[MSFT]" wrote:
    |
    | > Hi Dale,
    | >
    | > Welcome to ASPNET newsgroup.
    | > From your description, you're developing a custom web server control
    which
    | > has a collection propety which is of custom collection type. And you're
    | > wondering how to make the control's this propety be persisted in it's
    | > container page's class field?
    | >
    | > As you mentioned that
    | > =========
    | > I have had collection items persist as fields in the page
    | > class but I have not been able to pin it down or reproduce the behavior
    in
    | > any consistent fashion
    | > =========
    | >
    | > I'm not quite sure on this, do you mean your custom control's
    collection
    | > property will be stored in it's contianer page's field/property? Based
    on
    | > my understanding, currently for ASP.NET custom server control, the
    | > design-time feature only allow us to persist the properties in the
    inline
    | > HTML (inside control tag). Also, if we can make control's property
    become a
    | > direct field of it's host page's field, that may occur field
    conflicting
    | > there're multi such controls in a single page. Anyway, it would be much
    | > helpful if you can provide a certain demo so that we can perform some
    test
    | > on our side.
    | >
    | > Thanks,
    | >
    | > Steven Cheng
    | > Microsoft Online Support
    | >
    | > Get Secure! [url]www.microsoft.com/security[/url]
    | > (This posting is provided "AS IS", with no warranties, and confers no
    | > rights.)
    | >
    | >
    | >
    | >
    | >
    | >
    | >
    | > --------------------
    | > | Thread-Topic: Custom control code serialization to class file
    | > | thread-index: AcWPjE3jWtQF7EuRRw2+ThV5AJyGOA==
    | > | X-WBNR-Posting-Host: 63.235.249.11
    | > | From: "=?Utf-8?B?RGFsZQ==?=" <dale0973nospam.nospam>
    | > | Subject: Custom control code serialization to class file
    | > | Date: Sat, 23 Jul 2005 06:42:01 -0700
    | > | Lines: 28
    | > | Message-ID: <6B11F337-8A1E-4234-83F8-222941853358microsoft.com>
    | > | MIME-Version: 1.0
    | > | Content-Type: text/plain;
    | > | cht="Utf-8"
    | > | Content-Transfer-Encoding: 7bit
    | > | X-Newsreader: Microsoft CDO for Windows 2000
    | > | Content-Class: urn:content-classes:message
    | > | Importance: normal
    | > | Priority: normal
    | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
    | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingc ontrols
    | > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
    | > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
    | > | Xref: TK2MSFTNGXA01.phx.gbl
    | > microsoft.public.dotnet.framework.aspnet.buildingc ontrols:3908
    | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingc ontrols
    | > |
    | > | I have a custom control that includes a custom collection. In the
    | > collection
    | > | editor, I add a new item to the collection and that item gets
    persisted
    | > as
    | > | desired to the aspx page that contains the control but it does not
    | > persist to
    | > | the aspx.cs page.
    | > |
    | > | As I have tested different combinations of methods, overrides, custom
    | > | collectioneditors, custom type converters, etc. at some times, and
    | > | intermittently, I have had collection items persist as fields in the
    page
    | > | class but I have not been able to pin it down or reproduce the
    behavior
    | > in
    | > | any consistent fashion.
    | > |
    | > | The attributes I have on the collection property within my custom
    control
    | > | class are:
    | > |
    | > |
    [DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content),
    | > | Editor(typeof(MyCollectionEditor), typeof(UITypeEditor)),
    | >
    NotifyParentProperty(true),PersistenceMode(Persist enceMode.InnerDefaultPrope
    | > rty),
    | > | Category("Data")]
    | > |
    | > | Is there an attribute that I am missing that controls declaring the
    | > control
    | > | as a field in the page class? Any other suggestions?
    | > |
    | > | Thanks,
    | > |
    | > | --
    | > | Dale Preston
    | > | MCAD C#
    | > | MCSE, MCDBA
    | > |
    | >
    | >
    |

    Steven Cheng[MSFT] Guest

  6. #6

    Default RE: Custom control code serialization to class file

    Yes, that's the project.

    Thank you.
    --
    Dale Preston
    MCAD C#
    MCSE, MCDBA


    "Steven Cheng[MSFT]" wrote:
    > Thanks for your response Dale,
    >
    > Is the link you mentioned the "ClientScripts" project on your blog? If so,
    > I''ve found it and will have a look.
    > I'll update you if I got any new info. Thanks,
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! [url]www.microsoft.com/security[/url]
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    > --------------------
    > | Thread-Topic: Custom control code serialization to class file
    > | thread-index: AcWReboZabUXoXYHSUmjI5dU11WP0g==
    > | X-WBNR-Posting-Host: 24.116.7.58
    > | From: "=?Utf-8?B?RGFsZQ==?=" <dale0973nospam.nospam>
    > | References: <6B11F337-8A1E-4234-83F8-222941853358microsoft.com>
    > <9XidqBPkFHA.940TK2MSFTNGXA01.phx.gbl>
    > | Subject: RE: Custom control code serialization to class file
    > | Date: Mon, 25 Jul 2005 17:34:04 -0700
    > | Lines: 120
    > | Message-ID: <A5108CF3-C801-4D4A-A152-6F5F7ECC8A87microsoft.com>
    > | MIME-Version: 1.0
    > | Content-Type: text/plain;
    > | cht="Utf-8"
    > | Content-Transfer-Encoding: 7bit
    > | X-Newsreader: Microsoft CDO for Windows 2000
    > | Content-Class: urn:content-classes:message
    > | Importance: normal
    > | Priority: normal
    > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
    > | Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingc ontrols
    > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
    > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA02.phx.gbl!TK2MSF TNGXA03.phx.gbl
    > | Xref: TK2MSFTNGXA01.phx.gbl
    > microsoft.public.dotnet.framework.aspnet.buildingc ontrols:3911
    > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingc ontrols
    > |
    > | Well, surprise, surprise. The email on your post doesn't work. I guess
    > I
    > | should have expected that, mine doesn't either. Anyway, you won't get
    > the
    > | zip file so here's a link to the project on my blog:
    > |
    > [url]http://www.dalepreston.com/Blog/2005/07/visually-add-client-scripts-to-your[/url].
    > html
    > |
    > | It works pretty well like it is, but I just want to find that one last
    > | answer about having the designer add the field declaration to the page
    > class.
    > |
    > | Thanks,
    > | --
    > | Dale Preston
    > | MCAD C#
    > | MCSE, MCDBA
    > |
    > |
    > | "Steven Cheng[MSFT]" wrote:
    > |
    > | > Hi Dale,
    > | >
    > | > Welcome to ASPNET newsgroup.
    > | > From your description, you're developing a custom web server control
    > which
    > | > has a collection propety which is of custom collection type. And you're
    > | > wondering how to make the control's this propety be persisted in it's
    > | > container page's class field?
    > | >
    > | > As you mentioned that
    > | > =========
    > | > I have had collection items persist as fields in the page
    > | > class but I have not been able to pin it down or reproduce the behavior
    > in
    > | > any consistent fashion
    > | > =========
    > | >
    > | > I'm not quite sure on this, do you mean your custom control's
    > collection
    > | > property will be stored in it's contianer page's field/property? Based
    > on
    > | > my understanding, currently for ASP.NET custom server control, the
    > | > design-time feature only allow us to persist the properties in the
    > inline
    > | > HTML (inside control tag). Also, if we can make control's property
    > become a
    > | > direct field of it's host page's field, that may occur field
    > conflicting
    > | > there're multi such controls in a single page. Anyway, it would be much
    > | > helpful if you can provide a certain demo so that we can perform some
    > test
    > | > on our side.
    > | >
    > | > Thanks,
    > | >
    > | > Steven Cheng
    > | > Microsoft Online Support
    > | >
    > | > Get Secure! [url]www.microsoft.com/security[/url]
    > | > (This posting is provided "AS IS", with no warranties, and confers no
    > | > rights.)
    > | >
    > | >
    > | >
    > | >
    > | >
    > | >
    > | >
    > | > --------------------
    > | > | Thread-Topic: Custom control code serialization to class file
    > | > | thread-index: AcWPjE3jWtQF7EuRRw2+ThV5AJyGOA==
    > | > | X-WBNR-Posting-Host: 63.235.249.11
    > | > | From: "=?Utf-8?B?RGFsZQ==?=" <dale0973nospam.nospam>
    > | > | Subject: Custom control code serialization to class file
    > | > | Date: Sat, 23 Jul 2005 06:42:01 -0700
    > | > | Lines: 28
    > | > | Message-ID: <6B11F337-8A1E-4234-83F8-222941853358microsoft.com>
    > | > | MIME-Version: 1.0
    > | > | Content-Type: text/plain;
    > | > | cht="Utf-8"
    > | > | Content-Transfer-Encoding: 7bit
    > | > | X-Newsreader: Microsoft CDO for Windows 2000
    > | > | Content-Class: urn:content-classes:message
    > | > | Importance: normal
    > | > | Priority: normal
    > | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
    > | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingc ontrols
    > | > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
    > | > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
    > | > | Xref: TK2MSFTNGXA01.phx.gbl
    > | > microsoft.public.dotnet.framework.aspnet.buildingc ontrols:3908
    > | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingc ontrols
    > | > |
    > | > | I have a custom control that includes a custom collection. In the
    > | > collection
    > | > | editor, I add a new item to the collection and that item gets
    > persisted
    > | > as
    > | > | desired to the aspx page that contains the control but it does not
    > | > persist to
    > | > | the aspx.cs page.
    > | > |
    > | > | As I have tested different combinations of methods, overrides, custom
    > | > | collectioneditors, custom type converters, etc. at some times, and
    > | > | intermittently, I have had collection items persist as fields in the
    > page
    > | > | class but I have not been able to pin it down or reproduce the
    > behavior
    > | > in
    > | > | any consistent fashion.
    > | > |
    > | > | The attributes I have on the collection property within my custom
    > control
    > | > | class are:
    > | > |
    > | > |
    > [DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content),
    > | > | Editor(typeof(MyCollectionEditor), typeof(UITypeEditor)),
    > | >
    > NotifyParentProperty(true),PersistenceMode(Persist enceMode.InnerDefaultPrope
    > | > rty),
    > | > | Category("Data")]
    > | > |
    > | > | Is there an attribute that I am missing that controls declaring the
    > | > control
    > | > | as a field in the page class? Any other suggestions?
    > | > |
    > | > | Thanks,
    > | > |
    > | > | --
    > | > | Dale Preston
    > | > | MCAD C#
    > | > | MCSE, MCDBA
    > | > |
    > | >
    > | >
    > |
    >
    >
    Dale Guest

  7. #7

    Default RE: Custom control code serialization to class file

    Hi Dale,

    I've had a look at your project on my side. First I should say you've done
    a good job:-). For the field decalaration for the ClientScript Collection
    under the ClientScripts control, I think the current behavior of your
    control is the correct and reasonable one. Since you use the
    [PChildren(true, "Scripts")] for your ClientScripts control, so all
    it's inner HTML will be pd as the content of the "ScriptCollection"
    member property, so of course they won't become member field of the page
    class.

    As for the behavior that becoming member field of page class, I'm thinking
    whether you've ever made your ClientScripts control as a pure Container
    control(not NamingContainer), just like the
    System.Web.UI.WebControls.Panel, all the sub controls in the Panel's tag
    will be declared as a top level member field of the page. But don't think
    this mode is appropriate for your script control.

    Thanks,

    Steven Cheng
    Microsoft Online Support

    Get Secure! [url]www.microsoft.com/security[/url]
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
    --------------------
    | Thread-Topic: Custom control code serialization to class file
    | thread-index: AcWTG48ZqeTHw3DOQ6KePPOEyMy5HA==
    | X-WBNR-Posting-Host: 24.116.7.58
    | From: "=?Utf-8?B?RGFsZQ==?=" <dale0973nospam.nospam>
    | References: <6B11F337-8A1E-4234-83F8-222941853358microsoft.com>
    <9XidqBPkFHA.940TK2MSFTNGXA01.phx.gbl>
    <A5108CF3-C801-4D4A-A152-6F5F7ECC8A87microsoft.com>
    <JqvHn5wkFHA.3672TK2MSFTNGXA01.phx.gbl>
    | Subject: RE: Custom control code serialization to class file
    | Date: Wed, 27 Jul 2005 19:25:02 -0700
    | Lines: 191
    | Message-ID: <DB390FDC-D209-4166-B87F-82BC0F3575BCmicrosoft.com>
    | MIME-Version: 1.0
    | Content-Type: text/plain;
    | cht="Utf-8"
    | Content-Transfer-Encoding: 7bit
    | X-Newsreader: Microsoft CDO for Windows 2000
    | Content-Class: urn:content-classes:message
    | Importance: normal
    | Priority: normal
    | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
    | Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingc ontrols
    | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
    | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
    | Xref: TK2MSFTNGXA01.phx.gbl
    microsoft.public.dotnet.framework.aspnet.buildingc ontrols:3938
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingc ontrols
    |
    | Yes, that's the project.
    |
    | Thank you.
    | --
    | Dale Preston
    | MCAD C#
    | MCSE, MCDBA
    |
    |
    | "Steven Cheng[MSFT]" wrote:
    |
    | > Thanks for your response Dale,
    | >
    | > Is the link you mentioned the "ClientScripts" project on your blog? If
    so,
    | > I''ve found it and will have a look.
    | > I'll update you if I got any new info. Thanks,
    | >
    | > Steven Cheng
    | > Microsoft Online Support
    | >
    | > Get Secure! [url]www.microsoft.com/security[/url]
    | > (This posting is provided "AS IS", with no warranties, and confers no
    | > rights.)
    | > --------------------
    | > | Thread-Topic: Custom control code serialization to class file
    | > | thread-index: AcWReboZabUXoXYHSUmjI5dU11WP0g==
    | > | X-WBNR-Posting-Host: 24.116.7.58
    | > | From: "=?Utf-8?B?RGFsZQ==?=" <dale0973nospam.nospam>
    | > | References: <6B11F337-8A1E-4234-83F8-222941853358microsoft.com>
    | > <9XidqBPkFHA.940TK2MSFTNGXA01.phx.gbl>
    | > | Subject: RE: Custom control code serialization to class file
    | > | Date: Mon, 25 Jul 2005 17:34:04 -0700
    | > | Lines: 120
    | > | Message-ID: <A5108CF3-C801-4D4A-A152-6F5F7ECC8A87microsoft.com>
    | > | MIME-Version: 1.0
    | > | Content-Type: text/plain;
    | > | cht="Utf-8"
    | > | Content-Transfer-Encoding: 7bit
    | > | X-Newsreader: Microsoft CDO for Windows 2000
    | > | Content-Class: urn:content-classes:message
    | > | Importance: normal
    | > | Priority: normal
    | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
    | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingc ontrols
    | > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
    | > | Path:
    TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA02.phx.gbl!TK2MSF TNGXA03.phx.gbl
    | > | Xref: TK2MSFTNGXA01.phx.gbl
    | > microsoft.public.dotnet.framework.aspnet.buildingc ontrols:3911
    | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingc ontrols
    | > |
    | > | Well, surprise, surprise. The email on your post doesn't work. I
    guess
    | > I
    | > | should have expected that, mine doesn't either. Anyway, you won't
    get
    | > the
    | > | zip file so here's a link to the project on my blog:
    | > |
    | >
    [url]http://www.dalepreston.com/Blog/2005/07/visually-add-client-scripts-to-your[/url].
    | > html
    | > |
    | > | It works pretty well like it is, but I just want to find that one
    last
    | > | answer about having the designer add the field declaration to the
    page
    | > class.
    | > |
    | > | Thanks,
    | > | --
    | > | Dale Preston
    | > | MCAD C#
    | > | MCSE, MCDBA
    | > |
    | > |
    | > | "Steven Cheng[MSFT]" wrote:
    | > |
    | > | > Hi Dale,
    | > | >
    | > | > Welcome to ASPNET newsgroup.
    | > | > From your description, you're developing a custom web server
    control
    | > which
    | > | > has a collection propety which is of custom collection type. And
    you're
    | > | > wondering how to make the control's this propety be persisted in
    it's
    | > | > container page's class field?
    | > | >
    | > | > As you mentioned that
    | > | > =========
    | > | > I have had collection items persist as fields in the page
    | > | > class but I have not been able to pin it down or reproduce the
    behavior
    | > in
    | > | > any consistent fashion
    | > | > =========
    | > | >
    | > | > I'm not quite sure on this, do you mean your custom control's
    | > collection
    | > | > property will be stored in it's contianer page's field/property?
    Based
    | > on
    | > | > my understanding, currently for ASP.NET custom server control, the
    | > | > design-time feature only allow us to persist the properties in the
    | > inline
    | > | > HTML (inside control tag). Also, if we can make control's property
    | > become a
    | > | > direct field of it's host page's field, that may occur field
    | > conflicting
    | > | > there're multi such controls in a single page. Anyway, it would be
    much
    | > | > helpful if you can provide a certain demo so that we can perform
    some
    | > test
    | > | > on our side.
    | > | >
    | > | > Thanks,
    | > | >
    | > | > Steven Cheng
    | > | > Microsoft Online Support
    | > | >
    | > | > Get Secure! [url]www.microsoft.com/security[/url]
    | > | > (This posting is provided "AS IS", with no warranties, and confers
    no
    | > | > rights.)
    | > | >
    | > | >
    | > | >
    | > | >
    | > | >
    | > | >
    | > | >
    | > | > --------------------
    | > | > | Thread-Topic: Custom control code serialization to class file
    | > | > | thread-index: AcWPjE3jWtQF7EuRRw2+ThV5AJyGOA==
    | > | > | X-WBNR-Posting-Host: 63.235.249.11
    | > | > | From: "=?Utf-8?B?RGFsZQ==?=" <dale0973nospam.nospam>
    | > | > | Subject: Custom control code serialization to class file
    | > | > | Date: Sat, 23 Jul 2005 06:42:01 -0700
    | > | > | Lines: 28
    | > | > | Message-ID: <6B11F337-8A1E-4234-83F8-222941853358microsoft.com>
    | > | > | MIME-Version: 1.0
    | > | > | Content-Type: text/plain;
    | > | > | cht="Utf-8"
    | > | > | Content-Transfer-Encoding: 7bit
    | > | > | X-Newsreader: Microsoft CDO for Windows 2000
    | > | > | Content-Class: urn:content-classes:message
    | > | > | Importance: normal
    | > | > | Priority: normal
    | > | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
    | > | > | Newsgroups:
    microsoft.public.dotnet.framework.aspnet.buildingc ontrols
    | > | > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
    | > | > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
    | > | > | Xref: TK2MSFTNGXA01.phx.gbl
    | > | > microsoft.public.dotnet.framework.aspnet.buildingc ontrols:3908
    | > | > | X-Tomcat-NG:
    microsoft.public.dotnet.framework.aspnet.buildingc ontrols
    | > | > |
    | > | > | I have a custom control that includes a custom collection. In
    the
    | > | > collection
    | > | > | editor, I add a new item to the collection and that item gets
    | > persisted
    | > | > as
    | > | > | desired to the aspx page that contains the control but it does
    not
    | > | > persist to
    | > | > | the aspx.cs page.
    | > | > |
    | > | > | As I have tested different combinations of methods, overrides,
    custom
    | > | > | collectioneditors, custom type converters, etc. at some times,
    and
    | > | > | intermittently, I have had collection items persist as fields in
    the
    | > page
    | > | > | class but I have not been able to pin it down or reproduce the
    | > behavior
    | > | > in
    | > | > | any consistent fashion.
    | > | > |
    | > | > | The attributes I have on the collection property within my custom
    | > control
    | > | > | class are:
    | > | > |
    | > | > |
    | >
    [DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content),
    | > | > | Editor(typeof(MyCollectionEditor), typeof(UITypeEditor)),
    | > | >
    | >
    NotifyParentProperty(true),PersistenceMode(Persist enceMode.InnerDefaultPrope
    | > | > rty),
    | > | > | Category("Data")]
    | > | > |
    | > | > | Is there an attribute that I am missing that controls declaring
    the
    | > | > control
    | > | > | as a field in the page class? Any other suggestions?
    | > | > |
    | > | > | Thanks,
    | > | > |
    | > | > | --
    | > | > | Dale Preston
    | > | > | MCAD C#
    | > | > | MCSE, MCDBA
    | > | > |
    | > | >
    | > | >
    | > |
    | >
    | >
    |

    Steven Cheng[MSFT] Guest

Similar Threads

  1. Replies: 1
    Last Post: January 25th, 03:54 PM
  2. Custom Control Class within a class
    By ryan.d.rembaum@kp.org in forum ASP.NET Building Controls
    Replies: 0
    Last Post: February 7th, 08:48 PM
  3. Custom control fires event but ignores some code in the code behind file
    By recoil@community.nospam in forum ASP.NET Building Controls
    Replies: 0
    Last Post: March 8th, 05:17 PM
  4. Using a component class as a property for a custom control
    By Chris in forum ASP.NET Building Controls
    Replies: 0
    Last Post: November 11th, 08:25 AM
  5. Replies: 1
    Last Post: July 15th, 03:20 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139