Tuesday, January 25, 2011

SetValue not working for RadNumericTextbox


Setting a RadNumericTextBox's value using a Javascript function was not an issue in previous versions of Telerik. However, once I updated my Telerik Version to v. 2010.3.1109.40. This SetValue property was not working anymore.

1) RadNumericTextBox definition in HTML

1 <telerik:RadNumericTextBox ID="txtTaxCode" runat="server" CssClass="textbox_num_enabled2" Width="40px" MaxLength="4" MinValue="0" MaxValue="9999" EnableEmbeddedSkins="false">
2 <ClientEvents OnLoad="Loadradvalue"/> 3 <NumberFormat DecimalDigits="0" GroupSeparator=""/>
4 </telerik:RadNumericTextBox>

Very Important:
Be sure to call a Javascript function in one event declared in the ClientEvents tag of the control. In the example: onload event.

2) Javascript code for the function ClientEvents' event:

1 function Loadradvalue(sender, args) {
2 radvalue = sender;
3 }

3)Javascript code to set the value:
1 function CallBackFunction(radWindow) {
2 radvalue.set_value(5);
3 }

Now, it works well in my project. More information of properties and methods for Radnumerictextbox and other Telerik controls available here: http://www.telerik.com/help/aspnet-ajax/input_clientsideradnumerictextbox.html

No comments:

Post a Comment