clearing properties of type int

Discussion in 'ASP .Net Building Controls' started by Jeremy Chapman, Jun 15, 2006.

  1. I was looking at the HtmlTable control, and noticed that the CellPadding and
    CellSpacing properties are of type integer, yet in the property grid you can
    clear the values. I'm trying to make a property of type int in one of my
    controls and when I clear the property in the design time property editor, I
    get an error "Property value is not valid." Using reflector I took a look
    at the code inside the HtmlTable control and I've pretty much copied it in
    my control but it still doesn't work. Has anyone tried this?

    This is the asp.net code:
    [WebCategory("Appearance"),
    DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
    DefaultValue("")]
    public int CellPadding
    {
    get
    {
    string text1 = base.Attributes["cellpadding"];
    if (text1 == null)
    {
    return -1;
    }
    return int.Parse(text1, CultureInfo.InvariantCulture);
    }
    set
    {
    base.Attributes["cellpadding"] =
    HtmlControl.MapIntegerAttributeToString(value);
    }
    }
     
    Jeremy Chapman, Jun 15, 2006
    #1
    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. Schnoffos
    Replies:
    2
    Views:
    1,472
    Martien Verbruggen
    Jun 27, 2003
  2. Hal Styli
    Replies:
    14
    Views:
    2,036
    Old Wolf
    Jan 20, 2004
  3. arun
    Replies:
    8
    Views:
    689
    Dave Thompson
    Jul 31, 2006
  4. aling
    Replies:
    8
    Views:
    1,702
    Jim Langston
    Oct 20, 2005
  5. Replies:
    9
    Views:
    635
    James Kanze
    Apr 17, 2007
  6. Replies:
    19
    Views:
    600
  7. powerhouse04
    Replies:
    1
    Views:
    432
    powerhouse04
    Dec 16, 2007
  8. Steve Hicks
    Replies:
    2
    Views:
    1,543
Loading...