您目前尚未登陆,请选择【登陆】或【注册
首页->全站代码->MyWebPages51aspx汉化最终版>>App-Code/Controls/HomepageContent.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:MyWebPages51aspx汉化最终版
当前文件:文件类型 MyWebPagesStarterKit/App_Code/Controls/HomepageContent.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; 11using System.Data; 12using System.Configuration; 13using System.Web; 14using System.Web.Security; 15using System.Web.UI; 16using System.Web.UI.WebControls; 17using System.Web.UI.WebControls.WebParts; 18using System.Web.UI.HtmlControls; 19using System.Web.UI.Design; 20using System.ComponentModel; 21 22namespace MyWebPagesStarterKit.Controls 23{ 24 [Designer(typeof(HomepageContentDesigner)), ToolboxData("<{0}:TemplatedPanel runat=server></{0}:TemplatedPanel>")] 25 public class HomepageContent : WebControl, INamingContainer 26 { 27 private ITemplate _homepageTemplate; 28 private ITemplate _subpageTemplate; 29 30 public HomepageContent() { } 31 32 [Browsable(false), PersistenceMode(PersistenceMode.InnerProperty)] 33 public ITemplate HomepageTemplate 34 { 35 get 36 { 37 return _homepageTemplate; 38 } 39 set 40 { 41 _homepageTemplate = value; 42 } 43 } 44 45 [Browsable(false), PersistenceMode(PersistenceMode.InnerProperty)] 46 public ITemplate SubpageTemplate 47 { 48 get 49 { 50 return _subpageTemplate; 51 } 52 set 53 { 54 _subpageTemplate = value; 55 } 56 } 57 58 protected override void CreateChildControls() 59 { 60 if ((_homepageTemplate != null) && (_subpageTemplate != null)) 61 { 62 PlaceHolder ctl = new PlaceHolder(); 63 if ((Page.Session["Homepage"] != null) && ((bool)Page.Session["Homepage"])) 64 { 65 _homepageTemplate.InstantiateIn(ctl); 66 } 67 else 68 { 69 _subpageTemplate.InstantiateIn(ctl); 70 } 71 Controls.Add(ctl); 72 } 73 } 74 } 75 76 public class HomepageContentDesigner : ControlDesigner 77 { 78 TemplateGroupCollection col = null; 79 80 public override void Initialize(IComponent component) 81 { 82 // Initialize the base 83 base.Initialize(component); 84 // Turn on template editing 85 SetViewFlags(ViewFlags.TemplateEditing, true); 86 } 87 88 // Add instructions to the placeholder view of the control 89 public override string GetDesignTimeHtml() 90 { 91 return CreatePlaceHolderDesignTimeHtml("Click here and use the task menu to edit the template."); 92 } 93 94 public override TemplateGroupCollection TemplateGroups 95 { 96 get 97 { 98 if (col == null) 99 { 100 // Get the base collection 101 col = base.TemplateGroups; 102 103 // Create variables 104 TemplateGroup tempGroup; 105 TemplateDefinition tempDef; 106 TemplatedContent ctl; 107 108 // Get reference to the component as TemplateGroupsSample 109 ctl = (TemplatedContent)Component; 110 111 // Create a TemplateGroup 112 tempGroup = new TemplateGroup("Content"); 113 114 tempDef = new TemplateDefinition(this, "Content", ctl, "HomepageTemplate", false); 115 tempGroup.AddTemplateDefinition(tempDef); 116 117 tempDef = new TemplateDefinition(this, "Content", ctl, "SubpageTemplate", false); 118 tempGroup.AddTemplateDefinition(tempDef); 119 120 // Add the TemplateGroup to the TemplateGroupCollection 121 col.Add(tempGroup); 122 } 123 return col; 124 } 125 } 126 127 // Do not allow direct resizing unless in TemplateMode 128 public override bool AllowResize 129 { 130 get 131 { 132 if (this.InTemplateMode) 133 return true; 134 else 135 return false; 136 } 137 } 138 } 139}
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:MyWebPages51aspx汉化最终版
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号