您目前尚未登陆,请选择【登陆】或【注册
首页->博客论坛->LiveBlog v1.0测试版源码>>LiveBlog.Web/Admin/Menu.ascx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:LiveBlog v1.0测试版源码
当前文件:文件类型 LiveBlog/LiveBlog.Web/Admin/Menu.ascx.cs打开代码结构图
普通视图
		            
1using System; 2using System.IO; 3using System.Web; 4using System.Web.UI.WebControls; 5using System.Web.UI.HtmlControls; 6using LiveBlog.Core.Providers; 7using LiveBlog.Core; 8 9public partial class admin_Menu : System.Web.UI.UserControl 10{ 11 protected void Page_Load(object sender, EventArgs e) 12 { 13 if (!Page.IsCallback) 14 BindMenu(); 15 } 16 17 private void BindMenu() 18 { 19 foreach (SiteMapNode adminNode in SiteMap.Providers["SecuritySiteMap"].RootNode.ChildNodes) 20 { 21 if (adminNode.IsAccessibleToUser(HttpContext.Current)) 22 { 23 if (!Request.RawUrl.ToUpperInvariant().Contains("/ADMIN/") && (adminNode.Url.Contains("xmanager") || adminNode.Url.Contains("PingServices"))) 24 continue; 25 26 HtmlAnchor a = new HtmlAnchor(); 27 a.HRef = adminNode.Url; 28 29 a.InnerHtml = "<span>" + Translate(adminNode.Title) + "</span>";//"<span>" + Translate(info.Name.Replace(".aspx", string.Empty)) + "</span>"; 30 if (Request.RawUrl.EndsWith(adminNode.Url, StringComparison.OrdinalIgnoreCase)) 31 a.Attributes["class"] = "current"; 32 HtmlGenericControl li = new HtmlGenericControl("li"); 33 li.Controls.Add(a); 34 ulMenu.Controls.Add(li); 35 } 36 } 37 38 if (!Request.RawUrl.ToUpperInvariant().Contains("/ADMIN/")) 39 AddItem(Resources.labels.changePassword, Utils.RelativeWebRoot + "login.aspx"); 40 } 41 42 public void AddItem(string text, string url) 43 { 44 HtmlAnchor a = new HtmlAnchor(); 45 a.InnerHtml = "<span>" + text + "</span>"; 46 a.HRef = url; 47 48 HtmlGenericControl li = new HtmlGenericControl("li"); 49 li.Controls.Add(a); 50 ulMenu.Controls.Add(li); 51 } 52 53 public string Translate(string text) 54 { 55 try 56 { 57 return this.GetGlobalResourceObject("labels", text).ToString(); 58 } 59 catch (NullReferenceException) 60 { 61 return text; 62 } 63 } 64 65} 66
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:LiveBlog v1.0测试版源码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号