[Need Expert] Big design time problem

Discussion in 'ASP .Net' started by Loïc, Nov 5, 2003.

  1. Loïc

    Loïc Guest

    Hello,

    I have created a simple webcontrol named MyControl tahat contains one single
    property. The property name is Columns , his type is ColumnCollection (
    inherits from CollectionBase). this property contains an elements list and
    the type of these elements is Column.

    On a WebForm (in design mode), i insert my MyControl webcontrol . Je fill
    in his Columns property ( it inherits from CollectionBase type so the
    collection editor is opened ). Then i switch to Html mode to see the
    generated Xml code :

    <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
    Inherits="Xes_Web_Controls.WebForm1" %>
    <%@ Register TagPrefix="cc1" Namespace="Controls" Assembly="Controls" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title>WebForm1</title>
    <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
    <meta content="C#" name="CODE_LANGUAGE">
    <meta content="JavaScript" name="vs_defaultClientScript">
    <meta content="http://schemas.microsoft.com/intellisense/ie5"
    name="vs_targetSchema">
    </HEAD>
    <body MS_POSITIONING="GridLayout">
    <form id="Form1" method="post" runat="server">
    <cc1:mycontrol id="MyControl9" style="Z-INDEX: 101; LEFT: 336px;
    POSITION: absolute; TOP: 168px" runat="server" Width="464px">
    <Columns>
    <cc1:Column Type="string" Name="prenom"></cc1:Column>
    <cc1:Column Type="string" Name="nom"></cc1:Column>
    </Columns>
    </cc1:mycontrol>
    </form>
    </body>
    </HTML>

    At this step there is no problem. Buyt then i close the file which contains
    my webform, then i re-open the file. I switch to design mode and there is an
    error on my control ('' could not be set on property 'Columns' ).
    I do not understand this error and do no know resolve this error.

    Does anybody help me

    Thanks

    Loïc

    PS : at bottom, we can find my sources
    [MyControl.cs]
    using System;
    using System.ComponentModel ;
    using System.Web.UI ;
    using System.Web.UI.WebControls ;

    namespace Controls
    {
    public class MyControl : WebControl
    {

    private ColumnCollection m_columns ;
    public MyControl()
    {
    m_columns = new ColumnCollection() ;
    }
    [
    PersistenceMode(PersistenceMode.InnerProperty),
    DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
    NotifyParentProperty(true)
    ]
    public ColumnCollection Columns
    {
    get { return m_columns ; }
    set { m_columns = value ; }
    }
    }
    }

    [ColumnCollection.cs]
    namespace Controls
    {
    using System;
    using System.Collections ;
    using System.ComponentModel ;
    using System.Web.UI ;

    public class ColumnCollection : CollectionBase
    {
    public ColumnCollection() : base( )
    {

    }
    public void AddColumn( Column _col )
    {
    List.Add( _col ) ;
    }
    [NotifyParentProperty(true)]
    public Column this[int index]
    {
    get { return List[index] as Column ; }
    set { List[index] = value ; }
    }
    }
    }

    [Column.cs]
    namespace Controls
    {
    using System;
    public class Column
    {
    private string m_name ;
    private string m_type ;
    public Column()
    {

    }
    public string Name
    {
    get { return m_name ; }
    set { m_name = value ; }
    }
    public string Type
    {
    set { m_type = value ; }
    get { return m_type ; }
    }
    }
    }
    Loïc, Nov 5, 2003
    #1
    1. Advertising

  2. Loïc

    Natty Gur Guest

    I think you are missing inner default property persistence.
    To enable inner default property persistence, you must mark your control
    with the following variation of the ParseChildrenAttribute, where the
    second argument of the attribute is the name of the inner default
    property:

    [
    ParseChildren(true, "Columns")
    ]
    public class MyControl : WebControl { ... }


    Natty Gur[MVP]
    Phone Numbers:
    Office: +972-(0)9-7740261
    Fax: +972-(0)9-7740261
    Mobile: +972-(0)58-888377


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur, Nov 5, 2003
    #2
    1. Advertising

  3. Loïc

    Loïc Guest

    No it doesn't work .... there is another error ;-(

    Can you help me ?

    Loïc

    "Natty Gur" <> a écrit dans le message de
    news:...
    > I think you are missing inner default property persistence.
    > To enable inner default property persistence, you must mark your control
    > with the following variation of the ParseChildrenAttribute, where the
    > second argument of the attribute is the name of the inner default
    > property:
    >
    > [
    > ParseChildren(true, "Columns")
    > ]
    > public class MyControl : WebControl { ... }
    >
    >
    > Natty Gur[MVP]
    > Phone Numbers:
    > Office: +972-(0)9-7740261
    > Fax: +972-(0)9-7740261
    > Mobile: +972-(0)58-888377
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
    Loïc, Nov 6, 2003
    #3
  4. Loïc

    Natty Gur Guest

    Hi,

    I can try, what's the error.

    if you can put your hand on that book [1], I think it will solve all of
    your problems. what you're after isn't trivial task.

    [1] Developing Microsoft ASP.NET Server Controls and Components
    By Nikhil Kothari, Vandana Datje

    Publisher : Microsoft Press
    Pub Date : September 28, 2002
    ISBN : 0-7356-1582-9


    Natty Gur[MVP]
    Phone Numbers:
    Office: +972-(0)9-7740261
    Fax: +972-(0)9-7740261
    Mobile: +972-(0)58-888377


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur, Nov 6, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. flamesrock
    Replies:
    8
    Views:
    449
    Hendrik van Rooyen
    Nov 24, 2006
  2. Shaguf
    Replies:
    0
    Views:
    346
    Shaguf
    Dec 24, 2008
  3. Shaguf
    Replies:
    0
    Views:
    443
    Shaguf
    Dec 26, 2008
  4. Shaguf
    Replies:
    0
    Views:
    229
    Shaguf
    Dec 26, 2008
  5. Shaguf
    Replies:
    0
    Views:
    211
    Shaguf
    Dec 24, 2008
Loading...

Share This Page