级联控件ID
2008-05-15 15:00 Kevin-wang 阅读(219) 评论(0) 编辑 收藏 举报代码如下
1 namespace DSKJ.WebUI.WebControls
2 {
3 public class ControlConverter : ControlIDConverter//StringConverter
4 {
5 protected override bool FilterControl(Control control)
6 {
7 if (control is DSDateTimePicker)
8 return true;
9 else
10 {
11 return false;
12 }
13
14 }
15 }
16
17
18 public class DSDateTimePicker : System.Web.UI.WebControls.TextBox
19 {
20 [Description("最小日期的DateTimePicker")]
21 [TypeConverter(typeof(ControlConverter)),IDReferenceProperty]
22 public string MinDateControl
23 {
24 get
25 {
26 return minDateControlID;
27 }
28 set
29 {
30 if (value != string.Empty)
31 MinDateTime = string.Empty;
32 minDateControlID = value;
33 }
34 }
35
36 /// <summary>
37 /// 重载父类的PreRender事件,设置属性
38 /// </summary>
39 /// <param name="e"></param>
40 protected override void OnPreRender(EventArgs e)
41 {
42 //获取正确的控件客户端ID
43 string _ControlID=GetControlRenderID(MinDateControl)
44
45 }
46
47 protected string GetControlRenderID(string name)
48 {
49 Control control = this.FindControl(name);
50 if (control == null)
51 {
52 return string.Empty;
53 }
54 return control.ClientID;
55 }
56 }
57
2 {
3 public class ControlConverter : ControlIDConverter//StringConverter
4 {
5 protected override bool FilterControl(Control control)
6 {
7 if (control is DSDateTimePicker)
8 return true;
9 else
10 {
11 return false;
12 }
13
14 }
15 }
16
17
18 public class DSDateTimePicker : System.Web.UI.WebControls.TextBox
19 {
20 [Description("最小日期的DateTimePicker")]
21 [TypeConverter(typeof(ControlConverter)),IDReferenceProperty]
22 public string MinDateControl
23 {
24 get
25 {
26 return minDateControlID;
27 }
28 set
29 {
30 if (value != string.Empty)
31 MinDateTime = string.Empty;
32 minDateControlID = value;
33 }
34 }
35
36 /// <summary>
37 /// 重载父类的PreRender事件,设置属性
38 /// </summary>
39 /// <param name="e"></param>
40 protected override void OnPreRender(EventArgs e)
41 {
42 //获取正确的控件客户端ID
43 string _ControlID=GetControlRenderID(MinDateControl)
44
45 }
46
47 protected string GetControlRenderID(string name)
48 {
49 Control control = this.FindControl(name);
50 if (control == null)
51 {
52 return string.Empty;
53 }
54 return control.ClientID;
55 }
56 }
57