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

RadNumeric TextBox

3 Answers 86 Views
Input
This is a migrated thread and some comments may be shown as answers.
alex
Top achievements
Rank 1
alex asked on 20 Apr 2009, 09:50 AM
Hello , i have one RadNumerictextbox in my aspx page , i sent value to it with javascript  function , it shows value in page , but when i click a buttonin page , i cant access value in code behind. it returns ' ' .  why ? what should i do ?
______________________________________________
<script language="javascript">
        function checkedd() {
            var txt2 = document.getElementById('RadNumericTextBox1_text');
            txt2.value = '987';
            }
        </script>
<telerik:RadNumericTextBox ID="RadNumericTextBox1" Runat="server" >
                        <ClientEvents OnLoad="checkedd" />
                    </telerik:RadNumericTextBox>
______________________________________________________


3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Apr 2009, 10:28 AM
Hi Alex,

Since you are using RadControls for ASP.NET Ajax, use the $find() method for getting the client side object of RadNumericTextBox. The document.getElementById will only return a client side reference to its input area DOM element. Try out the following code.

ASPX:
   
<telerik:RadNumericTextBox ID="RadNumericTextBox1" Runat="server" >   
                <ClientEvents OnLoad="checkedd" />   
</telerik:RadNumericTextBox> 

JavaScript:
   
<script language="javascript" type="text/javascript">    
function checkedd()    
{    
    var numericInput = $find("<%= RadNumericTextBox1.ClientID %>");    
    numericInput.set_value('987');    
}   

CS:
   
protected void Button2_Click(object sender, EventArgs e)    
{    
    Response.Write(RadNumericTextBox1.Text);    
Here you can find more information:
Client-Side Basics
RadNumericTextBox Client Object

Thanks,
Shinu.
0
alex
Top achievements
Rank 1
answered on 20 Apr 2009, 11:48 AM
hello, it works but when i put the  <script language="javascript" type="text/javascript"> in form tag  i have other java script code on <head></head> and i want to use in there not in form tag . what should i do ?
0
Dimo
Telerik team
answered on 22 Apr 2009, 01:33 PM
Hello Alex,

You can place the Javascript function provided by Shinu anywhere on the page that you prefer. However, if it is in the <head>, you must wrap the <script> tag with a <telerik:RadCodeBlock>, otherwise you will get a server error due to the code block.

<head>
     <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

           <script type="text/javascript">

            // ....................

           </script>

      </telerik:RadCodeBlock>
</head>


Best wishes,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Input
Asked by
alex
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
alex
Top achievements
Rank 1
Dimo
Telerik team
Share this question
or