Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Object reference not set for an instance of an object in a .ASCX file

Reply
Thread Tools

Object reference not set for an instance of an object in a .ASCX file

 
 
Cal Who
Guest
Posts: n/a
 
      03-30-2010
In Design mode the code below shows:
Error rendering control - dp1
An unhandled exception has occurred.
Object reference not set for an instance of an object.

Likewise for tp1, dp2 and tp2

The code appears to work OK but I would like to remove those notices when I
look at it.

Any suggestions?

Thanks



<%@ Control Language="VB" AutoEventWireup="false"
CodeFile="DurationSelecter.ascx.vb" Inherits="Calendar_DurationSelecter" %>

<%@ Register TagPrefix="MyLib" Namespace="My.Library" %>

<script runat="server">


Public Property startDateTime() As Date

Get

Return dp1.SelectedDate.Add(tp1.SelectedTime.TimeOfDay)


End Get

Set(ByVal value As Date)

dp1.SelectedDate = value

tp1.SelectedTime = value

End Set

End Property


Public Property endDateTime() As Date

Get

Return dp2.SelectedDate.Add(tp2.SelectedTime.TimeOfDay)


End Get

Set(ByVal value As Date)

dp2.SelectedDate = value

tp2.SelectedTime = value

End Set

End Property


</script>

<table>

<tr>

<td align="center" colspan="2">

Start Date and Time:

</td>

<td align="center" colspan="2">

End Date and Time:

</td>

</tr>

<tr>

<td>

<MyLibatePicker ID="dp1" runat="server" />

</td>

<td>

<MyLib:TimePicker ID="tp1" runat="server" />

</td>

<td>

<MyLibatePicker ID="dp2" runat="server" />

</td>

<td>

<MyLib:TimePicker ID="tp2" runat="server" />

</td>

</tr>

</table>



the .vb file contains only:

Partial Class Calendar_DurationSelecter

Inherits System.Web.UI.UserControl

End Class


 
Reply With Quote
 
 
 
 
Mr. Arnold
Guest
Posts: n/a
 
      04-01-2010


"Cal Who" wrote:

> In Design mode the code below shows:
> Error rendering control - dp1
> An unhandled exception has occurred.
> Object reference not set for an instance of an object.
>
> Likewise for tp1, dp2 and tp2
>
> The code appears to work OK but I would like to remove those notices when I
> look at it.
>
> Any suggestions?
>


I would suspect that one of your data values is a null value. A value cannot
be cast to an object like string, int, longm, etc if the value is null.

Your application is failing, and it's going on like nothing happened due to
the application not knowing that it failed.
 
Reply With Quote
 
 
 
 
Cal Who
Guest
Posts: n/a
 
      04-02-2010
Right you are. I didn't know I had to do that.

Thanks



"Mr. Arnold" <> wrote in message
news:A22E66C0-4F53-4089-966B-...
>
>
> "Cal Who" wrote:
>
>> In Design mode the code below shows:
>> Error rendering control - dp1
>> An unhandled exception has occurred.
>> Object reference not set for an instance of an object.
>>
>> Likewise for tp1, dp2 and tp2
>>
>> The code appears to work OK but I would like to remove those notices when
>> I
>> look at it.
>>
>> Any suggestions?
>>

>
> I would suspect that one of your data values is a null value. A value
> cannot
> be cast to an object like string, int, longm, etc if the value is null.
>
> Your application is failing, and it's going on like nothing happened due
> to
> the application not knowing that it failed.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Object reference not set to an instance of an object" Weird thing happens with reference a link nguyentrongkha@gmail.com ASP .Net 1 09-20-2007 09:46 PM
Error:Object reference not set to an instance of an object. Suresh Kojhani ASP .Net 1 07-29-2004 12:10 PM
Error !Object reference not set to an instance of an object. !!! Help Parthiv Joshi ASP .Net 2 07-02-2004 10:28 AM
Object reference not set to an instance of an object. yysiow ASP .Net 1 07-12-2003 03:30 PM
Object reference not set to an instance of an object. Chris Fink ASP .Net 2 07-03-2003 06:48 PM



Advertisments