Asp.net源码专业站
首页->门户综合->特瑞飞家教信息平台源码>>Controls/SubmitTextbox.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:特瑞飞家教信息平台源码
当前文件:文件类型 HomeTeachingNet/Controls/SubmitTextbox.cs[3K,2009-6-12 11:44:15]打开代码结构图
普通视图
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Web; 5using System.Web.UI; 6using System.Web.UI.WebControls; 7using System.Web.UI.WebControls.WebParts; 8using System.Web.UI.HtmlControls; 9using System.ComponentModel; 10using System.Collections; 11 12namespace Controls 13{ 14 /// <summary> 15 /// SubmitTextbox 的摘要说明 16 /// </summary> 17 public class SubmitTextbox : TextBox 18 { 19 [TypeConverter(typeof(SubmitableControlConvertor)), DefaultValue(""), Category("Behavior")] 20 public string SubmitControl 21 { 22 get 23 { 24 object ret = this.ViewState["SubmitControl"]; 25 if (ret != null) 26 { 27 return (string)ret; 28 } 29 return string.Empty; 30 } 31 set 32 { 33 this.ViewState["SubmitControl"] = value; 34 } 35 } 36 37 protected override void AddAttributesToRender(HtmlTextWriter writer) 38 { 39 base.AddAttributesToRender(writer); 40 if (this.SubmitControl.Length > 0) 41 { 42 Control con = FindControl(SubmitControl); 43 if (con != null) 44 { 45 string script = "if(event.keyCode == 13){document.getElementById('" + con.ClientID + "').click(); event.returnValue=false;}"; 46 writer.AddAttribute("onkeydown", script); 47 } 48 } 49 } 50 } 51 52 public class SubmitableControlConvertor : StringConverter 53 { 54 private object[] GetControls(IContainer container) 55 { 56 ComponentCollection components = container.Components; 57 ArrayList ret = new ArrayList(); 58 foreach (IComponent control in components) 59 { 60 if (!(control is Button || control is LinkButton || control is ImageButton)) 61 { 62 continue; 63 } 64 Control button = (Control)control; 65 if ((button.ID != null) && (button.ID.Length != 0)) 66 { 67 ret.Add(string.Copy(button.ID)); 68 } 69 } 70 ret.Sort(Comparer.Default); 71 return ret.ToArray(); 72 } 73 74 75 public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) 76 { 77 if ((context != null) && (context.Container != null)) 78 { 79 object[] controls = this.GetControls(context.Container); 80 if (controls != null) 81 { 82 return new TypeConverter.StandardValuesCollection(controls); 83 } 84 } 85 return null; 86 } 87 88 public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) 89 { 90 return false; 91 } 92 93 public override bool GetStandardValuesSupported(ITypeDescriptorContext context) 94 { 95 return true; 96 } 97 } 98 99}
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:特瑞飞家教信息平台源码
51Aspx.com 版权所有 CopyRight © 2006-2010. 京ICP备06046876号 本站法律顾问:ITlaw-庄毅雄律师
返回顶部
客户服务:点击这里进行客户咨询 业务合作:点击这里洽谈业务合作 合作热线:010-68880146