473,626 Members | 3,247 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

added user control not showing up

PJ6
I need to add a user control in code, not through the designer. For some
reason it just doesn't show up. Is there some initialization method I need
to call for the control before attemptin to add it?

Paul

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
Me.Controls.Add (New WebUserControl3 )
End Sub

Nov 19 '05 #1
3 6487
Paul,

When you add a control dynamically, you have to add it to another control.
In the case of what you're trying, you should be using a placeholder
control.

Put the placeholder on your page where you want the user control to appear.
Then add your dynamic control to the placeholder.

Placeholder1.Co ntrols.Add(MyCo ntrol)

If you'd like some working examples I have a few available on my website,
www.aboutfortunate.com, Just click on the "Code Library" link at the top and
then type "Dynamic Control" into the search text box that will appear and
you'll have a few examples.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"PJ6" <no****@nowhere .net> wrote in message
news:O0******** ******@TK2MSFTN GP15.phx.gbl...
I need to add a user control in code, not through the designer. For some
reason it just doesn't show up. Is there some initialization method I need
to call for the control before attemptin to add it?

Paul

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
Me.Controls.Add (New WebUserControl3 )
End Sub

Nov 19 '05 #2
PJ6
I had already tried that. But just for the heck of it I used a placeholder
control as you suggested. The user control still doesn't show up. Stragenly,
if I change the inheritance from System.Web.UI.U serControl to something else
(such as HtmlInputCheckB ox), it shows up just fine...?

Paul

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate. com> wrote in
message news:%2******** *******@TK2MSFT NGP12.phx.gbl.. .
Paul,

When you add a control dynamically, you have to add it to another control.
In the case of what you're trying, you should be using a placeholder
control.

Put the placeholder on your page where you want the user control to
appear. Then add your dynamic control to the placeholder.

Placeholder1.Co ntrols.Add(MyCo ntrol)

If you'd like some working examples I have a few available on my website,
www.aboutfortunate.com, Just click on the "Code Library" link at the top
and then type "Dynamic Control" into the search text box that will appear
and you'll have a few examples.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"PJ6" <no****@nowhere .net> wrote in message
news:O0******** ******@TK2MSFTN GP15.phx.gbl...
I need to add a user control in code, not through the designer. For some
reason it just doesn't show up. Is there some initialization method I need
to call for the control before attemptin to add it?

Paul

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
Me.Controls.Add (New WebUserControl3 )
End Sub


Nov 19 '05 #3
PJ6
I got it...

Page.LoadContro l
"PJ6" <no****@nowhere .net> wrote in message
news:u1******** ******@TK2MSFTN GP15.phx.gbl...
I had already tried that. But just for the heck of it I used a placeholder
control as you suggested. The user control still doesn't show up.
Stragenly, if I change the inheritance from System.Web.UI.U serControl to
something else (such as HtmlInputCheckB ox), it shows up just fine...?

Paul

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate. com> wrote in
message news:%2******** *******@TK2MSFT NGP12.phx.gbl.. .
Paul,

When you add a control dynamically, you have to add it to another
control. In the case of what you're trying, you should be using a
placeholder control.

Put the placeholder on your page where you want the user control to
appear. Then add your dynamic control to the placeholder.

Placeholder1.Co ntrols.Add(MyCo ntrol)

If you'd like some working examples I have a few available on my website,
www.aboutfortunate.com, Just click on the "Code Library" link at the top
and then type "Dynamic Control" into the search text box that will appear
and you'll have a few examples.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"PJ6" <no****@nowhere .net> wrote in message
news:O0******** ******@TK2MSFTN GP15.phx.gbl...
I need to add a user control in code, not through the designer. For some
reason it just doesn't show up. Is there some initialization method I
need to call for the control before attemptin to add it?

Paul

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
Me.Controls.Add (New WebUserControl3 )
End Sub



Nov 19 '05 #4

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

Similar topics

5
2009
by: Henke | last post by:
I added a project to my solution that contains a user control. Now I 'd like to add the user control from that project to a form in my solution. The problem is that the control doesn't gets added to the My User Control tab. Any ideas? Thanks in advance, Henke!
9
2444
by: Anders K. Jacobsen [DK] | last post by:
Hi I have this that adds some usercontrol (UCTodays.ascx) to a placeholder foreach(A a in B){ UCTodays ucline = (UCTodays )LoadControl("UCTodays.ascx"); ucline.Initializecontrol(line,alternate); Placeholder1.Controls.Add(ucline); }
6
3367
by: Steve Booth | last post by:
I have a web form with a button and a placeholder, the button adds a user control to the placeholder (and removes any existing controls). The user control contains a single button. I have done all the usual stuff of recreating the usercontrol in the Page Init event. The 'failure' sequence is as follows: - select web form button to display the user control - select user control button, event fires - select web form button to display...
3
1270
by: Moojjoo | last post by:
I created an user control (.ascx file) with a DropDownList (DDL) with the following code behide: public string Selected_dept_value() { string dept_value = dept_dropdown.SelectedValue; return dept_value; } All the values were added via the visual interface.
7
3187
by: Samuel | last post by:
Hi, I am building a page that makes use of user control as a templating technique. The following is that I have in mind and it is actually working: Root/ -- login.aspx -- login.aspx.vb -- UC/ ----- Classic/
4
3015
by: Jordan | last post by:
I need to dynamically add an ImageButton control to a user control and and do some server-side processing when the user clicks it. While I the ImageButton is added to the user control at runtime, as needed, I'm having trouble wiring up its click event procedure. The problem is that when I go to subscribe the ImageButton to the delegate, the ImageButton is <undefined> (i.e., throws the "object not found" exception). Note that I'm using...
0
2395
by: Mike Collins | last post by:
I someone can please help, I am about at an end in trying to figure this out. I am adding some dynamic controls to my page (I found out that I was supposed to be doing that in the oninit event, which I am). I now want to read the text/values of those controls. I have found out that I can read the values if I wait until Page_Load, but then I have the same questions showing up again (along with the new questions) and I do not want them to....
1
7589
by: jelle.huygen | last post by:
Hello, I have a problem in ASP.NET 2.0 with the viewstate of my dynamically added user control. I have reproduced the problem with a very simple user control and a very simple page. On my usercontrol is a button and a label. Everytime the button is clicked a counter which is stored in the viewstate is increased and displayed in the label.
3
3559
by: reelrave | last post by:
Hello All, I've checked around a little on Google (and this group) and have found info similar to what I'm trying to do (i.e., changes that were made in the BE's tables are not reflected in the FE database) and have heard suggestions using code, etcetera. But I need a bit more clarification please. What I'm doing/have done is this (MS Access 2007, FE stored on WXP clients, BE stored on a W2K3 server):
0
8269
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8711
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8368
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7203
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4094
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4206
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2630
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1515
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.