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

How to disable Backspace key and Delete key in dropdowncalendar control

I have a question: how to disable Backspace key and Delete key when textbox is selected in dropdowncalendar control?

4 Replies

RS Rajarajeswari S Syncfusion Team November 5, 2007 04:41 AM UTC


Hi,

Sorry for the delay in response.

To make the Backspace and Delete keys disable we have to catch the keyboard events. Javascript allows the following events related with keyboard:

onKeyUp
onKeyDown.

But both of these events can only be applied to Text and TextArea and not for Select controls, etc. So your requirement is not possible.

Please let me know if you have any other queries.

Regards,
S.Rajarajeswari



SS Suresh Sekarean Syncfusion Team November 9, 2007 03:02 PM UTC

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.htm

Please try this and let us know if this helps.

Regards,
Sureshsekaran.




PZ Peter Zheng November 15, 2007 03:58 PM UTC

Hi, Sureshsekaran

Thanks. I have another question. I just upgraded Essential Studio to version 5.202.0.25. The dropdowncalendar's CultureSource dose not work any more. My setting is "From Server". Is there a workaround?



RS Rajarajeswari S Syncfusion Team November 19, 2007 01:44 PM UTC



Hi Peter,

CultureSource property specifies the current culture for the control. The values includes,

• FromClient - culture is obtained from the data posted by browser.
• FromServer - culture is obtained from web-server hosting page.
• UserOverride - user defined culture.

Please have a look at the sample browser sample from the below link where the culture source property is used to set different culture.

C:\Documents and Settings\User Name\My Documents\Syncfusion\EssentialStudio\5.2.0.25\Web\tools.web\Samples\2.0\EditorsPackage\EditorsPackage\DataEditorsCultureInformation\cs

And also you can get more information on the culture source property from the following link.

http://www2.syncfusion.com/ug_latest/toolsweb/default.html

Please check with these and if still the problem exists, could you please try
reproducing it in the above sample or send us the reproducing steps so that we could sort
out the cause of the issue and provide you a solution?

Regards,
Raji



Loader.
Live Chat Icon For mobile
Up arrow icon