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

Passing additional params in OnValueChanging event

1 Answer 78 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Annie asked on 28 Jul 2010, 04:11 PM


I would like to try using the CompositeScript functionality provided by the RadScriptManager. However, I'm having difficulty trying to pass in the parameters that I would need in the javascript in order to do to.   For example, for the RadNumericTextBox OnValueChaging event, we defined the javascript function to call:

txtAmount.ClientEvents.OnValueChanging = "price_changing";

In the RadScriptBlock, I have the following function:

function price_changing(sender, args) {
var strOldValue = args.get_oldValue().toString().replace("$",""); // 0.00
var strNewValue = args.get_newValue().toString().replace("$", ""); // 0.00
var totalfee = parseFloat(document.getElementById("<%= lblTotalFee.ClientID %>").innerText.replace("$", ""));
if (run_update && (strOldValue != strNewValue)) {
var grid = $find('<%= grdFee.ClientID %>');

In order to move the script block into a seperate .JS file, I need to replace "<%= lblTotalFee.ClientID %>" with a variable I can pass into the javascript function. (Or the "<%= grdFee.ClientID %>").


There seems to be no way of doing that, I cannot specify parameters in the ClientEvents.OnValueChanging event.

One way might solve it is to upgrade to .NET 4 (We use .NET 3.5 now), then use the ClientIDMode property, so we can always expect a static ID.  But I'm looking for another option. 

Any ideas?




1 Answer, 1 is accepted

Sort by
Telerik team
answered on 03 Aug 2010, 07:05 AM
Hi Annie,

You can register a client side variable declaration from the server. The variable will contain the client ID of your label or grid:

Copy Code
string script = String.Format("var  lblTotalFee = '{0}';", lblTotalFee.ClientID);
RadScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "lblTotalFeeId", script, true);

Now your javascript knows that the client ID of the TotalFee label is kept in a global variable named lblTotalFeeId. A simple $get(lblTotalFeeId) should get you the label.

Best wishes,
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question