Custom attributes/properties at design time (serialization?)

Discussion in 'ASP .Net Building Controls' started by WALDO, Aug 15, 2004.

  1. WALDO

    WALDO Guest

    OK. here's what I want to do.

    I have a text editor control that I created. I also have a seriedsof
    palette controls that I have created for use with the text editor. The
    Idea I want is that the page developer can slap any number of editors
    on a webform and any number of palettes on the same webform and
    associate an editor with a palette.

    So all the editor really needs to know when rendering is the uniqueid
    of the selected palette. What I have done is created a property of
    type palette on the editor. I have created a typeconverter to grab all
    the ids of the palettes on the webform. I have also set the
    DesignerSerializationVisibility attribute to Visible and the
    PersistenceMode to Attribute. Ultimately what I want to see is this:

    <cc1:TextEditor runat="server" id="TextEditor1" Height="200px"
    Width="500px" Palette="WebSafePalette1">This is my
    InnerContent</cc1:TextEditor>

    <cc1:WebSafePalette runat="server"
    id="WebSafePalette1"></cc1:WebSafePalette>
    <cc1:MSWordPalette runat="server"
    id="MSWordPalette1"></cc1:MSWordPalette>
    <cc1:StandardPalette runat="server"
    id="StandardPalette1"></cc1:StandardPalette>

    I want the Id of the selected palette to persist as an attribute
    property in the HTML at design-time.

    I see the list of palettes in the Palette property of the texteditor.
    My problem is that when I set the DesignerSerializationVisibility
    attribute to anything other than hidden, I get the error 'Invalid
    property value (Object not set to an instance of an object)' whenever
    I set the property at design time. When it is set to hidden, I don't
    get the error. Unfortunately nothing persists to the texteditor or the
    webform.

    Any ideas as to how I may accomplish this? I thought maybe my
    TypeEditor was wrong. Do I need a custom parser to fish out the
    properties? Maybe a custom serializer to put the attribute property
    where I want it. Maybe the serializer should put some code in the
    InitializeComponent of the webform.
     
    WALDO, Aug 15, 2004
    #1
    1. Advertisements

  2. WALDO

    WALDO Guest

    OK. So I figured out my problem partially. It was my typeconverter. I
    was assuming that in my ConvertTo function, context and
    context.instance would always produce values and therefore was only
    converting if they did. It's kind of funny, actually. I always thought
    that I would throw some kind of exception if I DIDN'T check those
    values. That's irony for you.

    So I got the name of the control to persist to my attribute the way I
    want. My new problem is how to DEserialize it. When I view the webform
    in the browser, it produces the exception:

    Unable to generate code for a value of type 'TextEdit.Palette'. This
    error occurred while trying to generate the property value for
    Palette.

    I suppose I understand this. It's trying to generate a palette from
    scratch from the value in the attribute, not the reference to the
    object.

    How would I approach DEserializing this object as a refernce to
    another control on the webform?
     
    WALDO, Aug 16, 2004
    #2
    1. Advertisements

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. Replies:
    8
    Views:
    2,517
    deadsea
    Jan 2, 2005
  2. P4trykx
    Replies:
    2
    Views:
    2,125
    bruce barker
    Jan 31, 2007
  3. flamesrock
    Replies:
    8
    Views:
    818
    Hendrik van Rooyen
    Nov 24, 2006
  4. Peter

    properties not showing in properties window at design time

    Peter, Dec 10, 2003, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    332
    Lostinet.Web Support
    Dec 10, 2003
  5. George
    Replies:
    4
    Views:
    391
    Jeffrey Tan[MSFT]
    Jan 19, 2004
  6. John Wright

    Custom TextBox with custom attributes and properties question

    John Wright, Feb 27, 2004, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    364
    John Wright
    Mar 1, 2004
  7. N Kumar

    Setting web custom control properties at design time

    N Kumar, Feb 21, 2006, in forum: ASP .Net Building Controls
    Replies:
    4
    Views:
    256
    Teemu Keiski
    Feb 23, 2006
  8. Nathan Bidwell

    Custom properties in a User Control at Design time

    Nathan Bidwell, Sep 2, 2003, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    484
    Nathan Bidwell
    Sep 3, 2003
Loading...