Issue with finding element in grid edit with ascx WebUserControl

1 Answer 50 Views
Grid UI for ASP.NET AJAX in ASP.NET MVC
Al
Top achievements
Rank 1
Iron
Al asked on 29 Sep 2023, 12:44 PM

Hi
I am really struggling to find a how to edit a textbox. I have a grid edited with a ascx WebUserControl. Within the ascx I the following 

var pSalesOrderNumber = $find("<%= txtOrderNumber.ClientID %>");
It is undefined.  I tried using  $telerik.findControl but still no luck. Sadly out of my depth.  Any help would be much appreciated

 

 

Al
Top achievements
Rank 1
Iron
commented on 29 Sep 2023, 01:49 PM

An acceptable workaround is to use RadTextbox instead of a textBox.  I would have liked to have solved this. 

1 Answer, 1 is accepted

Sort by
0
Doncho
Telerik team
answered on 04 Oct 2023, 07:13 AM

Hi Al,

The native asp:TextBox server control has no corresponding Client-side control object. To reach it on the client-side you will need to use the $get() method (or the document.getElementById() method) as a replacement for the $find():

var pSalesOrderNumber = $get("<%= txtOrderNumber.ClientID %>");

Please let me share some general information on this matter:

Most of the Telerik Controls expose also a client-side control object with its own client-side API. The $find() method would return the JavaScript object representing the client control. However, if you try to $find() an asp:Pane or asp:TextBoxl, it would return null as the Panel and the TextBox have no corresponding client-side object. Instead, you can use the $get() method that returns a DOM element but not a JavaScript object. The $find() and $get() methods are part of the ASP.NET AJAX Client Side Library. It is a feature of the framework that allows easy getting a reference to a Client-side Control object instance or to a native DOM element on the page. 

When it comes to getting a control on the client-side (such that has a client-side control object, e.g. RadTextBox), we have some of the common different approaches for getting a client-side reference to a control object listed in the following article:

If this is not the case here, I would ask you to share the complete markup declaration of the page in question so I can get a better overview of the case and assist you more accurately.

I hope you will find this information useful.

Kind regards,
Doncho
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources
Tags
Grid UI for ASP.NET AJAX in ASP.NET MVC
Asked by
Al
Top achievements
Rank 1
Iron
Answers by
Doncho
Telerik team
Share this question
or