Darren Wood
Darren Wood

Reputation: 1528

Get the value of RadNumericTextBox in JavaScript or jQuery in ASP.NET

I have a RadNumericTextBox in a DetailsViewon a ASP.Net Web Page. I am trying to access this in JavaScript (jQuery). I have successfully got the RadNumericTextBox as a variable in javaScript and when I inspect the page this variable contains all the properties including the value of the RNTB. However I get undefined for the result of get_value(). That is according to the literature for Telerik the right way to get the value. I have also tried val, value, and Text. None of them work.

Here is the javaScript (jQuery) I am using

<script  type="text/javascript">
    function addZerosToBSB(sender) {
        var BSB = $("#ctl00_XXXXXX_XXXXXXXWizard_XXXXXX_BSB");
        alert(BSB.value);//undefined
        alert(BSB.val); 
        alert(BSB.get_value()); // this is what telerik literature says to do but it is undefined
......

Here is the DetailsView

<asp:DetailsView runat="server" ID="XXXXXXXXXX" DataSourceID="XXXXXXX" Width="100%" DefaultMode="Edit" AutoGenerateRows="False" DataKeyNames="XXXXXXXXXX">
                    <FieldHeaderStyle Width="30%"></FieldHeaderStyle>
                    <Fields>
                        <asp:TemplateField HeaderText="BSB">                                
                            <EditItemTemplate>
                                <telerik:RadNumericTextBox runat="server" ID="BSB"  NumberFormat-GroupSeparator="" NumberFormat-DecimalDigits="0"  Text='<%# (Eval("BSB") %>' ></telerik:RadNumericTextBox>
                            </EditItemTemplate>
                        </asp:TemplateField>
.........

I have tried BSB.text in the javaScript and this is what it returns

ƒ (a){return S(this,function(a){return void 0===a? 
r.text(this):this.empty().each(function() 
{1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType|| 
(this.textContent=a)})},null,a,arguments.length)}

My question is how can I get the value of the RadNumericTextBox in javaScript and then how can I set it?

Upvotes: 0

Views: 1089

Answers (1)

Kosh
Kosh

Reputation: 18393

In jQuery you have to use BSB.val()

Upvotes: 1

Related Questions