i have a text box
a calender control
when i select date in calender control then it is displayed in textbox
but i dont want that anyone can type date in textbox.... i.e., only through calender control data should be entered.
enabled="false" or readonly doesnot work for me...
any suggestion
Loading

Amruta Kirdat72 reputationPosted Aug 20, 2011, 3:53 AM EDT
At KeyDown even of textbox write follwoing code
e.SuppressKeyPress = true; //this will solve ur prob
but i'm surprised why enabled = false and readonly is not working for you?
Regards,
Amruta
nishant ranjanRank #4,961 · 317 reputationPosted Aug 20, 2011, 4:10 AM EDT
Satish BhatRank #2,496 · 563 reputationPosted Aug 20, 2011, 4:26 AM EDT
Satyapriya NayakRank #47 · 31.5K reputationPosted Aug 20, 2011, 6:22 AM EDT
Try this
using System;
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;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
TextBox1.ReadOnly = true;
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
TextBox1.Text = Calendar1.SelectedDate.ToShortDateString();
}
}
Thanks
If this post helps you mark it as answer
nishant ranjanRank #4,961 · 317 reputationPosted Aug 22, 2011, 11:23 PM EDT
nishant ranjanRank #4,961 · 317 reputationPosted Aug 22, 2011, 11:35 PM EDT
protected void Page_Load(object sender, EventArgs e)
{
// txt_date.Enabled = false;
//txt_date.ReadOnly = true;
}
protected void txt_date_textchanged(object sender, EventArgs e)
{
lbl1.Text = txt_date.Text;
}
if i select readonly then will not be able to change date from calender.
and if select enabled then will not be able to display textbox text in label.
Mayur GujrathiRank #666 · 3.6K reputationPosted Aug 22, 2011, 11:59 PM EDT