Using a user control in a custom server control.

Angry [:@]

I've created a custom server control and am trying to add a user control to the rendering of the server control.  Is this possible?  If so, hints as to how this is done would be GREATLY appreciated!  Thanks in advance for considering an answer to this question.


4/13/2005 9:33:20 PM 4216 articles. 0 followers. Follow

5 Replies

Similar Articles

[PageSpeed] 8
Get it on Google Play
Get it on Apple App Store

Use the LoadControl method. For example:

Steven Bey

Recursion: see Recursion
4/14/2005 11:16:07 AM
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/15/2005 12:38:55 PM
The TableCell has a ControlsCollection, so just add the UserControl to that.
Steven Bey

Recursion: see Recursion
4/15/2005 1:30:40 PM

Unfortunately, my table is being rendered to the browser with the HTMLTextWriter object.  So, I don't have a named table object to add a control to.  Is there another way to render html to the browser in a server control that would allow me to access the table (and its Rows/Columns) as a named control? 

Thank you for your patience with my questions.  I'm new to .NET and am taking on quite a large project.

4/15/2005 1:40:45 PM

You could load the UserControl at the appropriate place in your Render method and then explicitly call the UserControl's Render method. For example:

   ... Render(HtmlTextWriter writer) {





Steven Bey

Recursion: see Recursion
4/15/2005 2:44:18 PM

Similar Artilces:

Help! Custom Server Control using User Control
I've been bashing my head for a few days on this problem. My Custom Server Control loads the User Control and renders it properly.  But, when I run the web application the controls (ex: buttons) from the User Control is not firing the event (ex: a button click to change the label's text)?Here is a snippet of part of my code:    Protected Overrides Sub CreateChildControls()        plhPanel = New System.Web.UI.WebControls.PlaceHolder        ContentFileLoaded = New System.Web.UI.U...

how to raise server control event(control defined inside user control) from host page?
I have built a user control(using c#,net 2.0,VS2005,MS-SQL server 2005),which contains set of 3 button,save,cancel and next and wud be reused/displayed in multiple pages.As the name says,they are suppose to update on save,reset the fields   on cancel and navigate to another page on next.How do i raise the onClick event for all of these button individually,from the individual host page?I do not have/do not prefer any logic,event handler etc.. defined in the user control for these buttons,since every host page have different set of parameters for save,cancel etc.Thanks...

Using server controls or user controls in FrontPage
I have a frontpage website with shared borders. Can I use a server control (or user control) in FrontPage as the top border? Or could I embed the control in the top border? My dad mentioned something like this scenerio to me and of course I did not have a solution. He finally gave up on FrontPage and converted the entire thing to ASP.Net... as far as both of us were concerned by the end of the day - you cannot mix two server technologies together with little to medium ease. :: I have a frontpage website with shared borders. If you mean frames, then the above does not apply really b...

load user control from server custom control
hi all,i have a 3rd party menu control that consists of a bunch of HyperLinks and a PlaceHolder control (C# v1.1.4) . links to .ascx files are retrieved from a data source, and when the page containing the control is loaded or a link clicked, the control uses this.Page.LoadControl(strLink) to add the .ascx to the PlaceHolder. fine and dandy, probably wouldnt have done it that way myself, but i'm stuck with it :)the problem is events: i can't raise 'em :( if i have for example a Button control on one of the .ascx pages, the Button.Click will go by unnoticed on the post-back. stran...

Using a server control in the rendering a custom control
Hi. I have a custom control that overrides the Render method to draw itself.  Is it possible to use a server control (asp:Image, wwHoverPanel, etc.) inside such a custom control or would I have to rewrite my custom control as a composite control? I'd like to do something something like:protected override void Render(HtmlTextWriter w) { w.RenderBeginTag(HtmlTextWriterTag.Table); w.RenderBeginTag(HtmlTextWriterTag.Tr) w.RenderBeginTag(HtmlTextWriterTag.Td) // somehow place asp:Label here w.RenderEndTag(); // column w.RenderEndTag(); // row ...

Usercontrol vs Custom Server Controls, Any need for Custom Server Controls
Hello I'm new to ASP.Net so this is probably a stupid question but, is there any need to create customer server controls now that you can pre-compile usercontrols into a dll and thus easily share between applications? This blog post from David Ebb describes how to do it and the restrictions he note don't seem that bad (other than being able to embed resources such as images in the dll). His article desribes the techniques for ASP.Net 2.0 and he suggests that there will be further improvements in .Net 3.5 in this ar...

how to have both server controls and html controls rendered in a custom control?
I have a custom control in which there is an html text box.when you click on it , a div containing a table is appeared and according to what you select in that table a text is set to the text box. It works fine but the problem is: as the text box is an html element it doesn't have viewstate and when a post back occures in the page its value disappeares.I tried a hidden field to keep its value.again there is another problem : I put this custom control in a usercontrol and put the usercontrol in a multiview and by clicking on a button this view is selected and by clicking another bu...

Server Web User Control or Web Custom Control
Ok, I made a DataGrid I like, stuck it in a Web Control Lib, and then to my toolbar. Now I want to take my nice little control and add it to a greater control, maybe place some buttons around it etc. I could always inherit from it in a new custom control and dynamically add the buttons, but I thought about using a Web User Control. I thought I could easily create a Web User Control, drop on my grid and the buttons on a form, and expose some properties and events, but once I got into it, I got a feeling that this isn't what a Web User Control is for. When designing a control li... controls used in custom composite controls?
I am creating an events calendar that uses the accordion to display the events for the selected day.  The problem I'm having is that the accordion is not responding to any client side events.  I would really like to find a good "How to" article for building composite controls that incorporate an control like the accordion....

Use Web Custom control or Web User control?
Friends,  I have a generic aspx page and its functions which is used in many .NET web application. The generic page contains a HTML Div control, server drop down list, server buttons, server textbox and it have different server and client functions to do its tasks for calling aspx pages in web applications. My problem is I do not know whether I should make that generic page as a web user control (but this is tedious because all other application folders must store frontpage aspx and code behind files of the generic page) or as a web custom control (This seems to be good beca...

Using ajax control (CollapsiblePanelExtender) in custom server control
 Hi I'm trying to write a server control that contains the collapsiblePanelExtender from the ajax toolkit.  But I have the following error when i try to show this control: Extender control 'ctl00$contentHolder$ctl00$Ant_baseModule1_cpeDemo' is not a registered extender control. Extender controls must be registered using RegisterExtenderControl() before calling RegisterScriptDescriptors(). I have no idea what i must add or change to make it working.  Anyone who has an idea?  Or maybe I'm doing it all wrong? This is my code:   Protected Overrides Sub Render(...

Custom Server Control Vs Web Parts, Any need for Custom Server Control
Hello I've just posted a similar question on why you need server controls when you can pre-compile usercontrols and redistribute them. I've seen lots of (usercontrol vs web part) but not much on web part vs custom server control. According to the MSDN site you can put web parts onto a normal page outside of a web part zone and they behave just like custom server controls. So, if you are creating a bunch of controls for redistribution to customer sites and/or SharePoint sites why don't you just create Web Par...

problems listenening to events on a custom server control from another custom server control
 Hi all,I am having problems listening to events on one of custom server controls(AddBookmark) from another custom server control(BookmarkList). The listener or the BookmarkList control has a property that can be set to the AddBookmark control (string at design but the reference is obtained at run-time). I am able to get a reference to the AddBookmark control and add a listener to it on the BookmarkList control on the OnPrender of BookmarkList. But the problem is that when the events on AddBookmark gets fired, the listener added from the BookmarkList is no longer present and the listene...

Custom Server Control Made of Custom Controls?
I'm giving myself a crash course in custom server controls, and I have a quick general question. Can I have a custom server control that is composed of other server controls I created. I'm pretty sure the answer is yes, but I want to be positive. Yes Shows how to combine existing controls into a new control using class composition. -ron Thanks! ASP.NET so rocks! Making page components extensible objects is such a great idea! I love it....

Web resources about - Using a user control in a custom server control. -

Control - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Insteon adds Sonos integration to control speakers from its iOS app & hardware
Users of Insteon’s connected home automation products will now be able to control their Sonos speakers directly from Insteon hardware and the ...

Control your Audi with your Apple TV, if you want to
Filed under: 2016 CES , Audi , Gadgets , Smartphone , Technology Have an A4 or Q7 and a new Apple TV? Audi will let them talk to each other on ...

Nexia brings voice control through Amazon Echo, adds upgraded Windows 10 app
... built on Microsoft's Universal Windows platform, meaning it can run on all devices. The biggest feature being added is the ability to control ...

Larwyn’s Linx: A Thorough Fisking Of Obama’s Executive Orders On Gun Control
... install a Larwyn's Linx widget . Get real-time news, 24/7, at BadBlue . Nation A Thorough Fisking Of Obama’s Executive Orders On Gun Control ...

The Nuclear Option — Executive Gun Control: Obama Creates ‘Crazy List,’ Disarms the Elderly
When all the hectoring is finished, the professorial lecturing is done, all the political posturing is over, all that is left are tears. And ...

UK police forces are going to use drones to help them control protests and carry out sieges
UK police forces are going to start using drones to help them control protests, investigate burglaries and carry out sieges, according to The ...

Bug in Silent Circle's Blackphone let attackers remotely control device
... a remote takeover vulnerability that attackers could exploit to send and receive text messages, to eavesdrop on calls and to remotely control ...

Here’s The Kind Of Control Gun Advocates Can Get Behind
Here’s The Kind Of Control Gun Advocates Can Get Behind

Gesture Control Comes To Volkswagon Concept Vehicles, Your Living Room And Life At CES
Control this! Gesture comes to your car, living room and just about everywhere in your life through two new gesture devices at CES 2016.

Resources last updated: 1/7/2016 11:46:35 AM