This is a migrated thread and some comments may be shown as answers.

how to disable enter key on a raddatepicker ?

6 Answers 408 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Neeraj
Top achievements
Rank 1
Neeraj asked on 21 May 2009, 10:13 PM
I have a radgrid , when I add a new line , hit enter on any of the date controls (raddatepicker) , it automatically posts back to the server which is very annoying. I was able to disable this for a RadNumericTextBox. 

how can I disable this for the raddatepicker ? can you please provide an example ? 

function disableEnterKey(sender, eventArgs)

 

{

 

var key = eventArgs.get_keyCode();

 

 

if(key && key == 13)

 

eventArgs.set_cancel(

true);

 

}

 

 


 

<telerik:RadNumericTextBox

 

 

ShowSpinButtons="False"

 

 

Skin="Office2007"

 

 

Type="Currency"

 

 

width="155px"

 

 

ID="txtUnitPrice"

 

 

runat="server" DbValue='<%# Bind("UNIT_SELLING_PRICE") %>' InvalidStyleDuration="100"

 

 

MinValue='<%#Convert.ToDouble(ConfigurationManager.AppSettings["MinNumber"].ToString())%>'

 

 

MaxValue='<%#Convert.ToDouble(ConfigurationManager.AppSettings["MaxNumber"].ToString())%>'

 

 

>

 

 

<NumberFormat AllowRounding="True" KeepNotRoundedValue="False" />

 

 

<ClientEvents OnKeyPress="disableEnterKey" />

 

 

</telerik:RadNumericTextBox>

 



 

6 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 22 May 2009, 04:13 AM
Hi Neeraj,

Try attaching the disableEnterKey() function to client event of DateInput of datepicker as shown below and see whether it is working fine.

ASPX:
 
<telerik:RadDatePicker ID="RadDatePicker1" runat="server"
    <DateInput runat="server"
        <ClientEvents OnKeyPress="disableEnterKey" /> 
    </DateInput> 
</telerik:RadDatePicker> 

Thanks,
Shinu.
0
Daniel
Telerik team
answered on 22 May 2009, 06:44 AM
Hello Neeraj,

Here is another approach:
function handleClickEvent(sender, args) 
    argsargs = args || window.event; 
    if (args.keyCode == 13) 
    { 
        args.cancelBubble = true
        args.returnValue = false
        if (args.preventDefault) args.preventDefault(); 
        if (args.stopPropagation) args.stopPropagation(); 
    } 
 

<telerik:RadDatePicker ID="RadDatePicker1" runat="server" onkeydown="handleClickEvent(this,event)">   
</telerik:RadDatePicker>  

Regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Neeraj
Top achievements
Rank 1
answered on 22 May 2009, 11:21 AM
that works great. Can I bind a clientevent  to a  GridCheckBoxColumn ?
 

<

 

telerik:GridCheckBoxColumn DataField="TAXABLE_FLAG" DataType="System.Boolean" HeaderText="Taxable"

 

 

UniqueName="TAXABLE_FLAG" EditFormColumnIndex="1">

 

 

<HeaderStyle Width="50px" />

 

 

<ItemStyle HorizontalAlign="center" Width="50px" />

 

 

 

</telerik:GridCheckBoxColumn>

 

0
Sebastian
Telerik team
answered on 22 May 2009, 11:41 AM
Hello Neeraj,

You may consider attaching a client event to the disabled asp CheckBox control inside built-in GridCheckBoxColumn with the approach from this online demo:

http://demos.telerik.com/aspnet-ajax/grid/examples/programming/accessingcellsandrows/defaultcs.aspx
(hooking client instead of server event for the relevant checkbox)

Best regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Neeraj
Top achievements
Rank 1
answered on 22 May 2009, 02:17 PM
actually I need to disable the "enter key" for the entire popup form that comes up. Even if I hit the popup anywhere and then hit enterkey , the page gets submitted basically calls the add new line code and a second popup appears behind the existing popup , is there a way to disable this ?
0
Neeraj
Top achievements
Rank 1
answered on 22 May 2009, 03:22 PM
actually I got it. I put this code in the master page and attached this button to the form as the defaultbutton and it works.

 

<asp:Button ID="hidDisableEnter" runat="server" OnClientClick="return false;" BorderStyle="None" Height="0" Width="0" />

 

Tags
Grid
Asked by
Neeraj
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Daniel
Telerik team
Neeraj
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or