Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Mar 27, 2007 10:04 AM by Knutsi
Mar 27, 2007 10:04 AM|LINK
I'm relativly new to making server controls, and am having some issues with a custom server control I'm making, and would like to get some advice on the approach. I'd be really greatfull if someone could help me out!
I've inserted an image of the control at the bottom of this post. The goal is to build a complex list that can be ordered, and where the individual items are edited inline in the list. The captured data is to be used for creating relations between webpages,
and adds some metadata to these relations.
Anyway, the control carries a collection called "Relations" that all the items in the list goes into. This collection is persisted in the view state, and hence the control needs to be rebuild on every request based on the state of this collection. This
brings me to my first question: is it safe to rebuild the control inside the OnLoad event, or should it be done sooner? It appears to work...
Second, each item in the list has a "move up" and a "move down" button. The events have command arguments that I use to determine which item in the collection to move. When the event occures, I reshuffle the collection. This brings me to my second question:
since the collection has been reordered, the control needs to be re-drawn. I do this in OnPreRender, is this safe? If appears to work when the items carry specific ID's that I set, not the default IDs that ASP.NET generate.
Now we come to the third, and most difficult part, or so it seems. I have another control that can edit one of the objects in the collection, an attach metadata to it. This editor presents input fields for the item.
My idea was to add one of these for each item in the list, allow the data to be edite inside the list. However, when I do, the editor controls I insert completely mix up their ViewStates! Sometime, they get shuffled around, sometimes I get actual rendering
I am unsure if this is caused by my approach being faulty, or the mechanism of ASP.NET.
Could someone please be so kind as to comment on my approach, and give me an optinion on it's sanity? (:
Thanks in advance!
. Knut, Norway