Skip to content

Commit 7c87fb3

Browse files
github-actions[bot]KB Bot
andauthored
Added new kb article stepper-add-navigation-urls (#649)
Co-authored-by: KB Bot <[email protected]>
1 parent 0c525a6 commit 7c87fb3

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
---
2+
title: Adding Navigation URLs to RadStepper Steps
3+
description: Learn how to add navigation URLs to steps in the RadStepper control for ASP.NET AJAX, enabling redirection upon step selection.
4+
type: how-to
5+
page_title: How to Implement Navigation for RadStepper Steps in ASP.NET AJAX
6+
slug: stepper-add-navigation-urls
7+
tags: radstepper, asp.net ajax, navigation, client-side, javascript
8+
res_type: kb
9+
ticketid: 1677261
10+
---
11+
12+
## Environment
13+
14+
<table>
15+
<tbody>
16+
<tr>
17+
<td>Product</td>
18+
<td>RadStepper for ASP.NET AJAX</td>
19+
</tr>
20+
<tr>
21+
<td>Version</td>
22+
<td>2024.4.1114</td>
23+
</tr>
24+
</tbody>
25+
</table>
26+
27+
## Description
28+
29+
In scenarios where clicking a step in the RadStepper control should navigate the user to a specific URL, it's necessary to handle the step selection client-side and perform the navigation using JavaScript. The RadStepper does not have a built-in property to set a navigation URL directly.
30+
31+
This knowledge base article also answers the following questions:
32+
- How can I navigate to a URL when a RadStepper step is clicked?
33+
- Is it possible to assign a navigation URL to steps in the RadStepper control?
34+
- Can I use JavaScript to handle step selection in RadStepper for navigation purposes?
35+
36+
## Solution
37+
38+
To achieve navigation from RadStepper steps, follow these steps:
39+
40+
1. **Handle the OnClientStepSelected Event**: Utilize the [OnClientStepSelected](https://docs.telerik.com/devtools/aspnet-ajax/controls/stepper/client-side-programming/events) event to detect when a step is selected by the user.
41+
42+
2. **Implement JavaScript for Navigation**: Within the event handler, use JavaScript to navigate to the URL associated with the selected step.
43+
44+
### Sample Implementation
45+
46+
```asp
47+
<telerik:RadStepper runat="server" ID="RadStepper1">
48+
<ClientEvents OnStepSelected="onStepSelected" />
49+
<Steps>
50+
<telerik:StepperStep Label="Step 1" />
51+
<telerik:StepperStep Label="Step 2" />
52+
<telerik:StepperStep Label="Step 3" />
53+
</Steps>
54+
</telerik:RadStepper>
55+
56+
<script type="text/javascript">
57+
function onStepSelected(sender, args) {
58+
var stepIndex = args.get_step().getIndex();
59+
60+
// Define URLs for each step
61+
var urls = [
62+
"http://example.com/step1",
63+
"http://example.com/step2",
64+
"http://example.com/step3"
65+
];
66+
67+
// Navigate to the URL corresponding to the selected step
68+
window.location.href = urls[stepIndex];
69+
}
70+
</script>
71+
```
72+
73+
**Explanation:**
74+
- `OnClientStepSelected`: This event triggers when a user selects a step, providing an opportunity to execute custom JavaScript code.
75+
- `args.get_step().getIndex()`: This method retrieves the index of the selected step, which is used to identify the correct URL from the `urls` array.
76+
- `URLs Array`: An array that holds the URLs for each step. The navigation occurs based on the array index matching the step index.
77+
78+
Using this approach, you can easily add navigation functionality to the RadStepper steps without the need for server-side processing.
79+
80+
## See Also
81+
82+
- [RadStepper Client-Side Programming Overview](https://docs.telerik.com/devtools/aspnet-ajax/controls/stepper/client-side-programming/overview)
83+
- [RadStepper Server-Side Programming Overview](https://docs.telerik.com/devtools/aspnet-ajax/controls/stepper/server-side-programming/overview)

0 commit comments

Comments
 (0)