Currently, I am using a WebSiteMap, SiteMapDataSource and TreeView to handle the navigation. When first accessing the app, the restricted features are not visiable. When an user logs in, then the user features become visiable on the tree view. Likewise, when an administrator logs in, then both the user and administrator features appear.
I would like to replace the WebSiteMap, SiteMapDataSource and TreeView with the Prometheus RadMenu with the options being displaced horizonally across the top of the MasterPage.
I did try the option of indicating that the data source to the RadMenu was the SiteMapDataSource but this option only displayed the first note ("Home") with the other options as children and only when the home option was selected. (The first leve in a WebSiteMap can have only one note.)
Does anyone know how to integrate the RadMenu with the MembershipProvider such that retricted buttons only appear if the user is authorized to access those features>
6 Answers, 1 is accepted
<telerik:RadMenu ID="RadMenu1" EnableEmbeddedSkins="false" Skin="scSkin" runat="server" /> |
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load |
If Not Page.IsPostBack Then |
If Roles.IsUserInRole("Administrator") Then |
RadMenu1.LoadContentFile("~/App_Data/scMenuData_admin.xml") |
ElseIf Roles.IsUserInRole("User") Then |
RadMenu1.LoadContentFile("~/App_Data/scMenuData_user.xml") |
End If |
End If |
End Sub |
Hope that helps you out.
Is your code running in the master page code behind or on the various content pages code behind?
I tried doing that but the RadMenu is not visible to the master page code behind:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Telerik.Web.UI;
namespace ElectronicLane
{
public partial class MasterPage : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (Roles.IsUserInRole("User") || Roles.IsUserInRole("Admin"))
{
RadMenuItem RootItem = new RadMenuItem();
RootItem.Text = "New Root Item";
RadMenu1.Items.Add(RootItem); <== Can't find RadMenu1
}
}
}
On the MasterPage.master, I have:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="MasterPage.master.cs" Inherits="MasterPage" %>
and
<telerik:RadMenu ID="RadMenu1" Runat="server" Flow="Horizontal" Skin="Inox">
<DefaultGroupSettings Flow="Vertical" ExpandDirection="Auto"></DefaultGroupSettings>
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
<Items>....</Items>
<ExpandAnimation Type="OutQuart"></ExpandAnimation>
</telerik:RadMenu>
You need to have this line underneath your <%@ Master... line
<%@ Register Assembly="Telerik.Web.UI" NameSpace="Telerik.Web.UI" TagPrefix="telerik" %> |
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="MasterPage.master.cs"
Inherits="MasterPage" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>ElectronicLane</title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td align="right" colspan="2">
<asp:LoginName ID="loginName1" runat="server" FormatString="Welcome {0} to our site."
Font-Italic="True" ForeColor="#3333FF" />
 
<asp:LoginStatus ID="LoginStatus1" runat="server" Font-Italic="True" LoginText="Authorized Dealer Login"
LogoutPageUrl="~/Default.aspx" />
</td>
</tr>
<tr>
<td class="firstColumn">
 <img alt="" src="Images/ElectronicLane.gif" />
</td>
<td align="center" class="secondColumn">
<table id="Table1" runat="server">
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text="2709 Electronic Lane, Dallas, TX 75220"
Font-Bold="True" Font-Italic="True" ForeColor="Black" Height="20px" Width="387px"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label3" runat="server" Text="Phone: 214-956-0555 FAX: 1-800-932-2960"
Font-Bold="True" Font-Italic="True" ForeColor="Black" Height="20px" Width="387px"></asp:Label>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
</td>
<td>
<table width="100%">
<tr>
<td>
<telerik:RadMenu ID="RadMenu1" Runat="server" Flow="Horizontal" Skin="Inox">
<DefaultGroupSettings Flow="Vertical" ExpandDirection="Auto"></DefaultGroupSettings>
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
<Items>
<telerik:RadMenuItem runat="server" ExpandMode="ClientSide"
NavigateUrl="Default.aspx" Text="Home">
<groupsettings expanddirection="Auto" flow="Vertical" />
</telerik:RadMenuItem>
<telerik:RadMenuItem runat="server" ExpandMode="ClientSide"
NavigateUrl="Products.aspx" Text="Products">
<groupsettings expanddirection="Auto" flow="Vertical" />
</telerik:RadMenuItem>
<telerik:RadMenuItem runat="server" ExpandMode="ClientSide"
NavigateUrl="NewsandEvents.aspx" Text="News and Events">
<groupsettings expanddirection="Auto" flow="Vertical" />
</telerik:RadMenuItem>
<telerik:RadMenuItem runat="server" ExpandMode="ClientSide"
NavigateUrl="AboutUs.aspx" Text="AboutUs">
<groupsettings expanddirection="Auto" flow="Vertical" />
</telerik:RadMenuItem>
<telerik:RadMenuItem runat="server" ExpandMode="ClientSide"
NavigateUrl="NewDealer.aspx" Text="New Dealer">
<groupsettings expanddirection="Auto" flow="Vertical" />
</telerik:RadMenuItem>
</Items>
<ExpandAnimation Type="OutQuart"></ExpandAnimation>
</telerik:RadMenu>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td>
<img alt="" src="Images/Edge.gif" /></td>
</tr>
<tr>
<td>
<img alt="" src="Images/Cedia.gif" /></td>
</tr>
</table>
</td>
<td class="secondColumn" style="vertical-align: top; border-top: olive thick solid;
border-left: olive thick solid; border-top-width: thick; border-left-width: thick;
border-left-color: olive; border-top-color: olive; border-right-width: thick;
border-right-color: olive;">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>