Re: Calendar Control custom navigation problems

Discussion in 'ASP .Net' started by Ben Fidge, Jul 18, 2003.

  1. Ben Fidge

    Ben Fidge Guest

    Gian

    Try using the TodaysDate property of the calendar instead of VisibleDate in
    the SelectedIndexChanged event handler

    Ben

    "Giancarlo Persico" <> wrote in message
    news:...
    > I have a simple calendar control with a dropdownlist underneath which

    allows
    > the user to select the year they wish the calendar to display. The
    > dropdownlist has AutoPostBack set to true and works fine EXCEPT for after
    > you navigate the calendar using next/previous - the dropdownlist then no
    > longer updates the calendar?
    >
    > In the pageload event I have tried reassigning the dropdownlist
    > onselectionchange event handler to no avail.
    >
    > Any help/suggestions would be greatly appreciated. Please take a look at

    my
    > code below.
    >
    >
    > Thanks
    >
    > Gian
    >
    > public class CalendarSelector : System.Web.UI.Page
    >
    > {
    >
    > protected System.Web.UI.WebControls.Calendar calSelector;
    >
    > protected System.Web.UI.WebControls.DropDownList ddlYears;
    >
    > protected System.Web.UI.WebControls.Literal Literal1;
    >
    > protected DateTime dDateToday = DateTime.Now;
    >
    > protected int iYear = DateTime.Now.Year;
    >
    >
    > private void Page_Load(object sender, System.EventArgs e)
    >
    > {
    >
    > if(!IsPostBack) {
    >
    > for(int i = 1900; i <= DateTime.Now.Year; i++) {
    >
    > ddlYears.Items.Add(new ListItem(i.ToString()));
    >
    > }
    >
    > Utils.SetDropDownListUKey(ddlYears, Convert.ToInt32(DateTime.Now.Year));
    >
    > }
    >
    > }
    >
    >
    > private void calSelector_SelectionChanged(object sender, System.EventArgs

    e)
    > {
    >
    > string strjscript = "<script language='javascript'>";
    >
    > strjscript += "window.opener." +
    > HttpContext.Current.Request.QueryString["formname"];
    >
    > strjscript += ".value = '" + calSelector.SelectedDate.ToString("d") +
    > "';window.close();";
    >
    > strjscript += "</script" + ">"; //Don't ask, tool bug.
    >
    > Literal1.Text = strjscript;
    >
    > }
    >
    >
    > #region Web Form Designer generated code
    >
    > override protected void OnInit(EventArgs e)
    >
    > {
    >
    > //
    >
    > // CODEGEN: This call is required by the ASP.NET Web Form Designer.
    >
    > //
    >
    > InitializeComponent();
    >
    > base.OnInit(e);
    >
    > }
    >
    >
    > /// <summary>
    >
    > /// Required method for Designer support - do not modify
    >
    > /// the contents of this method with the code editor.
    >
    > /// </summary>
    >
    > private void InitializeComponent()
    >
    > {
    >
    > this.calSelector.SelectionChanged += new
    > System.EventHandler(this.calSelector_SelectionChanged);
    >
    > this.ddlYears.SelectedIndexChanged += new
    > System.EventHandler(this.ddlYears_SelectedIndexChanged);
    >
    > this.Load += new System.EventHandler(this.Page_Load);
    >
    > }
    >
    > #endregion
    >
    > private void ddlYears_SelectedIndexChanged(object sender, System.EventArgs
    > e) {
    >
    > int iYearDiff = iYear - Convert.ToInt32(ddlYears.SelectedItem.Value);
    >
    > calSelector.TodaysDate = dDateToday.AddYears(-iYearDiff);
    >
    > }
    >
    > }
    >
    >
    >
    >
    >
     
    Ben Fidge, Jul 18, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. msnews.microsoft.com
    Replies:
    2
    Views:
    484
    Steven Cheng[MSFT]
    Apr 22, 2004
  2. Laurahn
    Replies:
    3
    Views:
    914
    Steven Cheng[MSFT]
    Feb 6, 2007
  3. Matt Sokol
    Replies:
    2
    Views:
    395
    Theo Tillotson
    Aug 7, 2003
  4. Giancarlo Persico

    Calendar Control custom navigation problems

    Giancarlo Persico, Jul 18, 2003, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    132
    Ben Fidge
    Jul 18, 2003
  5. msnews.microsoft.com

    Calendar Control: Changing the Month Display and Navigation Links

    msnews.microsoft.com, Apr 19, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    184
    Steven Cheng[MSFT]
    Apr 20, 2004
Loading...

Share This Page