Hi,
I am using RadNumericTextBox inside the <edititemtemplate> tag of a RadGrid. I have set autopostback property of RadNumericTextBox to false. Still when I press Enter key postback happens. Given below is my code:
<telerik:RadGrid ID="grdTrans" GridLines="None" AutoGenerateColumns="false" Height="500px"
AutoGenerateEditColumn="false" AutoGenerateDeleteColumn="false"
runat="server" OnCancelCommand="grdTrans_CancelCommand"
AllowPaging="false" AllowSorting="false"
OnDeleteCommand="grdTrans_DeleteCommand" OnUpdateCommand="grdTrans_UpdateCommand"
onneeddatasource="grdTrans_NeedDataSource"
oninsertcommand="grdTrans_InsertCommand"
onitemdatabound="grdTrans_ItemDataBound"
oneditcommand="grdTrans_EditCommand" >
<MasterTableView Name="master" EditMode="InPlace" GridLines="None" DataKeyNames="accid" CommandItemDisplay="Bottom" >
<Columns>
<telerik:GridEditCommandColumn>
</telerik:GridEditCommandColumn>
<telerik:GridTemplateColumn HeaderText="Debit" UniqueName="debit" DataType="System.Decimal" ItemStyle-Width="100px" ItemStyle-HorizontalAlign="Right" >
<ItemTemplate>
<asp:Label ID="lblDbAmt" Text= '<%# Eval("dbamt") %>' CssClass="labels" runat="server"> </asp:Label>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadNumericTextBox ID="txtDbAmt" Text = '<%# bind("dbamt") %>' MinValue="0" MaxValue="99999999.99" MaxLength="11" DataType="System.Decimal" Culture="en-GB" AutoPostBack="false" ClientEvents-OnKeyPress="KeyPressed" EnabledStyle-HorizontalAlign="Right" runat="server">
<NumberFormat AllowRounding="false" DecimalDigits="2" DecimalSeparator="." GroupSeparator="," GroupSizes="3" />
</telerik:RadNumericTextBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
I had to use the following javascript function to avoid postback:
function KeyPressed(ctrl, e) {
if (e.get_domEvent().rawEvent.keyCode == 13) { //enter
//special handling (focus other control and so on) here
e.get_domEvent().preventDefault();
e.get_domEvent().stopPropagation();
}
Is there any workaround other than using the above javascript.
Alphonse
I am using RadNumericTextBox inside the <edititemtemplate> tag of a RadGrid. I have set autopostback property of RadNumericTextBox to false. Still when I press Enter key postback happens. Given below is my code:
<telerik:RadGrid ID="grdTrans" GridLines="None" AutoGenerateColumns="false" Height="500px"
AutoGenerateEditColumn="false" AutoGenerateDeleteColumn="false"
runat="server" OnCancelCommand="grdTrans_CancelCommand"
AllowPaging="false" AllowSorting="false"
OnDeleteCommand="grdTrans_DeleteCommand" OnUpdateCommand="grdTrans_UpdateCommand"
onneeddatasource="grdTrans_NeedDataSource"
oninsertcommand="grdTrans_InsertCommand"
onitemdatabound="grdTrans_ItemDataBound"
oneditcommand="grdTrans_EditCommand" >
<MasterTableView Name="master" EditMode="InPlace" GridLines="None" DataKeyNames="accid" CommandItemDisplay="Bottom" >
<Columns>
<telerik:GridEditCommandColumn>
</telerik:GridEditCommandColumn>
<telerik:GridTemplateColumn HeaderText="Debit" UniqueName="debit" DataType="System.Decimal" ItemStyle-Width="100px" ItemStyle-HorizontalAlign="Right" >
<ItemTemplate>
<asp:Label ID="lblDbAmt" Text= '<%# Eval("dbamt") %>' CssClass="labels" runat="server"> </asp:Label>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadNumericTextBox ID="txtDbAmt" Text = '<%# bind("dbamt") %>' MinValue="0" MaxValue="99999999.99" MaxLength="11" DataType="System.Decimal" Culture="en-GB" AutoPostBack="false" ClientEvents-OnKeyPress="KeyPressed" EnabledStyle-HorizontalAlign="Right" runat="server">
<NumberFormat AllowRounding="false" DecimalDigits="2" DecimalSeparator="." GroupSeparator="," GroupSizes="3" />
</telerik:RadNumericTextBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
I had to use the following javascript function to avoid postback:
function KeyPressed(ctrl, e) {
if (e.get_domEvent().rawEvent.keyCode == 13) { //enter
//special handling (focus other control and so on) here
e.get_domEvent().preventDefault();
e.get_domEvent().stopPropagation();
}
Is there any workaround other than using the above javascript.
Alphonse