473,398 Members | 2,120 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,398 software developers and data experts.

Addin ASCX control at runtime and page_load

I have an ASCX control with 2 objects (asp:label and asp:xml)
I wan't to add this control using Controls.Add() because my business logic
requires to select the correct control to show.

I have some code on ASCX page_load event that makes references to asp:label
(only set text property to it) and asp:xml.

If i add the control directly in an ASPX page i have no problems but if i
add it with Controls.Add() i have the following error: "Object reference not
set to an instance of an object"

What could be the solution? Should i put the logic in another event?

thanks,
Gonçalo Boléo
Nov 19 '05 #1
1 1756
Without seeing code it's impossible to tell.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Gonçalo Boléo" <gb****@netcabo.pt> wrote in message
news:ei*************@TK2MSFTNGP15.phx.gbl...
I have an ASCX control with 2 objects (asp:label and asp:xml)
I wan't to add this control using Controls.Add() because my business logic
requires to select the correct control to show.

I have some code on ASCX page_load event that makes references to
asp:label (only set text property to it) and asp:xml.

If i add the control directly in an ASPX page i have no problems but if i
add it with Controls.Add() i have the following error: "Object reference
not set to an instance of an object"

What could be the solution? Should i put the logic in another event?

thanks,
Gonçalo Boléo

Nov 19 '05 #2

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

Similar topics

0
by: dh | last post by:
As a simple example, I can't seem to be able to reference a label called "lblOutput" that exists in my test.aspx page from within a User control, TestControl.ascx. I am stumped. Any help is...
4
by: George Durzi | last post by:
I created a simple user control which contains a hyperlink to link the user to a topic in a compiled help file. I named all my help topics to have the same name as the aspx they are for. So in...
2
by: C K | last post by:
I am having trouble getting the page_load event to fire from within my usercontrol - my code is below, I'm sure I'm missing something simple. Just your basic web user control - I've just began...
1
by: Andrew Parsons | last post by:
Hi all, I had a weird issue with trying to use a cookie in a ASCX housed on my web forms and I was wondering if I am missing something. I wanted to use the authenticated cookie for the user...
1
by: Oleg Ogurok | last post by:
Hi all, In my page class, I'm loading a user control: private void Page_Load(object sender, System.EventArgs e) { Control c = LoadControl("WebUserControl1.ascx"); Controls.AddAt(0, c); }
1
by: Gonçalo Boléo | last post by:
I have an ASCX control with 2 objects (asp:label and asp:xml) I wan't to add this control using Controls.Add() because my business logic requires to select the correct control to show. I have...
3
by: Bert | last post by:
Hi I am trying to load my user control in a placeholder, i get an error: c:\inetpub\wwwroot\testinline\WebForm2.aspx.vb(26): Type 'WebUserControl6' is not defined? Private Sub...
0
by: CMELLO | last post by:
I have am dynamically loading a web user control based on the click of a tab strip I load the default control for the first tab in the page load event after checking page is not postback. After...
0
by: =?Utf-8?B?Y2luZHk=?= | last post by:
I have am dynamically loading a web user control based on the click of a tab strip I load the default control for the first tab in the page load event after checking page is not postback. After...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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,...
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.