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
Mayur GujrathiPosted Aug 23, 2011, 3:59 AM
nishant ranjanPosted Aug 23, 2011, 3:35 AM
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.
nishant ranjanPosted Aug 23, 2011, 3:23 AM
Satyapriya NayakPosted Aug 20, 2011, 10:22 AM
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
Satish BhatPosted Aug 20, 2011, 8:26 AM
nishant ranjanPosted Aug 20, 2011, 8:10 AM
Amruta KirdatPosted Aug 20, 2011, 7:53 AM
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