Saturday, March 24, 2012

Object reference not set to an instance of an object

On a webform, I made a literal DateRange and in Page_Load() assigned to its text a string strDates which I filled with HTML code for 2 date dropdownlist When I ran the form the above error popped up.

The line where the error occurred is :

Me.DatetRange.Text = strDates

What's wrong?

Thanks for any help.Hi,

I'm not sure about your situation, but usually when i get that error there's a word or lettering someplace thats wrong. It's usually not a big deal but i've spent hours before searching for what might be wrong and it turned out to be an s on the end of a work that shouldnt have been there or something dumb like that.

I would check your html and your code behind very carefully.

Hope you work it out
The error states that Me.DatetRange was not initialized. Shouldn't it be Me.DateRange?
I corrected it to DateRange and still get the error.
You don't need to use 'Me.' when referring to a literal, if you're thinking of 'Me' as being the form or page...

if DateRange is the ID of the Literal - - just use DateRange.Text=strDates (depending, of course, on the correct spelling)

0 comments:

Post a Comment