8 Answers, 1 is accepted
Could you please verify whether you are setting the RadNumericTextBox value using its Client-side object's set_value() property?
I hope this helps.
Greetings,
Martin
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
function CalculateAin(sender, eventArgs) {
var Numericbox = $find("<%=SubtotalPremSubjAssessment_box.ClientID %>");
var i = sender.get_value();
Numericbox .set_value(Numericbox .get_value() - i);
CalculateC(i, false);
}
//Sample Rad Input Element
<telerik:RadNumericTextBox runat="server" ReadOnly="true" ID="SubtotalPremSubjAssessment_box" SkinID="CurrencyOnlyBox"
Width="135px" Value="0" DataType="System.Decimal" >
<clientevents onvaluechanged="CalculateE" />
</telerik:RadNumericTextBox>
//Sample C# Code-behind (NOTE: this is where the problem is, the value assigned from the JavaScript is ignored )
command.Parameters.AddWithValue("@SubtotalPremSubjAssessment", SubtotalPremSubjAssessment_box.Value); //This always returns the default value specified above in sample HTML; It returns null when the default value has been omitted.
SubtotalPremSubjAssessment_box returns it's default value of 0 when called from code behind no matter what is displayed in the NumericBox. The input box always displays correctly and as expected. I am completely lost on this issue, i can't find any relevant info anywhere else, please help if you can.
Also when i remove the readonly attribute or set it to true and manually enter a value into that numeric input, codebehind gets correct value.
Could you please check the CalculateAin function one more time. Note the highlighted rows bellow where "sender" and "Numericbox" are the same object and subtracting the value from itself would always result in 0:
function
CalculateAin(sender, eventArgs) {
var
Numericbox = $find(
"<%=SubtotalPremSubjAssessment_box.ClientID %>"
);
var
i = sender.get_value();
Numericbox .set_value(Numericbox .get_value() - i);
CalculateC(i,
false
);
}
Meanwhile you can try the code bellow that demonstrates that RadNumericTextBox functions as expected:
<%@ Page Language="C#" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
id
=
"Head1"
runat
=
"server"
>
</
head
>
<
body
>
<
form
id
=
"mainForm"
runat
=
"server"
>
<
asp:ScriptManager
runat
=
"server"
ID
=
"ScriptManager1"
>
</
asp:ScriptManager
>
<
script
type
=
"text/javascript"
>
function CalculateE(sender, args)
{
}
function MyClick()
{
var numericTextBox = $find("SubtotalPremSubjAssessment_box");
numericTextBox.set_value(parseFloat(numericTextBox.get_value()) - 1);
}
</
script
>
<
script
type
=
"text/C#"
runat
=
"server"
>
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write(SubtotalPremSubjAssessment_box.Value);
}
</
script
>
<
telerik:RadNumericTextBox
runat
=
"server"
ReadOnly
=
"true"
ID
=
"SubtotalPremSubjAssessment_box"
Width
=
"135px"
Value
=
"0"
DataType
=
"System.Decimal"
>
<
ClientEvents
OnValueChanged
=
"CalculateE"
/>
</
telerik:RadNumericTextBox
>
<
input
type
=
"button"
id
=
"Button2"
value
=
"Set value"
onclick
=
"MyClick()"
/>
<
asp:Button
Text
=
"Get value"
ID
=
"Button1"
OnClick
=
"Button1_Click"
runat
=
"server"
/>
</
form
>
</
body
>
</
html
>
I hope this helps.
Greetings,
Martin
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
I finally found the solution. The client side script was not executing when the server side need it to. Added a RadAjaxManager to the page and problem was solved.
EDIT: Okay, so after a little more testing, the AjaxManager only fixed the first occurrence of this issue. I have several boxes that take javascript entered values.
i have the same problem, seaching for solution i found this old topic thats is Exactly problem...
Making some test if the radcontrol seted as readonly i cant get the value(seted by set_value on JS) on codebehind, i removed the readonly and put enabled false and thats work. but i need use readonly becuse my user didnt like disabled aspect.
anyone know this inssue?
tkx!
I have tried to replicate the issue utilizing the code bellow, but the value is successfully retrieved from the server. Please review it and let me know whether I miss something.
<%@ Page Language="C#" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html>
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
asp:ScriptManager
runat
=
"server"
ID
=
"Sm1"
>
</
asp:ScriptManager
>
<
script
runat
=
"server"
>
protected void Button1_Click(object sender, EventArgs e)
{
L1.Text = "Text: " + RadNumericTextBox1.Text;
L2.Text = "Value: " + RadNumericTextBox1.Value.ToString();
}
</
script
>
<
script
type
=
"text/javascript"
>
function ClientClick()
{
var numTextBox = $find("<%= RadNumericTextBox1.ClientID %>");
var num = Math.random();
numTextBox.set_value(num * 100);
}
</
script
>
<
asp:Button
Text
=
"SetValue"
OnClientClick
=
"ClientClick();return false;"
runat
=
"server"
/>
<
asp:Button
Text
=
"PostBack"
ID
=
"Button1"
OnClick
=
"Button1_Click"
runat
=
"server"
/>
<
telerik:RadNumericTextBox
runat
=
"server"
ID
=
"RadNumericTextBox1"
ReadOnly
=
"true"
></
telerik:RadNumericTextBox
>
<
asp:Label
Text
=
""
ID
=
"L1"
runat
=
"server"
/>
<
asp:Label
Text
=
""
ID
=
"L2"
runat
=
"server"
/>
</
form
>
</
body
>
</
html
>
I hope this helps.
Regards,
Martin
Telerik
I am using a Numeric-Input with it's type set to "currency" while inside a RadGrid in edit mode.
Normal usage is working fine but my functionality requires a keyboard HotKey/AccessKey for the submit button.
Scenario:
Users input data into the grid primarily using only the keyboard.
This particular input is the LAST column in the grid so they type in a dollar amount and
then submit the form using the hotkey associated to the Submit button ("Access Key").
<asp:button id="btnAdd" accessKey="A" runat="server" ToolTip="Press Alt+A to Add Row" Text="Add Row" onclick="btnAdd_Click"></asp:button>
the grid does not recognize a value inside the (edit-mode) numeric-Input field unless they TAB OFF the control. I have been able to trap this event (btnAdd_Click) while firing on the client, actually trapping OnBlur fired from within the Numeric-Input which occurs prior to the btnAddRow event, but the Grid still shows as $0 for this control on the server postback.
This issue was fixed in the later versions. Try out our public beta for the next release. Check the changes here:
http://www.telerik.com/products/aspnet-ajax/whats-new/release-history/q3-2013-beta-version-2013-3-926.aspx
Regards,
Vasil
Telerik