Reading attributes of nested properties

M

mr dropdown

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!
 
B

Brock Allen

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".
 
M

Mike MacMillan

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,813
Messages
2,569,696
Members
45,484
Latest member
MasqueradeOfSilence

Latest Threads

Top