The Artima Developer Community
Sponsored Link

.NET Buzz Forum
A couple ASP.NET lessons learned

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Brad Wilson

Posts: 462
Nickname: dotnetguy
Registered: Jul, 2003

Brad Wilson is CTO of OneVoyce, Inc.
A couple ASP.NET lessons learned Posted: Nov 29, 2003 10:55 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Brad Wilson.
Original Post: A couple ASP.NET lessons learned
Feed Title: The .NET Guy
Feed URL: /error.aspx?aspxerrorpath=/dotnetguy/Rss.aspx
Feed Description: A personal blog about technology in general, .NET in specific, and when all else fails, the real world.
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Brad Wilson
Latest Posts From The .NET Guy

Advertisement

I'm in the middle of the laborous process of writing an article (or, more likely, a series of articles) for my web site about ASP.NET Tips and Tricks.

We have a lot of lessons we've learned from bending and breaking ASP.NET, especially as it pertains to writing custom server controls. Here's a couple quick ones that I keep banging my head against:

1. Put controls in the tree as soon as possible.

A lot of things happen when the control is in the tree; namely, you get access to events, you can reference your parent Page, you can retrieve your unique client-side ID, etc. The longer you're not in the tree, the longer you have to wait for access to those things (in one example I'm struggling with today, I need the client ID but I can't find it). If a control needs these things, then it needs to be in the tree as quickly as possible.

2. Separate rendering from the child control tree.

When making a server side control, the child control tree gives things access to the events and pages and client IDs, as seen in #1. However, I've found it to be a mistake to simply create the entire child control tree with EVERYTHING you plan to render. Most often, this can be almost impossible to achieve in the face of postbacks, because your child control tree might be changing as a result of the work done during postback. Just as important for events, this child tree needs to reflect the exact same during repeated postbacks so that events are sent to the right control. Change the tree, and the IDs change, and your button click may end up sent to the wrong button!

So my recommendation here is to only put things into the tree that have a need to be there -- controls that render data and receive events -- and to leave the actual physical rendering of the layout of the tree. The things in the child control tree don't even necessarily need to be rendered.

Writing server-side controls is very difficult if you wish to do it well. You cannot ignore the reality of the fact that there's HTML underneath, and that this UI doesn't really function like a traditional rich UI.

// Now playing: Kamelot - Silent Goddess //

Read: A couple ASP.NET lessons learned

Topic: Where's the Yukon content? Previous Topic   Next Topic Topic: I need to learn how to write a review

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use