Server Control Custom Properties Order

T

todd.freed

Hello. I'll make this quick - its quite a conundrum

I have the following markup

<MyNS:MyControl runat="server" id="myId"
CustomProperty1="value"
CustomProperty1="value"
CustomProperty1="value" >
<Columns>
<CustomColumnType1 value1="value" value2="value"/>
<CustomColumnType2 value1="value" value2="value"/>
<CustomColumnType3 value1="value" value2="value"/>
<CustomColumnType2 value1="value" value2="value"/>
<CustomColumnType1 value1="value" value2="value"/>
</Columns>
</MyNS:MyControl>

This is a control I have written which inherits from WebControl. Each
of the 'CustomProperty's correspond to properties of my control. It
also has a 'Columns' property which corresponds to the XML-ish markup
between the opening/closing tags of the control declaration. The
Columns property is an object of type ColumnList. The ColumnList class
has several properties which each correspond to the CustomColumnTypes
as you see here. The CustomColumnTypes have several properties which
correspond to the values I have indicated above.

Now- the preceeding worked splendidly until today. Basically, each of
the CustomColumns gets added to a collection which belongs to the
ColumnList class. Then OnRender I do some things and emit some nice
HTML to the page; great.

However, today we converted our whole project to ASP.Net 2.0 and Visual
Studio 2005. Yay. Problem is, now, the properties corresponding to
CustomColumnType are being accessed in what appears to be a random
order. This is a problem because the CustomColumns are being added in
an incorrect order (used to be simple top-down) and the net result is
that the columns that are being displayed on the client are in a random
order, instead of the order in which they are defined in the control
declaration. When I Render the HTML I am simply looping over the
Columns collection from 0 until x, so the order is very important.

Possible solution: you could assign an "order" property to each column
declaration, then I could loop over the collection in that order.
However- this is a massive hack and I just cant bring myself to do it.

Any help much appreciated.
 

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,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top