Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9146659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:48:04+00:00 2026-06-17T10:48:04+00:00

Need to add a button for next previous year in ASP calendar control dynamically.

  • 0

Need to add a button for next previous year in ASP calendar control dynamically.

How can I add it right next to the existing next and prev controls? Is it possible to do this via dayrender event ?? Please help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:48:05+00:00Added an answer on June 17, 2026 at 10:48 am

    No, you cannot modify the existing calendar easily. But maybe it’s sufficient to ad a table-row above the calendar where you can select the year.

    <table>
        <tr>
            <td>
                <asp:DropDownList id="drpCalMonth" Runat="Server" OnSelectedIndexChanged="Set_Calendar" AutoPostBack="true"></asp:DropDownList>
                <asp:DropDownList id="drpCalYear" Runat="Server" OnSelectedIndexChanged="Set_Calendar" AutoPostBack="true"></asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Calendar id="cntCalendar" Runat="Server" Width="100%" />
            </td>
        </tr>
    </table>
    

    Here are two methods to populate the year- and month-dropdownlists:

    protected void Populate_MonthList()
    {
        //Add each month to the list
        var dtf = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat;
        for(int i=1; i<=12; i++)
            drpCalMonth.Items.Add(new ListItem(dtf.GetMonthName(i), i.ToString()));
    
        //Make the current month selected item in the list
        drpCalMonth.Items.FindByValue(DateTime.Now.Month.ToString()).Selected = true;
    }
    
    
    protected void Populate_YearList()
    {
        //Year list can be changed by changing the lower and upper 
        //limits of the For statement    
        for (int intYear = DateTime.Now.Year - 20; intYear <= DateTime.Now.Year + 20; intYear++)
        {
            drpCalYear.Items.Add(intYear.ToString());
        }
    
        //Make the current year selected item in the list
        drpCalYear.Items.FindByValue(DateTime.Now.Year.ToString()).Selected = true;
    }
    

    You can initialize the lists from Page_Load:

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Populate_MonthList();
            Populate_YearList();
        }
    }
    

    and finally, here’s the event handler for the SelectedIndexChanged event for both DropDownLists which sets the new Date:

    protected void Set_Calendar(object Sender, EventArgs e)
    {
        int year = int.Parse(drpCalYear.SelectedValue);
        int month = int.Parse(drpCalMonth.SelectedValue);
        cntCalendar.TodaysDate = new DateTime(year, month, 1);
    }
    

    [ tested ]

    Inspired by: https://web.archive.org/web/20210304123649/https://www.4guysfromrolla.com/articles/090104-1.aspx (VB)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a TabBar Control with 3 tab, i need to add controls(Button,Label) dynamically
I am in great trouble....How can i set next and previous button/arrow at my
I need to add the button on the right hand side of the footer.
I need to add functionality to the close button in my class that extends
I've got a Primefaces command button that I need to add a callback to
I making a custom button, and I need to add a PreviewKeyDown event, whenever
I'm new in c#. I need to add a Find_Click button which has the
I need to position this update button on www.euroworker.no/order (you'll have to add an
I have: Textbox(Multi-line) Panel Different controls inside panel (buttons,textbox) Scenario: I need to add
I can't access a element with its href. Like this example, i need add

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.