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