Hi all,
I have a usercontrol (a textbox with dropdown calendar that fills the
textbox with the selected date) that I implement in a datagrid in a webform.
On first loading the page, the datagrid's visibility is set to 'false', and
so the UC depCal is not rendered on the page. Hence the following code in
the InitializeComponent() method causes an error:
this.depCal.DateChanged += new
custCalendar.DateChangedEventHandler(this.depCal_D ateSet);
The error is: 'Object reference not set to an instance of an object'
Hence I think what I need to do is check for the existance of the control
depCal on the page before exectuing the above code snippet. I tried the
code below, again in the InitializeComponent() method, but it didn't work.
Even when the Datagrid and hence the control depCal is visible on the page,
I never get inside the IF statement.
if ( depCal != null ) {
this.depCal.DateChanged += new
custCalendar.DateChangedEventHandler(this.depCal_D ateSet);
}
Can you tell me if I'm approaching the problem from the right angle, and how
to solve it? Thanks in advance for your help,
Iain 4 1255
With .visibility = false, you should not throw an error. If you are
dynamically placing the control, it is another story. In that case, you can
add the event handler at the time you create the control on the page.
One way to toggle on and off is to place panels on the page and make the
whole panel invisible. It works very nice, esp. if you have multiple
controls that have to be toggled.
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
************************************************** ********************
Think Outside the Box!
************************************************** ********************
"Iain Porter" <st***@intraspin.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl... Hi all, I have a usercontrol (a textbox with dropdown calendar that fills the textbox with the selected date) that I implement in a datagrid in a
webform. On first loading the page, the datagrid's visibility is set to 'false',
and so the UC depCal is not rendered on the page. Hence the following code in the InitializeComponent() method causes an error: this.depCal.DateChanged += new custCalendar.DateChangedEventHandler(this.depCal_D ateSet);
The error is: 'Object reference not set to an instance of an object'
Hence I think what I need to do is check for the existance of the control depCal on the page before exectuing the above code snippet. I tried the code below, again in the InitializeComponent() method, but it didn't work. Even when the Datagrid and hence the control depCal is visible on the
page, I never get inside the IF statement.
if ( depCal != null ) { this.depCal.DateChanged += new custCalendar.DateChangedEventHandler(this.depCal_D ateSet); }
Can you tell me if I'm approaching the problem from the right angle, and
how to solve it? Thanks in advance for your help,
Iain
Is the problem that in the method InitialiseComponent(), we don't know
anything about the controls on the page, and hence can't tell if they exist
or not, or if they are visible or not?
Thanks - I will change them to panels, as there will be several controls
relating to the grid that will all become visible at once. I'm not
dynamically placing the controls - they are coded into the .aspx file - i
just toggle visibility.
Thanks, Iain
"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamM> wrote in
message news:Oq**************@TK2MSFTNGP12.phx.gbl... With .visibility = false, you should not throw an error. If you are dynamically placing the control, it is another story. In that case, you
can add the event handler at the time you create the control on the page.
One way to toggle on and off is to place panels on the page and make the whole panel invisible. It works very nice, esp. if you have multiple controls that have to be toggled.
-- Gregory A. Beamer MVP; MCP: +I, SE, SD, DBA
************************************************** ******************** Think Outside the Box! ************************************************** ******************** "Iain Porter" <st***@intraspin.com> wrote in message news:%2***************@TK2MSFTNGP09.phx.gbl... Hi all, I have a usercontrol (a textbox with dropdown calendar that fills the textbox with the selected date) that I implement in a datagrid in a webform. On first loading the page, the datagrid's visibility is set to 'false', and so the UC depCal is not rendered on the page. Hence the following code
in the InitializeComponent() method causes an error: this.depCal.DateChanged += new custCalendar.DateChangedEventHandler(this.depCal_D ateSet);
The error is: 'Object reference not set to an instance of an object'
Hence I think what I need to do is check for the existance of the
control depCal on the page before exectuing the above code snippet. I tried the code below, again in the InitializeComponent() method, but it didn't
work. Even when the Datagrid and hence the control depCal is visible on the page, I never get inside the IF statement.
if ( depCal != null ) { this.depCal.DateChanged += new custCalendar.DateChangedEventHandler(this.depCal_D ateSet); }
Can you tell me if I'm approaching the problem from the right angle, and how to solve it? Thanks in advance for your help,
Iain
It is possible that the InitializeComponent event is a problem. In general,
I use Page_Load for common stuff and event handlers for control driven
events. I still like panels, as you make visible (or visa versa) in one
step, which is very convenient. The page weight is rather light, so it is
not a big maintainability versus performance issue.
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
************************************************** ********************
Think Outside the Box!
************************************************** ********************
"Iain Porter" <st***@intraspin.com> wrote in message
news:ud******************@TK2MSFTNGP12.phx.gbl... Is the problem that in the method InitialiseComponent(), we don't know anything about the controls on the page, and hence can't tell if they
exist or not, or if they are visible or not?
Thanks - I will change them to panels, as there will be several controls relating to the grid that will all become visible at once. I'm not dynamically placing the controls - they are coded into the .aspx file - i just toggle visibility.
Thanks, Iain
"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamM> wrote in message news:Oq**************@TK2MSFTNGP12.phx.gbl... With .visibility = false, you should not throw an error. If you are dynamically placing the control, it is another story. In that case, you can add the event handler at the time you create the control on the page.
One way to toggle on and off is to place panels on the page and make the whole panel invisible. It works very nice, esp. if you have multiple controls that have to be toggled.
-- Gregory A. Beamer MVP; MCP: +I, SE, SD, DBA
************************************************** ******************** Think Outside the Box! ************************************************** ******************** "Iain Porter" <st***@intraspin.com> wrote in message news:%2***************@TK2MSFTNGP09.phx.gbl... Hi all, I have a usercontrol (a textbox with dropdown calendar that fills the textbox with the selected date) that I implement in a datagrid in a webform. On first loading the page, the datagrid's visibility is set to
'false', and so the UC depCal is not rendered on the page. Hence the following
code in the InitializeComponent() method causes an error: this.depCal.DateChanged += new custCalendar.DateChangedEventHandler(this.depCal_D ateSet);
The error is: 'Object reference not set to an instance of an object'
Hence I think what I need to do is check for the existance of the control depCal on the page before exectuing the above code snippet. I tried
the code below, again in the InitializeComponent() method, but it didn't work. Even when the Datagrid and hence the control depCal is visible on the
page, I never get inside the IF statement.
if ( depCal != null ) { this.depCal.DateChanged += new custCalendar.DateChangedEventHandler(this.depCal_D ateSet); }
Can you tell me if I'm approaching the problem from the right angle,
and how to solve it? Thanks in advance for your help,
Iain
So is the problem in the 'how' I'm testing for the existance of the control,
or the 'when'? Is Page_Load too early? I alse tried putting the code into
a Grid_Load event, but with the same results - the control always registers
as null.
Is there a later method in which I can test for the existance, i.e. a
once_the_control_has_loaded_to_the_page event?
How would I implement an onrender event?
Thanks again for your help,
Iain
"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamM> wrote in
message news:u2**************@TK2MSFTNGP11.phx.gbl... It is possible that the InitializeComponent event is a problem. In
general, I use Page_Load for common stuff and event handlers for control driven events. I still like panels, as you make visible (or visa versa) in one step, which is very convenient. The page weight is rather light, so it is not a big maintainability versus performance issue.
-- Gregory A. Beamer MVP; MCP: +I, SE, SD, DBA
************************************************** ******************** Think Outside the Box! ************************************************** ******************** "Iain Porter" <st***@intraspin.com> wrote in message news:ud******************@TK2MSFTNGP12.phx.gbl... Is the problem that in the method InitialiseComponent(), we don't know anything about the controls on the page, and hence can't tell if they exist or not, or if they are visible or not?
Thanks - I will change them to panels, as there will be several controls relating to the grid that will all become visible at once. I'm not dynamically placing the controls - they are coded into the .aspx file -
i just toggle visibility.
Thanks, Iain
"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamM> wrote
in message news:Oq**************@TK2MSFTNGP12.phx.gbl... With .visibility = false, you should not throw an error. If you are dynamically placing the control, it is another story. In that case,
you can add the event handler at the time you create the control on the page.
One way to toggle on and off is to place panels on the page and make
the whole panel invisible. It works very nice, esp. if you have multiple controls that have to be toggled.
-- Gregory A. Beamer MVP; MCP: +I, SE, SD, DBA
************************************************** ******************** Think Outside the Box! ************************************************** ******************** "Iain Porter" <st***@intraspin.com> wrote in message news:%2***************@TK2MSFTNGP09.phx.gbl... > Hi all, > I have a usercontrol (a textbox with dropdown calendar that fills
the > textbox with the selected date) that I implement in a datagrid in a webform. > On first loading the page, the datagrid's visibility is set to 'false', and > so the UC depCal is not rendered on the page. Hence the following code in > the InitializeComponent() method causes an error: > this.depCal.DateChanged += new > custCalendar.DateChangedEventHandler(this.depCal_D ateSet); > > The error is: 'Object reference not set to an instance of an object' > > Hence I think what I need to do is check for the existance of the control > depCal on the page before exectuing the above code snippet. I tried the > code below, again in the InitializeComponent() method, but it didn't
work. > Even when the Datagrid and hence the control depCal is visible on
the page, > I never get inside the IF statement. > > if ( depCal != null ) { > this.depCal.DateChanged += new > custCalendar.DateChangedEventHandler(this.depCal_D ateSet); > } > > Can you tell me if I'm approaching the problem from the right angle, and how > to solve it? Thanks in advance for your help, > > Iain > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Lance |
last post by:
Hi,
How do you test for an object existing in C#? C# seems to differentiate
between 'null' and non-existance. In other languages I could test...
|
by: Lloyd Sheen |
last post by:
Ok I have created a small testbed site for testing and I am have a problem
with the terms Usercontrol, Webcontrol, etc.
What I need to do in the...
|
by: Andrew Wan |
last post by:
I have been developing web applications with ASP & Javascript for a long
time. I have been using Visual Studio 2003.NET. While VS2003 is okay for...
|
by: =?Utf-8?B?Tm9yZW1hYw==?= |
last post by:
I have had no luck with the following scenario:
One of our requirements for a particular business scenario is to test the
existance of a URL...
|
by: concettolabs |
last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
|
by: better678 |
last post by:
Question:
Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct?
Answer:
Java is an object-oriented...
|
by: teenabhardwaj |
last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
|
by: CD Tom |
last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
|
by: CD Tom |
last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
| |