Solved

Change asp.net calendar control Title programatically

Posted on 2014-11-19
2
141 Views
Last Modified: 2014-11-20
Hi I am trying to change the text of the Title property of a calendar control, I have the initial property set in the .aspx but the only thing that happens when I take it out is that is defaults to current date.

<asp:Calendar ID="Calendar_1" runat="server" VisibleDate="2014-01-01">

Open in new window


As a simple test I have tried the following line in the load event and the DayRender event but it doesn't change:

 
protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
Calendar_1.VisibleDate.AddYears(10);
            }
}

//OR

 protected void DayRender(object sender, DayRenderEventArgs e)
        {           
            Calendar_1.VisibleDate = DateTime.Now.AddYears(10);
}

Open in new window


Any help would be appreciated!
0
Comment
Question by:Scarlett72
2 Comments
 
LVL 19

Accepted Solution

by:
Manoj Patil earned 500 total points
Comment Utility
Try this on Calender Init method

Calendar1.VisibleDate = DateTime.Now.Date.AddYears(10).Date;

Open in new window

0
 

Author Closing Comment

by:Scarlett72
Comment Utility
thank you!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now