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

Cannot get access to controls from clientside

3 Answers 74 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Henrik
Top achievements
Rank 1
Henrik asked on 23 Jan 2009, 06:49 AM
Hi!

In my webapp I'm using the ASP.NET RadControls, but I cannot get access to them clientside. For example, if I have this:
<tel:RadNumericTextBox ID="txtCalcYearIndex"  NumberFormat-DecimalSeparator="," CssClass="textbox" runat="server" /> 
<script type="text/javascript"
var txtCalcYearIndex = <%=txtCalcYearIndex.ClientID%>
txtCalcYearIndex.SetValue("12345"); 
</script> 
- then I get an error saying: "ctl00_MainContent_txtCalcYearIndex is not defined"

I am also using jQuery in my application - does this have something to say? Or is it possible to use jQuery to access telerik controls? - then I could use the same approach for all control instead of distinguishing between core ASP.NET controls and Telerik controls...

Best regards

Henrik




3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 23 Jan 2009, 07:24 AM
Hi Henrik,

Try the following client side code for accessing the RadNumericTextBox's client side object. You have to use the $find method for accessing the RadControls. See the example.

JavaScript:
<script type="text/javascript">  
function getInput() 
    var txtCalcYearIndex = $find("<%= txtCalcYearIndex.ClientID %>"); //get the client side object 
    txtCalcYearIndex.set_value("12345"); //setting the value 
</script>  

ASPX:
<telerik:RadNumericTextBox ID="txtCalcYearIndex" Runat="server"></telerik:RadNumericTextBox> 
<input id="Button1" type="button" value="button" onclick="getInput();"/> 

You can also refer to the online documentation which explains about most important properties/methods of the RadNumericTextBox client side object.
Client-Side Basics
RadNumericTextBox Client Object

Thanks,
Shinu.
0
Henrik
Top achievements
Rank 1
answered on 23 Jan 2009, 11:41 AM
Hi Shanu,

That works - thank you.
Whenever I googled on telerik client side, I ended up on this page:
http://www.telerik.com/help/aspnet/input/clientsideapi.html
- which explains a different approach. But maybe I searched for the wrong keywords.

Best regards
Henrik


0
Paul
Telerik team
answered on 23 Jan 2009, 11:50 AM
Hello Henrik,

The mentioned URL points to the documentation of the 'classic' RadInput for ASP.NET, but it seems you are using  RadInput for ASP.NET AJAX. These are two different controls and there are differences in their API.

Kind regards,
Paul
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
General Discussions
Asked by
Henrik
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Henrik
Top achievements
Rank 1
Paul
Telerik team
Share this question
or