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

RadNumericTextbox OnValueChanged update label text

5 Answers 295 Views
Input
This is a migrated thread and some comments may be shown as answers.
Aniket Braganza
Top achievements
Rank 2
Aniket Braganza asked on 21 Nov 2008, 04:30 AM
How do I update the text of a label/control on my page when the user changes the value, using the OnValueChanged ClientEvent.

I have a Master/Content page scenario, with a RadAjaxManager in the master page and a RadAjaxManagerProxy in the content page. I also have my function in a RadCodeBlock and am using

$find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("args"); 

to get the args. I can't get the numerictextbox to update the label's text when I change the value.

Here is my code block but neither line to set the text worked.

    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"
 
        <script language="javascript" type="text/javascript"
                function OnClientValueChanged (sender, args) 
                { 
                    $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("args"); 
                    <%= lblValueEntered.ClientID %>.Text=  "Value Entered:" + args.get_newValue(); 
                    // document.getElementById("lblValueEntered").Text =  "Value Entered:" + args.get_newValue(); 
                } 
        </script> 
    </telerik:RadCodeBlock> 


My textbox looks like this
           <div style="text-align: center; margin: 5px 0px 0px 5px;"
                <asp:Label ID="lblScheduled" runat="server" Text="Lessons Scheduled" AssociatedControlID="txtScheduled"></asp:Label> 
                <telerik:RadNumericTextBox ID="txtScheduled" runat="server" ShowSpinButtons="True" 
                    Culture="English (United States)" Width="125px"
                    <ClientEvents OnValueChanged="OnClientValueChanged" /> 
                </telerik:RadNumericTextBox> 
            </div> 

I also tried adding those 2 controls, the textbox an the label to the updatedcontrols but that didn't help.

What am I missing here? Please help!

Aniket



5 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 21 Nov 2008, 08:02 AM
Hello Aniket,

Test the following modification and let us know whether this helps.
$get("lblValueEntered").innerHTML = "Value Entered:" + args.get_newValue();  

Best regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Aniket Braganza
Top achievements
Rank 2
answered on 23 Nov 2008, 01:09 AM
I get the following Javascript Error when I use your code
     'null' is null or not an object
0
Missing User
answered on 26 Nov 2008, 08:32 AM
Hello Aniket,


Please find attached a sample web application that demonstrates the needed approach.

Best wishes,
Plamen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Bryan Brannon
Top achievements
Rank 2
answered on 10 Dec 2008, 09:14 PM
I am using this same functionality (it works) but I have a problem when the RadNumericTextBox1 has the following properties:

Me.RadNumericTextbox1.MinValue = 1
Me.RadNumericTextbox1.MaxValue = 5
Me.RadNumericTextbox1.Value = 2

So, using the javascript to get_newValue() into a label (works) except that when I use the spinner buttons to try to toggle the Value below my MinValue.  The control thows the instant UI error warning me that this value and stops the action but my label still gets the value that is below my MinValue.

Any fix for this?
0
Daniel
Telerik team
answered on 15 Dec 2008, 03:51 PM
Hello Bryan,

Possible workaround would be the following:
<script type="text/javascript"
    var error; 
    function ClientValueChanged(sender, args) 
    { 
        if (!error) $get("<%= lblScheduled.ClientID %>").innerHTML = args.get_newValue(); 
        error = false
    } 
    function Error(sender, args) 
    { 
        error = true
    } 
</script> 

<ClientEvents OnValueChanged="ClientValueChanged" OnError="Error" /> 

Let us know if you need more information.

Best regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Input
Asked by
Aniket Braganza
Top achievements
Rank 2
Answers by
Daniel
Telerik team
Aniket Braganza
Top achievements
Rank 2
Missing User
Bryan Brannon
Top achievements
Rank 2
Share this question
or