I have two fields Renwal date and Date of cheque. for that i use two text boxes.Then i want to use one calendar to fill the renwal date and date of cheque in respective text boxes.
how to do in csharp. please help me.
Thanks!
Renwal date textbox1 Calendar
Date of cheque textbox2 Calendar
for that i want to use one calendar only.
Using Calendar
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Satyapriya NayakRank #47 · 31.5K reputationPosted Jun 10, 2012, 10:45 AM EDT
Try this...
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm6.aspx.cs" Inherits="WebApplication16.WebForm6" %>
using System;
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 WebApplication16
{
public partial class WebForm6 : System.Web.UI.Page
{
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
if (String.IsNullOrEmpty(TextBox1.Text))
{
if (String.IsNullOrEmpty(TextBox2.Text))
{
TextBox1.Text = Calendar1.SelectedDate.Date.ToString();
}
else if (!String.IsNullOrEmpty(TextBox2.Text) && (TextBox2.Text != Calendar1.SelectedDate.Date.ToString()))
{
TextBox1.Text = Calendar1.SelectedDate.Date.ToString();
}
}
else if (String.IsNullOrEmpty(TextBox2.Text))
{
if (String.IsNullOrEmpty(TextBox1.Text))
{
TextBox2.Text = Calendar1.SelectedDate.Date.ToString();
}
else if (!String.IsNullOrEmpty(TextBox1.Text) && (TextBox1.Text != Calendar1.SelectedDate.Date.ToString()))
{
TextBox2.Text = Calendar1.SelectedDate.Date.ToString();
}
}
}
}
}
Thanks