views:

37

answers:

2

I haven't seen this implemented before in ASP.NET, but am thinking about a UI that would look and act like this:

Conceptual Overview

  • A TabControl is loaded and the first tab contains a grid
  • When a row is double-clicked, a new tab is created with the record detail
  • The content of the tab/record detail is created by a usercontrol
  • Many tabs could be created, and therefore many instances of the usercontrol will be created

I know ASP.NET will rename my (runat="server") ID's for me, and that I can use jQuery or ASP.NET server-side code to work with the ID's... My concerns are:

  • How can I ask ASP.NET to generate a unique ID for each Nth instance of my usercontrol (to be rendered in a placeholder)
  • How do I actually create that extra instance of the control?
  • What else do I need to keep in mind?

Since I don't want postbacks I'm considering basing my implementation off of ComponentArt's Callback Control, and using ASP.net usercontrols to achieve this effect. This will allow me to do most things that require a postback, but won't refresh all the elements on a page... just the section that contains the user control. That being said, I'm not tied to a particular implementation.

A: 

btw, if you use .NET 4.0 you can set ClientIdMode to Static so control will have the same ID as it has in markup. See MSDN

abatishchev
I've barely scratched the surface of .NET 4... thanks for the tip! Also, I'll fix my casing of ASP.NET from now on ;)
MakerOfThings7
A: 

You should look into the Page.LoadControl method. It works nicely and as far as I remember you put placeholders on your page and load the controls into the PlaceHolders, that's how you control the ids.

One thing that doesn't work out so well with this approach is when your control raises events that your Page object has to handle. If your control is selfcontained however you shouldn't have a problem.

This might help you get started: http://www.codeproject.com/KB/aspnet/LoadingUSerControl.aspx

Tjaart