您目前尚未登陆,请选择【登陆】或【注册
首页->全站代码->MyWebPages51aspx汉化最终版>>App-Code/Controls/SidebarControl.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:MyWebPages51aspx汉化最终版
当前文件:文件类型 MyWebPagesStarterKit/App_Code/Controls/SidebarControl.cs打开代码结构图
普通视图
		            
1//=============================================================================================== 2// 3// (c) Copyright Microsoft Corporation. 4// This source is subject to the Microsoft Permissive License. 5// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx. 6// All other rights reserved. 7// 8//=============================================================================================== 9 10using System.IO; 11using System.Web; 12using System.Web.UI; 13using System.Web.UI.WebControls; 14using System.Web.UI.HtmlControls; 15using System.Xml; 16using System.Xml.Xsl; 17 18namespace MyWebPagesStarterKit.Controls 19{ 20 /// <summary> 21 /// Sidebar control to display a vertical bar with various RSS items/channels 22 /// </summary> 23 public class SidebarControl : WebControl, INamingContainer 24 { 25 /// <summary> 26 /// Reference to sidebar data object 27 /// </summary> 28 protected Sidebar _sidebar; 29 30 /// <summary> 31 /// Constructor, initializes sidebar data 32 /// </summary> 33 public SidebarControl(): base() 34 { 35 _sidebar = Sidebar.GetInstance(); 36 } 37 38 /// <summary> 39 /// Adds controls to the sidebar depending on the Sidebar data object 40 /// </summary> 41 protected override void CreateChildControls() 42 { 43 string Xml = _sidebar.GetRSSFeed(HttpContext.Current.User.Identity); 44 45 if (Xml != string.Empty) 46 { 47 //for Valid XHTML 1.0 Transitional the div-tag cannot be placed directly within span-tag 48 //span-tag is created automatically by the .net control 49 HtmlGenericControl obj = new HtmlGenericControl("object"); 50 Controls.Add(obj); 51 52 HtmlGenericControl divTop = new HtmlGenericControl("div"); 53 divTop.Attributes.Add("class", "sidebartop"); 54 //Controls.Add(divTop); 55 obj.Controls.Add(divTop); 56 57 HtmlGenericControl divSidebar = new HtmlGenericControl("div"); 58 divSidebar.Attributes.Add("class", "sidebar"); 59 //Controls.Add(divSidebar); 60 obj.Controls.Add(divSidebar); 61 62 XmlDocument doc = new XmlDocument(); 63 doc.LoadXml(Xml); 64 65 foreach (XmlNode link in doc.SelectNodes("//link")) 66 link.InnerText = ResolveUrl(link.InnerText); 67 68 Xml ctrlFeed = new Xml(); 69 divSidebar.Controls.Add(ctrlFeed); 70 ctrlFeed.ID = "ctrlSidebarFeed"; 71 72 ctrlFeed.XPathNavigator = doc.CreateNavigator(); 73 ctrlFeed.TransformSource = Page.Server.MapPath("~/App_Themes/" + Page.Theme + "/sidebar.xsl"); 74 ctrlFeed.DataBind(); 75 76 /* it is a known issue that the html encoding is not correct with the Xml control and XSLT. The alternative is to create the string manually and render it. 77 * See http://weblogs.asp.net/justin_rogers/archive/2004/08/04/208464.aspx 78 */ 79 80 HtmlGenericControl divBottom = new HtmlGenericControl("div"); 81 divBottom.Attributes.Add("class", "sidebarbottom"); 82 //Controls.Add(divBottom); 83 obj.Controls.Add(divBottom); 84 Controls.Add(obj); 85 } 86 } 87 } 88}
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:MyWebPages51aspx汉化最终版
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号