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

Failing to pull the current value from RadNumericTextBox

6 Answers 146 Views
Input
This is a migrated thread and some comments may be shown as answers.
Jesse Lawler
Top achievements
Rank 1
Jesse Lawler asked on 19 May 2010, 07:21 AM
Okay, so this seems really strange to me.  I've got a RadNumericTextBox.  I have a client-side Javascript function that gets its value using this line...

            var orderTotal = $find('<%= OrderTotal.ClientID %>').get_value();

...for use in some client-side stuff.  This works fine.

However, occasionally the value of this RadNumericTextBox is changed through a CallBack, with the change being made from the Code-Behind.  The value of the RadNumericTextBox changes in the browser, and everything seems to work fine there too.

BUT if I then call the Javascript function again, to get the value, it gives me the old value, as if the CallBack had never been made and the value of the RadNumericTextBox had never been changed.  What is going on?

I need to always be pulling the proper, current value of the RadNumericTextBox with my Javascript function.

Thanks!


6 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 21 May 2010, 11:30 AM
Hello Jesse,

Please confirm that the javascript is correctly called after the Ajax request. Please review the following help topic for more information on this matter.

Kind regards,
Maria Ilieva
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.
0
Jesse Lawler
Top achievements
Rank 1
answered on 30 May 2010, 05:39 AM
The Javascript is definitely being called.  Essentially all my Javascript is doing is multiplying the value of Field A by the value of Field B and putting the result into Field C.  Field A is being updated from the code-behind via a Callback, which works fine.  But then when I call the Javascript, the value that it pulls from Field A is the outdated, pre-Callback value, as if the Callback never took place.

Why would the Javascript line...

$find('<%= OrderTotal.ClientID %>').get_value();

...be returning the pre-Callback value, when the Callback has clearly been successful, with the new value visible in the control?

(PS: Sorry for the slow reply; I suffered a catastrophic system crash shortly after posting the original request.  Computer is all better now.)
0
Maria Ilieva
Telerik team
answered on 02 Jun 2010, 12:20 PM
Hello Jesse,

Could you please post some more code shows the Ajax settings so we could further research on the problem.


Kind regards,
Maria Ilieva
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.
0
Maria Ilieva
Telerik team
answered on 02 Jun 2010, 12:20 PM
Hello Jesse,

Could you please post some more code shows the Ajax settings so we could further research on the problem?


Kind regards,
Maria Ilieva
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.
0
Jesse Lawler
Top achievements
Rank 1
answered on 03 Jun 2010, 12:13 AM
Here is the code-behind that sets the value of the RadNumericTextBox in question.  This works fine.  When this Callback runs, the RadNumericTextBox (named OrderTotal) updates exactly as it should...

    private void OrderTotalCallback_Callback(object sender, ComponentArt.Web.UI.CallBackEventArgs e) 
    { 
        ResetOrderTotal(); 
        OrderTotal.RenderControl(e.Output); 
    } 
 
    private void ResetOrderTotal() 
    { 
        double total = 0; 
        foreach (ComponentArt.Web.UI.GridItem item in OrderProductsGrid.Items) 
        { 
            if (item["ordprdCostOverride"] == DBNull.Value) 
            { 
                total += Convert.ToDouble(item["ordprdTotal"]); 
            } 
            else 
            { 
                total += Convert.ToDouble(item["ordprdCostOverride"]); 
            } 
        } 
        OrderTotal.Value = total; 
     } 

But then this Javascript function, fails (or rather, fails to generate the correct answer - it executes fine) because the variable it sets in the first line (it's local orderTotal variable) picks up the previous value for the RadNumericTextBox, from before the Callback was ever executed.  It's as if Javascript doesn't have access to the post-Callback values of the page's variables, and is operating off a cached bunch of data somewhere.  Help!

Thanks,

Jesse

       function calculateWeightedTotal() { 
            var orderTotal = $find('<%= OrderTotal.ClientID %>').get_value(); 
            if (orderTotal == '') orderTotal = 0; 
            var probability = $find('<%= Probability.ClientID %>').get_value(); 
            $find('<%= WeightedTotal.ClientID %>').set_value(orderTotal * probability / 100); 
        } 

0
Maria Ilieva
Telerik team
answered on 08 Jun 2010, 08:00 AM
Hello Jesse,

I'm not able to see the Ajax settings in the code you have provided. Could you please let me know how the ajax is set on the Page. Are you using RadAjaxManager or RadaAjaxPanel controls? In order to execute the javascript correctly after ajax request you should use the ResponseScripts property of the RadAjaxPanel or RadAjaxManager

Kind regards,
Maria Ilieva
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.
Tags
Input
Asked by
Jesse Lawler
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Jesse Lawler
Top achievements
Rank 1
Share this question
or