Users Pricing

forum

home / developersection / forums / object reference not set to an instance of an object in asp:calendar

Object reference not set to an instance of an object in ASP:Calendar

Elena Glibart 2660 08 Dec 2014

I have an <asp:Calendar> in my code and I want to do is that when a date is clicked, it will show the selected date on the page. 

 protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
    Label1.Text = "The selected date is " + Calendar1.SelectedDate.ToShortDateString();
}

I followed the code instructions from here, Microsoft's website.

But I get this error.

System.NullReferenceException: Object reference not set to an instance of an object.


2 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md