Hello:
I have a aspx web page - let's call it main.aspx
It contains a placeholder: Myplaceholder.
I have a web control, lets call it webcontrol which has a code behind class
called webcontrolclass and a label called mycontrollabel
In the webcontrolclass , I have a private sub called:
Sub writetomycontro llabel(stuff as text)
mycontrollabel. text=stuff
End Sub
The code behind main.aspx
Dim MANAGEGENERAL As Control = LoadControl("we bcontrol.ascx") ' needed for
the placeholder
Public MyMANAGEGENERAL As New webcontrolclass
I have a sub which is called by a button located on main.aspx
Sub mainaspx_click( usualstuff ) handles mainaspx.Click
MyPlaceholder.C ontrols.Add(MAN AGEGENERAL)
MyMANAGEGENERAL .writetomycontr ollabel("hello" )
End sub
I get the error message:
Object reference not set to an instance of an object.
Exception Details: System.NullRefe renceException: Object reference not set
to an instance of an object.
MyMANAGEGENERAL .writetomycontr ollabel("hello" )
So, I am missing something obvious - but I dont get it.
Help
Thanks
Terry 4 1204
I think you need to load the control using
LoadControl method and then add it to the controls collection. The
problem is that the label control inside your custom control is not
loaded yet..
hth
-ashish
ote: Hello:
I have a aspx web page - let's call it main.aspx It contains a placeholder: Myplaceholder.
I have a web control, lets call it webcontrol which has a code behind class called webcontrolclass and a label called mycontrollabel In the webcontrolclass , I have a private sub called: Sub writetomycontro llabel(stuff as text) mycontrollabel. text=stuff End Sub
The code behind main.aspx Dim MANAGEGENERAL As Control = LoadControl("we bcontrol.ascx") ' needed for the placeholder Public MyMANAGEGENERAL As New webcontrolclass
I have a sub which is called by a button located on main.aspx Sub mainaspx_click( usualstuff ) handles mainaspx.Click MyPlaceholder.C ontrols.Add(MAN AGEGENERAL) MyMANAGEGENERAL .writetomycontr ollabel("hello" ) End sub
I get the error message: Object reference not set to an instance of an object. Exception Details: System.NullRefe renceException: Object reference not set to an instance of an object. MyMANAGEGENERAL .writetomycontr ollabel("hello" )
So, I am missing something obvious - but I dont get it. Help Thanks Terry
Where does
MANAGEGENERAL As Control = LoadControl("we bcontrol.ascx")
exist? In Page_Load? Is it executed with every postback and before the
Click event?
--
Scott http://www.OdeToCode.com/blogs/scott/
On Tue, 22 Mar 2005 16:15:15 -0500, "Support"
<Re************ ****@mail.oci.s tate.ga.us> wrote: Hello:
I have a aspx web page - let's call it main.aspx It contains a placeholder: Myplaceholder.
I have a web control, lets call it webcontrol which has a code behind class called webcontrolclass and a label called mycontrollabel In the webcontrolclass , I have a private sub called: Sub writetomycontro llabel(stuff as text) mycontrollabel. text=stuff End Sub
The code behind main.aspx Dim MANAGEGENERAL As Control = LoadControl("we bcontrol.ascx") ' needed for the placeholder Public MyMANAGEGENERAL As New webcontrolclass
I have a sub which is called by a button located on main.aspx Sub mainaspx_click( usualstuff ) handles mainaspx.Click MyPlaceholder. Controls.Add(MA NAGEGENERAL) MyMANAGEGENERAL .writetomycontr ollabel("hello" ) End sub
I get the error message: Object reference not set to an instance of an object. Exception Details: System.NullRefe renceException: Object reference not set to an instance of an object. MyMANAGEGENERAL .writetomycontr ollabel("hello" )
So, I am missing something obvious - but I dont get it. Help Thanks Terry
exist before and page Loads ...
Public Class A
Inherits System.Web.UI.P age
Dim MANAGEGENERAL As Control = LoadControl("Ma nageGeneral.asc x")
Private Sub PAge_Init() Handles MyBAse.Init
End Sub
Private Sub PAge_Load() Handles MyBase.Load
MyPlaceholder.C ontrols.Add(MAN AGEGENERAL)
End Sub
Terry
"Scott Allen" <sc***@nospam.o detocode.com> wrote in message
news:bo******** *************** *********@4ax.c om... Where does
MANAGEGENERAL As Control = LoadControl("we bcontrol.ascx")
exist? In Page_Load? Is it executed with every postback and before the Click event?
-- Scott http://www.OdeToCode.com/blogs/scott/
On Tue, 22 Mar 2005 16:15:15 -0500, "Support" <Re************ ****@mail.oci.s tate.ga.us> wrote:
Hello:
I have a aspx web page - let's call it main.aspx It contains a placeholder: Myplaceholder.
I have a web control, lets call it webcontrol which has a code behind class called webcontrolclass and a label called mycontrollabel In the webcontrolclass , I have a private sub called: Sub writetomycontro llabel(stuff as text) mycontrollabel. text=stuff End Sub
The code behind main.aspx Dim MANAGEGENERAL As Control = LoadControl("we bcontrol.ascx") ' needed for the placeholder Public MyMANAGEGENERAL As New webcontrolclass
I have a sub which is called by a button located on main.aspx Sub mainaspx_click( usualstuff ) handles mainaspx.Click MyPlaceholder .Controls.Add(M ANAGEGENERAL) MyMANAGEGENERAL .writetomycontr ollabel("hello" ) End sub
I get the error message: Object reference not set to an instance of an object. Exception Details: System.NullRefe renceException: Object reference not set to an instance of an object. MyMANAGEGENERAL .writetomycontr ollabel("hello" )
So, I am missing something obvious - but I dont get it. Help Thanks Terry
You might want to turn on two options under Project -> Properties ->
Build: Option Strict and Option Explicit. That might help track down
the source of the error, looking at the code it doesn't seem these
options are on.
--
Scott http://www.OdeToCode.com/blogs/scott/
On Thu, 24 Mar 2005 07:40:45 -0500, "Support"
<Re************ ****@mail.oci.s tate.ga.us> wrote: exist before and page Loads ...
Public Class A Inherits System.Web.UI.P age Dim MANAGEGENERAL As Control = LoadControl("Ma nageGeneral.asc x")
Private Sub PAge_Init() Handles MyBAse.Init End Sub
Private Sub PAge_Load() Handles MyBase.Load MyPlaceholder.C ontrols.Add(MAN AGEGENERAL) End Sub
Terry "Scott Allen" <sc***@nospam.o detocode.com> wrote in message news:bo******* *************** **********@4ax. com... Where does
MANAGEGENERAL As Control = LoadControl("we bcontrol.ascx")
exist? In Page_Load? Is it executed with every postback and before the Click event?
-- Scott http://www.OdeToCode.com/blogs/scott/
On Tue, 22 Mar 2005 16:15:15 -0500, "Support" <Re************ ****@mail.oci.s tate.ga.us> wrote:
Hello:
I have a aspx web page - let's call it main.aspx It contains a placeholder: Myplaceholder.
I have a web control, lets call it webcontrol which has a code behind class called webcontrolclass and a label called mycontrollabel In the webcontrolclass , I have a private sub called: Sub writetomycontro llabel(stuff as text) mycontrollabel. text=stuff End Sub
The code behind main.aspx Dim MANAGEGENERAL As Control = LoadControl("we bcontrol.ascx") ' needed for the placeholder Public MyMANAGEGENERAL As New webcontrolclass
I have a sub which is called by a button located on main.aspx Sub mainaspx_click( usualstuff ) handles mainaspx.Click MyPlaceholde r.Controls.Add( MANAGEGENERAL) MyMANAGEGENERAL .writetomycontr ollabel("hello" ) End sub
I get the error message: Object reference not set to an instance of an object. Exception Details: System.NullRefe renceException: Object reference not set to an instance of an object. MyMANAGEGENERAL .writetomycontr ollabel("hello" )
So, I am missing something obvious - but I dont get it. Help Thanks Terry
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: mike420 |
last post by:
In the context of LATEX, some Pythonista asked what the big
successes of Lisp were. I think there were at least three *big*
successes.
a. orbitz.com web site uses Lisp for algorithms, etc.
b. Yahoo store was originally written in Lisp.
c. Emacs
The issues with these will probably come up, so I might as well
mention them myself (which will also make this a more balanced
|
by: zapazap |
last post by:
Dear Snake Charming Gurus,
(Was: http://mail.python.org/pipermail/python-list/2004-January/204454.html)
First, a thank you to Tim Golden, Thomas Heller, and Mark Hammond
for your earlier help with this problem. I am uncertain about what
etiquette calls for, but more on that later.
My Objective:
I am trying to control the _VMWare Desktop_ application
|
by: CoreyMas |
last post by:
Hello All,
Here is what I would like to do
I am creating a game program that displays a map (preferably in hexes but
that is another matter) and whenever the user is over the "map" I want to
know the x,y coords (in pixels) of where he is pointing to.
Here is what I have done
|
by: Adam Lipscombe |
last post by:
Folks,
I need to get the contents of a form attribute.
In Read/Write mode this is field, so I can use getElementById("name").value
In ReadOnly this is just plain text, so I can use
getElementById("name").innerText.
I need to do it dynamically though, so is there anyway I can look at the
object returned by getElementById() and determine if it was a field or a
|
by: Joe Bloggs |
last post by:
Does anyone know if its possible to pass parameters or the values of
Request.QueryString from a web page to a custom control class? I'm using
a C# Web Application. For Example I have Web Page1 which has to
parameters passed to it from another Web page
Parameter # 1 dbid and Parameter # 2 reportid.
I know that I can access the values of the parameters from the code
behind .aspx.cs using Request.QueryString so
| |
by: Alex |
last post by:
Hi all,
I'm writing a small web application which searches a database based on
a date field, and populates a datagrid control with the results. The
datagrid control has selection buttons added to it to view additional
details about the selected result (a second database query is
triggered).
I want this second query to pop up in a new window, the way it would
if I used "window.open" in javascript. I've added a function in the
|
by: jhcorey |
last post by:
This is an ASP.NET 2.0 question.
In 1.0, common techniques for communicating between a page and the
controls on it
depended on being able to declare variables of the page and control
types.
For example, if I had a page called MyPage.aspx, then I could declare a
variable
of type MyPage in my user control code. Typically I would have a
namespace with the same name as my project.
|
by: rustyc |
last post by:
Well, here's my first post in this forum (other than saying 'HI' over in the hi forum ;-)
As I said over there:
... for a little side project at home, I'm writing a ham radio web site in uby/Rails. I started it in Perl and gave up on Perl as I went from the 'display the database information on the web page' to the 're-display the information from the database and allow the user to update the database using the web page' stage and realized...
|
by: Cirene |
last post by:
I know that sometimes referring to controls deep in a page using a Master
Page can be funky.
For a website using a standard header/footer/nav, do you prefer using User
Controls for the common items, or do you prefer Master Pages?
What is best from your experience? I've downloaded a few sample projects
(like for the Telerik Rad Controls) and have noticed that they like to use
User Controls.
|
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...
|
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...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |