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 1336
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 as so:
if(ex.InnerException.StackTrace != null)...
|
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 long run is have a page using AJAX and having...
|
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
intellisense of ASP & Javascript, it's still not...
|
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 before sending the client there. If the URL does not...
|
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,...
| |
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...
|
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,...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
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...
| |
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 ...
|
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...
| |