|
| 1 | +--- |
| 2 | +title: Containing a RadWindow within an Element |
| 3 | +description: Learn how to contain a RadWindow within a specific element using the RestrictionZoneID property. |
| 4 | +type: how-to |
| 5 | +page_title: How to Contain a RadWindow within an Element |
| 6 | +slug: contain-radwindow-within-element |
| 7 | +tags: radwindow, asp.net ajax, containment, restriction zone |
| 8 | +res_type: kb |
| 9 | +--- |
| 10 | +## Environment |
| 11 | +| Property | Value | |
| 12 | +| --- | --- | |
| 13 | +| Product | RadWindow for ASP.NET AJAX | |
| 14 | +| Version | 2024.1.131 | |
| 15 | + |
| 16 | +## Description |
| 17 | +I would like to know how to contain a RadWindow within a specific element so that the window cannot leave that area. I want to achieve the same behavior as 'KeepInScreenBounds' but for an element, not the screen. |
| 18 | + |
| 19 | +## Solution |
| 20 | +To achieve this behavior, you can use the `RestrictionZoneID` property of the RadWindow. This property allows you to specify the ID of an HTML element within which the RadWindow will be constrained. Here's how you can set it up: |
| 21 | + |
| 22 | +1. Create a container element, such as a `<div>`, with the desired dimensions and a unique ID: |
| 23 | +```html |
| 24 | +<div id="radWindowContainer" style="width: 500px; height: 500px; border: 1px solid #000;"> |
| 25 | + <!-- Your container element --> |
| 26 | +</div> |
| 27 | +``` |
| 28 | + |
| 29 | +2. Use the `RestrictionZoneID` property of the RadWindow to specify the ID of the container element: |
| 30 | +```html |
| 31 | +<telerik:RadWindowManager ID="RadWindowManager1" runat="server"> |
| 32 | + <Windows> |
| 33 | + <telerik:RadWindow ID="RadWindow1" runat="server" NavigateUrl="default2.aspx" Title="My Window" VisibleOnPageLoad="true" VisibleStatusbar="false" |
| 34 | + RestrictionZoneID="radWindowContainer" Width="300" Height="200"> |
| 35 | + </telerik:RadWindow> |
| 36 | + </Windows> |
| 37 | +</telerik:RadWindowManager> |
| 38 | +``` |
| 39 | + |
| 40 | +In this setup, the `radWindowContainer` `<div>` acts as the boundary for the RadWindow. The `RestrictionZoneID` property of the RadWindow is set to the ID of the container element (`radWindowContainer`), ensuring that the window stays within the confines of this div. |
| 41 | + |
| 42 | +Now, the RadWindow will be contained within the specified element and cannot leave that area, providing the functionality you're looking for. |
| 43 | + |
| 44 | +## Notes |
| 45 | +- Make sure to adjust the dimensions and styles of the container element (`radWindowContainer`) to fit your specific requirements. |
| 46 | +- The `RestrictionZoneID` property can only be used with elements that have a defined size, such as a `<div>` with a specified width and height. |
| 47 | + |
0 commit comments