Asp.net源码专业站
首页->控件应用->口凡网日历控件及Demo源码>>Controls/CodefanEditor.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:口凡网日历控件及Demo源码
当前文件:文件类型 CodefanCalendar/Controls/CodefanEditor.cs[5K,2009-6-12 11:36:08]打开代码结构图
普通视图
		            
1using System; 2using System.Collections.Generic; 3using System.ComponentModel; 4using System.Text; 5using System.Web; 6using System.Web.UI; 7using System.Web.UI.WebControls; 8using System.Drawing.Design; 9using System.Collections.Specialized; 10 11[assembly: TagPrefix("Codefan.Controls", "Codefan")] 12 13namespace Codefan.Controls 14{ 15 [DefaultProperty("Text")] 16 [ToolboxData("<{0}:CodefanEditor runat=server></{0}:CodefanEditor>")] 17 [Designer("Codefan.Controls.EditorDesigner")] 18 public class CodefanEditor:Control,IPostBackDataHandler 19 { 20 private static readonly object ValueChangedEvent; 21 22 /// <summary> 23 /// 值改变事件 24 /// </summary> 25 public event EventHandler ValueChanged 26 { 27 add 28 { 29 base.Events.AddHandler(ValueChangedEvent, value); 30 } 31 remove 32 { 33 base.Events.RemoveHandler(ValueChangedEvent, value); 34 } 35 } 36 37 protected virtual void OnValueChanged(EventArgs e) 38 { 39 if (base.Events != null) 40 { 41 EventHandler handler=(EventHandler)base.Events[ValueChangedEvent]; 42 if (handler != null) 43 { 44 handler(this, e); 45 } 46 } 47 } 48 49 void IPostBackDataHandler.RaisePostDataChangedEvent() 50 { 51 this.OnValueChanged(EventArgs.Empty); 52 } 53 bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection) 54 { 55 if (postCollection[postDataKey] != this.Text) 56 { 57 this.Text = postCollection[postDataKey]; 58 return true; 59 } 60 return false; 61 } 62 63 static CodefanEditor() 64 { 65 ValueChangedEvent = new object(); 66 } 67 68 public CodefanEditor() 69 { 70 71 } 72 73 /// <summary> 74 /// 编辑器高度设定,默认值为300px 75 /// </summary> 76 public Unit Height 77 { 78 get 79 { 80 object obj = this.ViewState["Height"]; 81 return ((obj == null) ? Unit.Parse("300px") : ((Unit)obj)); 82 } 83 set 84 { 85 this.ViewState["Height"] = value; 86 } 87 } 88 89 /// <summary> 90 /// 编辑器宽度设定,默认值为621px 91 /// </summary> 92 public Unit Width 93 { 94 get 95 { 96 object obj = this.ViewState["Width"]; 97 return ((obj == null) ? Unit.Parse("621px") : ((Unit)obj)); 98 } 99 set 100 { 101 this.ViewState["Width"] = value; 102 } 103 } 104 105 /// <summary> 106 /// 编辑器内部的文本信息 107 /// </summary> 108 public String Text 109 { 110 get 111 { 112 object obj = this.ViewState["Text"]; 113 return ((obj == null) ? string.Empty : (String)obj); 114 } 115 set 116 { 117 this.ViewState["Text"] = value; 118 } 119 120 } 121 122 123 /// <summary> 124 /// 编辑器页面路径 125 /// </summary> 126 private String EditorPath 127 { 128 get 129 { 130 String path = ResolveUrl("~/Codefan-Controls/Editor/editor.htm"); 131 return path; 132 } 133 } 134 135 /// <summary> 136 /// Render 137 /// </summary> 138 /// <param name="writer"></param> 139 protected override void Render(HtmlTextWriter writer) 140 { 141 base.Render(writer); 142 String str = String.Format("<input type=\"hidden\" id=\"{0}\" name=\"{0}\" value=\"{1}\" />", this.UniqueID, HttpUtility.HtmlEncode(this.Text)); 143 writer.Write(str); 144 str = String.Format("<iframe id=\"{0}\" src=\"{4}\" frameBorder=\"0\" scrolling=\"no\" width=\"{2}\" height=\"{3}\"" + 145 " onload=\"setTimeout('if(document.all)window.frames[\\'{0}\\'].$(\\'c\\').contentWindow.document.body.innerHTML=\\'<div>\\'+document.getElementById(\\'{1}\\').value+\\'</div>\\';else document.getElementById(\\'{0}\\').contentWindow.$(\\'c\\').contentWindow.document.body.innerHTML=\\'<div>\\'+document.getElementById(\\'{1}\\').value+\\'</div>\\';',400);setInterval('if(document.all)document.getElementById(\\'{1}\\').value=window.frames[\\'{0}\\'].$(\\'c\\').contentWindow.document.body.innerHTML;else document.getElementById(\\'{1}\\').value=document.getElementById(\\'{0}\\').contentWindow.$(\\'c\\').contentWindow.document.body.innerHTML;',500)\" ></iframe>", this.ID + "_Editor", this.UniqueID, this.Width, this.Height, this.EditorPath); 146 writer.Write(str); 147 } 148 } 149 150 /// <summary> 151 /// 编辑器设计期样子 152 /// </summary> 153 public class EditorDesigner : System.Web.UI.Design.ControlDesigner 154 { 155 /// <summary> 156 /// 默认构造函数 157 /// </summary> 158 public EditorDesigner() { } 159 160 /// <summary> 161 /// 返回设计时展示的样子 162 /// </summary> 163 /// <returns></returns> 164 public override string GetDesignTimeHtml() 165 { 166 CodefanEditor e = (CodefanEditor)base.Component; 167 return String.Format("<div style=\"width:{0};height:{1};border:1pt solid #black;background:#e6e6e6;padding:4px;\">This is the CodefanEditorV1.0,More Codefan-Controls please click <a href='http://www.codefan.net/'>http://www.codefan.net/</a></div>", e.Width, e.Height); 168 } 169 } 170} 171
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:口凡网日历控件及Demo源码
51Aspx.com 版权所有 CopyRight © 2006-2010. 京ICP备06046876号 本站法律顾问:ITlaw-庄毅雄律师
返回顶部
客户服务:点击这里进行客户咨询 业务合作:点击这里洽谈业务合作 合作热线:010-68880146