Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > Other ASP.NET > ASP.NET 1.x and 2.0 Application Design
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 13th, 2005, 04:42 PM
Registered User
 
Join Date: May 2004
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default User Control within Custom Server Controls

Is it possible to use a user control in a custom server control? If so, how is it rendered to the browser?

Thanks in advance!

  #2 (permalink)  
Old April 13th, 2005, 07:34 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

A user control lives as an ASCX file in the web project so it wouldn't normally be used in a compiled control. However... you could create an instance of such a control. The Page class has a method 'LoadControl' which takes a file as an argument. This will load an instance of a control that you could then add to a controls collection inside your custom control. Keep in mind however, that you will run into a potential problem with this: if the compiled control is in a different assembly and you need to reference the class type that represents the user control (the code behind the ASCX) you'll end up with a circular reference. Also in my opinion, by doing this you are kind of breaking the rules of building a custom server control by making it dependant on an external resource that you can't directly supply. The consumer of the custom control will have to have the user control file in their web project.

-Peter
  #3 (permalink)  
Old April 15th, 2005, 07:37 AM
Registered User
 
Join Date: May 2004
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

My server control renders a table with x number of rows. I want to add a user control to each row of the table, last column. I do not know how many user controls I will need until runtime. How do I specify where the user control is placed in the server control's table cell?

  #4 (permalink)  
Old April 15th, 2005, 09:00 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You need to add it to the last column's cell's Controls collection in the appropriate order. As long as it's in the controls collection .NET will render it.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom Server Control....Custom Property Editor ZArrinPour ASP.NET 1.0 and 1.1 Basics 1 June 15th, 2010 11:30 AM
Help! Custom Server Control using User Control diehard ASP.NET 1.0 and 1.1 Professional 2 January 4th, 2006 12:33 PM
DataGrid Controls Within custom validator control geetha_ganesan ADO.NET 1 March 26th, 2005 04:38 PM
urgent custom control with collection of controls dd_smith Pro VB.NET 2002/2003 1 December 19th, 2004 06:05 PM
custom server controls rotsey General .NET 0 November 24th, 2004 03:08 AM



All times are GMT -4. The time now is 11:09 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.