我有一个 RadMenu,我希望在单击时突出显示选定的项目。但我无法得到想要的结果......
下面是我在 ascx.cs 文件中的代码:
命名空间 HGS.HGSAdmin.UserControl { 公共部分类 UCLeftMenu : System.Web.UI.UserControl { protected void Page_Load(object sender, GridItemEventArgs e) {
RadMenuItem item = RadLeftMenu.FindItemByUrl(Request.Url.PathAndQuery);
if (item != null)
{
Response.Write(item.Text);
foreach (RadMenuItem childItem in item.Menu.GetAllItems())
{
childItem.CssClass = "";
}
item.CssClass = "focused";
while (item.Owner is RadMenuItem)
{
((RadMenuItem)item.Owner).CssClass = "focused";
item = (RadMenuItem)item.Owner;
}
}
}
protected void RadLeftMenu_ItemClick(object sender, RadMenuEventArgs e)
{
foreach (RadMenuItem childItem in e.Item.Menu.GetAllItems())
{
childItem.CssClass = "";
}
e.Item.CssClass = "focused";
RadMenuItem item = e.Item;
while (item.Owner is RadMenuItem)
{
((RadMenuItem)item.Owner).CssClass = "focused";
item = (RadMenuItem)item.Owner;
}
}
}
}
下面是我的 ascx 页面:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UCLeftMenu.ascx.cs" Inherits="HGS.HGSAdmin.UserControl.UCLeftMenu" %> <%@ Register Assembly="Telerik.Web.UI" 命名空间="Telerik.Web.UI" TagPrefix="telerik" %>
<script src="../../Script/RadMenu.js" type="text/javascript"></script>
<link href="../../Styles/styles_RadMenu.css" rel="stylesheet" type="text/css" />
<table valign="top">
<tr>
<td rowspan="2" class="contarea">
</td>
</tr>
<tr>
<td width="192" align="left" valign="top" class="menumid">
<telerik:RadScriptManager ID="ScriptManager" runat="server">
</telerik:RadScriptManager>
<telerik:RadMenu ID="RadLeftMenu" runat="server" EnableEmbeddedSkins="true" EnableRoundedCorners="true"
Flow="Vertical" EnableShadows="true" OnItemClick="RadLeftMenu_ItemClick">
<%--<LoadingStatusTemplate>
<asp:Image runat="server" ID="LoadingImage" ImageUrl="Images/loading.gif" ToolTip="Loading..." Width="16px" Height="16px" style="margin-top:8px" />
</LoadingStatusTemplate>--%>
<Items>
<telerik:RadMenuItem runat="server" Text=". Home" NavigateUrl="../FrmStaticPage.aspx?h">
</telerik:RadMenuItem>
<telerik:RadMenuItem runat="server" Text=". About Us" NavigateUrl="../FrmStaticPage.aspx?a">
</telerik:RadMenuItem>
<telerik:RadMenuItem runat="server" Text=". Services" NavigateUrl="../FrmStaticPage.aspx?s">
</telerik:RadMenuItem>
<telerik:RadMenuItem runat="server" Text=". Gallery" NavigateUrl="../FrmStaticPage.aspx?g">
</telerik:RadMenuItem>
<telerik:RadMenuItem runat="server" Text=". Contact Us" NavigateUrl="../FrmStaticPage.aspx?c">
</telerik:RadMenuItem>
<telerik:RadMenuItem runat="server" Text=". Testimonials" NavigateUrl="../FrmTestimonials.aspx?t">
</telerik:RadMenuItem>
<telerik:RadMenuItem runat="server" Text=". Links" NavigateUrl="../FrmStaticPage.aspx?l">
</telerik:RadMenuItem>
<telerik:RadMenuItem runat="server" Text=". Featured Services" NavigateUrl="~/HGSAdmin/FrmFeaturedServices.aspx">
<GroupSettings Flow="Vertical" />
</telerik:RadMenuItem>
<telerik:RadMenuItem runat="server" Text=". Banner Images" NavigateUrl="../Banner.aspx">
</telerik:RadMenuItem>
</Items>
</telerik:RadMenu>
</td>
</table>
任何人都可以请指导吗?非常感谢!