WebDialog
1using System;
2using System.ComponentModel;
3using System.Text;
4using System.Collections;
5using System.Web.UI;
6using System.Web.UI.WebControls;
7
8namespace PowerAsp.NET.Comtrols
9{
10 /**//// <summary>
11 ///
12 /// </summary>
13 ///
14 [ToolboxItemFilter("System.Web.UI",ToolboxItemFilterType.Require),
15 Designer(typeof(PowerAsp.NET.Designer.WebDialogDesigner))
16 ]
17 public class WebDialog:Component
18 {
19 public WebDialog()
20 {
21 }
22 private enum DialogMode
23 {
24 None = 0,
25 Alert = 1
26 }
27 private Page _page = null;
28 private bool _isHooked = false;
29
30 private const string SCP_SCRIPT_START = "\n<script language=\"javascript\">\n";
31 private const string SCP_ALERT = "window.alert('{0}');\n";
32 private const string SCP_SCRIPT_END = "</script>\n";
33
34 private string _mesage = null;
35 private DialogMode _mode = DialogMode.None;
36
37 [Browsable(false),
38 DefaultValue(null)
39 ]
40 public Page _Page
41 {
42 get
43 {
44 return _page;
45 }
46 set
47 {
48 _page = value;
49 }
50 }
51
52 private void HookedPagePreRender(object sender,EventArgs args)
53 {
54 if(DialogMode.Alert == _mode)
55 {
56 _page.RegisterStartupScript(this.GetHashCode().ToString(),
57 SCP_SCRIPT_START+string.Format(SCP_ALERT,_mesage)+SCP_SCRIPT_END);
58 }
59 }
60
61 private void HookPageLoad()
62 {
63 if((!_isHooked) && (_page != null))
64 {
65 _page.PreRender +=new EventHandler(HookedPagePreRender);
66 _isHooked = true;
67 }
68 }
69 public void ShowAlertDialog(string message)
70 {
71 _mode = DialogMode.Alert;
72 _mesage = message;
73 HookPageLoad();
74 }
75 }
76}
77
1using System;
2using System.ComponentModel;
3using System.Text;
4using System.Collections;
5using System.Web.UI;
6using System.Web.UI.WebControls;
7
8namespace PowerAsp.NET.Comtrols
9{
10 /**//// <summary>
11 ///
12 /// </summary>
13 ///
14 [ToolboxItemFilter("System.Web.UI",ToolboxItemFilterType.Require),
15 Designer(typeof(PowerAsp.NET.Designer.WebDialogDesigner))
16 ]
17 public class WebDialog:Component
18 {
19 public WebDialog()
20 {
21 }
22 private enum DialogMode
23 {
24 None = 0,
25 Alert = 1
26 }
27 private Page _page = null;
28 private bool _isHooked = false;
29
30 private const string SCP_SCRIPT_START = "\n<script language=\"javascript\">\n";
31 private const string SCP_ALERT = "window.alert('{0}');\n";
32 private const string SCP_SCRIPT_END = "</script>\n";
33
34 private string _mesage = null;
35 private DialogMode _mode = DialogMode.None;
36
37 [Browsable(false),
38 DefaultValue(null)
39 ]
40 public Page _Page
41 {
42 get
43 {
44 return _page;
45 }
46 set
47 {
48 _page = value;
49 }
50 }
51
52 private void HookedPagePreRender(object sender,EventArgs args)
53 {
54 if(DialogMode.Alert == _mode)
55 {
56 _page.RegisterStartupScript(this.GetHashCode().ToString(),
57 SCP_SCRIPT_START+string.Format(SCP_ALERT,_mesage)+SCP_SCRIPT_END);
58 }
59 }
60
61 private void HookPageLoad()
62 {
63 if((!_isHooked) && (_page != null))
64 {
65 _page.PreRender +=new EventHandler(HookedPagePreRender);
66 _isHooked = true;
67 }
68 }
69 public void ShowAlertDialog(string message)
70 {
71 _mode = DialogMode.Alert;
72 _mesage = message;
73 HookPageLoad();
74 }
75 }
76}
77
ComponentDesigner
1using System;
2using System.ComponentModel;
3using System.ComponentModel.Design;
4using System.Web.UI;
5using PowerAsp.NET.Comtrols;
6
7namespace PowerAsp.NET.Designer
8{
9 /**//// <summary>
10 /// WebDialogDesigner 的摘要说明。
11 /// </summary>
12 public class WebDialogDesigner:ComponentDesigner
13 {
14 public override void Initialize(IComponent component)
15 {
16 base.Initialize (component);//要先调,不知道为啥。
17
18
19 IContainer container = Component.Site.Container;
20 foreach(IComponent comp in container.Components)
21 {
22 if(comp is Page)
23 {
24 ((WebDialog)component)._Page = (Page)comp;
25 }
26 }
27 }
28
29 public WebDialogDesigner()
30 {
31 }
32 }
33}
34
1using System;
2using System.ComponentModel;
3using System.ComponentModel.Design;
4using System.Web.UI;
5using PowerAsp.NET.Comtrols;
6
7namespace PowerAsp.NET.Designer
8{
9 /**//// <summary>
10 /// WebDialogDesigner 的摘要说明。
11 /// </summary>
12 public class WebDialogDesigner:ComponentDesigner
13 {
14 public override void Initialize(IComponent component)
15 {
16 base.Initialize (component);//要先调,不知道为啥。
17
18
19 IContainer container = Component.Site.Container;
20 foreach(IComponent comp in container.Components)
21 {
22 if(comp is Page)
23 {
24 ((WebDialog)component)._Page = (Page)comp;
25 }
26 }
27 }
28
29 public WebDialogDesigner()
30 {
31 }
32 }
33}
34