Skip to content

Commit 6c692e1

Browse files
github-actions[bot]KB Bot
and
KB Bot
authored
Added new kb article splitter-accessing-aspnet-placeholder-control-in-radpane-using-javascript (#635)
Co-authored-by: KB Bot <[email protected]>
1 parent 64119ec commit 6c692e1

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
title: Accessing ASP.NET PlaceHolder Control in RadPane Using JavaScript
3+
description: Learn how to make ASP.NET PlaceHolder controls accessible via JavaScript when used within a RadPane by wrapping them in a server control that renders an HTML element.
4+
type: how-to
5+
page_title: Making ASP.NET PlaceHolder Controls Accessible in JavaScript within RadPane
6+
slug: splitter-accessing-aspnet-placeholder-control-in-radpane-using-javascript
7+
tags: radsplitter, asp.net ajax, radpane, javascript, placeholder, panel
8+
res_type: kb
9+
ticketid: 1671798
10+
---
11+
12+
## Environment
13+
14+
<table>
15+
<tbody>
16+
<tr>
17+
<td>Product</td>
18+
<td>RadSplitter for ASP.NET AJAX</td>
19+
</tr>
20+
</tbody>
21+
</table>
22+
23+
## Description
24+
25+
In ASP.NET WebForms, I'm using a `asp:PlaceHolder` control inside a `RadPane` to dynamically add several controls. However, I cannot locate the `PlaceHolder` using JavaScript functions like `$find('RecordForm')` or `document.getElementById('RecordForm')`. Both return null. How can I access the PlaceHolder control with JavaScript?
26+
27+
This knowledge base article also answers the following questions:
28+
- How to make a PlaceHolder control accessible via JavaScript in ASP.NET AJAX?
29+
- What is the method to interact with dynamically added controls in a PlaceHolder on the client side?
30+
- Why can't JavaScript find a PlaceHolder control and how to solve it?
31+
32+
## Solution
33+
34+
The `asp:PlaceHolder` control does not render any HTML element, making it inaccessible through JavaScript's `$get()` or `document.getElementById()`. To interact with the PlaceHolder or its dynamically added controls on the client side, wrap the PlaceHolder in a server control that renders an HTML element, such as `asp:Panel`.
35+
36+
Modify your markup to include the PlaceHolder within a Panel:
37+
38+
```asp
39+
<telerik:RadPane id="PaneLeftTop" runat="server" Scrolling="None" BackColor="#F5F5F5" OnClientResized="OnClientPaneLeftTopResized">
40+
<div style="margin-top:3px;margin-left:7px;line-height:2.25">
41+
<asp:Panel id="RecordFormPanel" runat="server">
42+
<asp:PlaceHolder id="RecordForm" runat="server" />
43+
</asp:Panel>
44+
</div>
45+
</telerik:RadPane>
46+
```
47+
48+
Access the Panel with JavaScript by its ID:
49+
50+
```javascript
51+
var panel = document.getElementById('RecordFormPanel'); // or $get('RecordFormPanel')
52+
```
53+
54+
The `asp:Panel` control renders as a `<div>` element in HTML, making it accessible through JavaScript. This approach allows you to maintain the server-side functionality of dynamically adding controls to the PlaceHolder while also providing a way to interact with those controls or their container on the client side.
55+
56+
## See Also
57+
58+
- [RadSplitter for ASP.NET AJAX - Overview](https://www.telerik.com/products/aspnet-ajax/documentation/controls/splitter/overview)
59+
- [ASP.NET Panel Control Overview](https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.panel)
60+
- [Using JavaScript to Manipulate DOM Elements](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Introduction)

0 commit comments

Comments
 (0)