hi
I have problem with the textbox reading from a calendar
I to make the default value for the textbox is the system date which is working now in my code and when the user click the button to change it it should save the selected date in the textbox value and hide the calendar but it's not taking it .
this is my code :
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DateTime today = DateTime.Today;
Calendar1.TodaysDate = today;
Calendar1.SelectedDate = Calendar1.TodaysDate;
TextBox1.Text = Calendar1.SelectedDate.Date.ToString();
Calendar1.Visible = false;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
if (Calendar1.Visible == true)
{
TextBox1.Text = Calendar1.SelectedDate.Date.ToString();
Calendar1.Visible = false;
}
else
{
Calendar1.Visible = true;
}
}
}
}
Loading

Satyapriya NayakRank #47 · 31.5K reputationPosted May 9, 2013, 12:50 AM EDT
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace WebApplication1
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DateTime today = DateTime.Today;
Calendar1.TodaysDate = today;
Calendar1.SelectedDate = Calendar1.TodaysDate;
TextBox1.Text = Calendar1.SelectedDate.Date.ToString();
Calendar1.Visible = false;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Calendar1.Visible = true;
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
if (Calendar1.Visible == true)
{
TextBox1.Text = Calendar1.SelectedDate.Date.ToString();
Calendar1.Visible = false;
}
else
{
Calendar1.Visible = true;
}
}
}
}
ToBe152 reputationPosted May 9, 2013, 2:03 AM EDT