We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to disable the text entry in DropDownCalendar control?

Platform: ASP.NET Web Forms (Classic) |
Control: DropDownCalendarControl |
Product Version:


You can disable the entry of text 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


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




public class CustomDropDownControl : DropDownCalendarControl


protected override void RenderChildren(HtmlTextWriter writer)


//Insert the Validation script here.

this.m_textBox.Attributes["onkeydown"] = "if(!(event.keyCode<=57 && event.keyCode

=48)){if(!(event.keyCode <= 90 && event.keyCode >=65)){if(!(event.keyCode<=122 &&

event.keyCode >=97)){" + this.m_textBox.Attributes["onkeydown"] + "}else return

false;}else return false;}else return false;";





Public partial Class _Default : Inherits System.Web.UI.Page

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

  Dim DropDownCalendarControl1 As CustomDropDownControl = New



 End Sub

End Class

Public Class CustomDropDownControl : Inherits DropDownCalendarControl

 Protected Overrides Sub RenderChildren(ByVal writer As HtmlTextWriter)

  Me.m_textBox.Attributes("onkeydown") = "if(!(event.keyCode<=57 &&

event.keyCode >=48)){if(!(event.keyCode <= 90 && event.keyCode

>=65)){if(!(event.keyCode<=122 && event.keyCode >=97)){" &

Me.m_textBox.Attributes("onkeydown") & "}else return false;}else return false;}else return



 End Sub

End Class

You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile