Anybody written a TypeConverter for a custom Style class?

Discussion in 'ASP .Net Web Controls' started by Sky, Jul 11, 2004.

  1. Sky

    Sky Guest

    Hello (again!):

    Been working all weekend on trying to get a grip on what happens under the
    hood with WebControl.ControlStyle property versus WebControl.Style array...
    And think I am getting somewhere...except for a couple more hitches to work
    out. (Famous last words, no?)

    What I am trying to do is work with a custom Style class that has Margin,
    Padding, Text-Align, etc...

    That part has correctly compiled, and I was able to wire it into a custom
    control by adding to the control:

    protected override Style CreateControlStyle() {

    return (XActStyle) new XActStyle(ViewState);


    To expose it in the IDE's property panel, I did:

    public new XActStyle ControlStyle {get {return
    (XActStyle)base.ControlStyle;}} //base.ControlStyle;

    Works great: finally am starting to feel that it is looking more like what I
    want in the IDE, where the CSS values are not all over the Property Panel
    (ForeColor, etc) but grouped together under a Typed Style expandable class.

    Now...The problem is that when I put values into this via the IDE, they are
    not serialized/persisted to the HTML behind the control...
    I suspect that it is that I need a TypeConverter for this.

    Q: Could someone tell me if that guess is right/wrong before I spend hours
    and hours looking up how to make a TypeConverter for such a complex
    structure (ie: is there a base TypeConverter that I can build onto rather
    than trying to figure out by what magic MS was able to combine BorderStyle
    BorderColor, etc. with Style["Border"], etc....

    Q: If someone has already built a TypeConverter that I can refer to to get a
    leg up, could you post it/guide me to it?

    Q:When I get it to work.....with a little help from someone ;-) ... I assume
    that it will still not be addressible via HTML attribute tags -- unless I
    expose all these properties directly (ie TextAlign {get{return
    ControlStyle.TextAlign;....}} just as MS did -- which would bring me right
    back to where I was trying to get away from (Style/Position properties as
    base properties of the control, rather than neatly tucked away as sub
    properties of ControlStyle accessible only via an
    ExpandableObjectConverter... So my question is, would there be any way
    that someone can think of that I can TypeConvert the Style attribute to
    populate this ControlStyle, and viceversa?
    Q: Failing that being possible/feasible... would the properties be
    accessible via Html by the "-" Syntax -- ie something like <MyControl
    ControlStyle-TextAlign="right" ControlStyle-BorderStyle='dashed'> Obviously
    this is not at all what I want either -- but I ask for about this for
    ...ugh...'academic?' reasons...

    Again, thanks so much for all the help :)
    Sky, Jul 11, 2004
    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. Christian
    Gary Varga
    Jul 18, 2003
  2. Sky Sigal
    Sky Sigal
    Jul 14, 2004
  3. Yogesh Parab
    Jan 2, 2006
  4. Jim
    Steven Cheng[MSFT]
    Oct 25, 2005
  5. Sky Sigal

    Help! custom TypeConverter/Persistence problems...

    Sky Sigal, Jul 13, 2004, in forum: ASP .Net Web Controls
    Sky Sigal
    Jul 13, 2004

Share This Page