473,396 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Add a WebUserControl Control At Runtime

I would like to add a WebUserControl control at runtime in the
CreateChildControls() method, but it's not working like I had hoped.
This technique works fine for WebControls:

protected override void CreateChildControls()
{
Header hdr = new Header();
Footer ftr = new Footer();

Controls.Add(hdr);
Controls.Add(ftr);
}

Header and Footer are both WebUserControl's. How would I go about
adding these controls at runtime?

Thank you in advance,

--
Sean

http://senfo.blogspot.com
Feb 24 '06 #1
1 1285
Nevermind, found out that I needed to call the LoadControl() method on
WebUserControls rather than instantiating them:

protected override void CreateChildControls()
{
Header hdr = (Header) this.LoadControl("Controls/Header.ascx");
Footer ftr = (Footer) this.LoadControl("Controls/Footer.ascx");

Controls.AddAt(1, hdr); // Add header
Controls.AddAt(4, ftr); // Add footer
}

--
Sean

http://senfo.blogspot.com
Feb 24 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Chris | last post by:
Hi, I have 2 textboxes (txtVal1, txtVal2) in a WebUserControl (WebCalcUserControl) for which I write public properties : public int Value1 { get { return Convert.ToInt32(txtVal1.Text); }...
2
by: Arun | last post by:
I am new to ASP.NET I need some help for this scenario The scenario is like this I have a template Page which loads a WebUserControl (uct1.ascx) inside a PlaceHolder (PH1) Now this Web User...
1
by: Serdar Kalaycý | last post by:
Hi There, I have a webusercontrol and it works allright when created at design time. But when I try to create it at the runtime (this is because the number of control needed is variable) I could...
1
by: DichkoSoft | last post by:
Hi I create WebUserControl and very confused when use control For Example: ***************************** *wuc.ascx ***************************** <script id=clientEventHandlersJS...
0
by: Christian H | last post by:
Hello, I've just created a WebUserControl that consists of a few other controls such as DropDownList, TextBox and Button. Based on the information entered in the DropDownlist, and TextBox, the...
4
by: Oren | last post by:
hi, How can I call to a Function/Property and send data dynamically to the UserControl ? I mean Instead (look at CurrentPage): <Result:Header id="rh" CurrentPage="1" RecordsPerPage="2"...
0
by: Giovanni | last post by:
Dear Friends, I have a decision to make and hope to get some insight: I have built several WebUserControls one of which is a WebUserControl that queries an SQL server database, retrieves a...
0
by: Terry Olsen | last post by:
In an effort to create a QueryBuilder for a web page, I've created a WebUserControl. It can be seen here: http://boycot.no-ip.com/images/querybuilder.jpg I load one control initially in the...
0
by: Klaus Jensen | last post by:
Hi In a repeater-control, in the <SeparatorTemplatei have placed a webusercontrol, I have made. That works great- However, I want to know be able to only display this WebUserControl a certain...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.