Reading attributes of nested properties

Discussion in 'ASP .Net Building Controls' started by mr dropdown, Dec 20, 2005.

  1. mr dropdown

    mr dropdown Guest

    Hi, I have 2 questions:

    1. How can I read attributes of inner property of a web server control?
    2. How can I read inner properties of inner properties of a web server
    control?

    for example:
    <myControl>
    <myInnerProperty attributeThatIWantToRead="yes">
    <PropertyThatIWantToRead
    AnotherAttributeIWantToRead="yes"></PropertyThatIWantToRead>
    </myInnerProperty>
    </myControl>

    Thanks!
    mr dropdown, Dec 20, 2005
    #1
    1. Advertising

  2. mr dropdown

    Brock Allen Guest

    If the control has all the custom attributes to allow this syntax in the
    ASPX page, then those attributes are simply property assignments on the control
    and its properties. So they should be accessible via the control's object
    model. It will be something like "DataGrid.RowStyle.BackColor".

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen

    > Hi, I have 2 questions:
    >
    > 1. How can I read attributes of inner property of a web server
    > control? 2. How can I read inner properties of inner properties of a
    > web server control?
    >
    > for example:
    > <myControl>
    > <myInnerProperty attributeThatIWantToRead="yes">
    > <PropertyThatIWantToRead
    > AnotherAttributeIWantToRead="yes"></PropertyThatIWantToRead>
    > </myInnerProperty>
    > </myControl>
    > Thanks!
    >
    Brock Allen, Dec 21, 2005
    #2
    1. Advertising

  3. mr. dropdown,
    im assuming <myControl> is a custom control you've authored. there
    are two ways to do what you're asking.
    1) if myControl has a property called myInnerProperty (or any of the
    other nested tags' names), you can set the attribute
    [ParseChildren(true)] in your custom control to have any children it
    parses parsed as properties.
    2) parse these tags as custom controls. you'll first need a class to
    associate with each nested tag. ex:

    public class myInnerProperty : Control

    you can then attach a ControlBuilder to myControl and override
    GetChildControlType and have it return any myInnerProperty tags it sees
    as a myInnerProperty control. then, during myControls
    AddParsedSubObject method, if the object is a myInnerProperty control,
    you can do with it as you like...as it will be a concrete class rather
    than an HtmlGenericControl.

    let me know if this helps,
    Mike MacMillan



    mr dropdown wrote:
    > Hi, I have 2 questions:
    >
    > 1. How can I read attributes of inner property of a web server control?
    > 2. How can I read inner properties of inner properties of a web server
    > control?
    >
    > for example:
    > <myControl>
    > <myInnerProperty attributeThatIWantToRead="yes">
    > <PropertyThatIWantToRead
    > AnotherAttributeIWantToRead="yes"></PropertyThatIWantToRead>
    > </myInnerProperty>
    > </myControl>
    >
    > Thanks!
    Mike MacMillan, Dec 28, 2005
    #3
    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. Max
    Replies:
    1
    Views:
    471
    Joe Kesselman
    Sep 22, 2006
  2. P4trykx
    Replies:
    2
    Views:
    1,793
    bruce barker
    Jan 31, 2007
  3. james_027

    class attributes & data attributes

    james_027, Jun 20, 2007, in forum: Python
    Replies:
    2
    Views:
    361
    Bruno Desthuilliers
    Jun 20, 2007
  4. Kyle Schmitt
    Replies:
    3
    Views:
    180
    Kyle Schmitt
    Jul 24, 2007
  5. Jayden
    Replies:
    16
    Views:
    469
    Steven D'Aprano
    Sep 29, 2012
Loading...

Share This Page