Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calendar Control Help

Status
Not open for further replies.

blar9

Programmer
Mar 12, 2007
39
US
I have a calendar control on my page and when the user clicks on a date I want to capture that date to use to populate grids ect on the page simple no?.... Problem is the Date that was clicked on is not the value until the page finishes loading.... Here is the code of a very simple example that does what I am talking about.

Code behind:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Junk : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
lblLoad.Text = Cal.SelectedDate.ToString();

}
protected void Page_LoadComplete(object sender, EventArgs e)
{
lblAfterLoad.Text = Cal.SelectedDate.ToString();

}
}

Asp Code:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Junk.aspx.cs" Inherits="Junk" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:Calendar ID="Cal" runat="server"></asp:Calendar><br /><br />
<asp:Label runat="server" ID="lblLoad"></asp:Label><br />
<asp:Label runat="server" ID="lblAfterLoad"></asp:Label>
</div>
</form>
</body>
</html>

Thanks for any help
 
Not sure what your question is or what you want to do. The way you have your code structred now will behave as you have explained, the page must postback andload completely to get the value you want.
Why not try using the calendar's SelectionChanged event to capture the date choosen?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top