Hi Peter,
The above requirement can be met by rewriting the existing onkeydown event of DropDownCalendar control Textbox element. And the keys pressed can be validated in this event. Please refer the below code snippet .
[C#]
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//DropDownCalendar control attributes collections should be set before 'RenderChildren' method.
CustomDropDownControl DropDownCalendarControl1 = new CustomDropDownControl();
//Add dropdown control in the PlaceHolder control list
PlaceHolder1.Controls.Add(DropDownCalendarControl1);
}
}
public class CustomDropDownControl : DropDownCalendarControl
{
protected override void RenderChildren(HtmlTextWriter writer)
{
//Insert the Validation script here.
this.m_textBox.Attributes["onkeydown"] = "if(event.keyCode!=8){if(event.keyCode!=46){" + this.m_textBox.Attributes["onkeydown"] + "}else return false;}else return false;";
base.RenderChildren(writer);
}
}
Please refer the below sample which illustrates the above.
http://websamples.syncfusion.com/samples/Tools.Web/5.2.0.25/F69441/main.htmPlease try this and let us know if this helps.
Regards,
Sureshsekaran.