WebDialog,谁想出来的真牛。

ContractedBlock.gif ExpandedBlockStart.gif WebDialog
 1None.gifusing System;
 2None.gifusing System.ComponentModel;
 3None.gifusing System.Text;
 4None.gifusing System.Collections;
 5None.gifusing System.Web.UI;
 6None.gifusing System.Web.UI.WebControls;
 7None.gif
 8None.gifnamespace PowerAsp.NET.Comtrols
 9ExpandedBlockStart.gifContractedBlock.gifdot.gif{
10ExpandedSubBlockStart.gifContractedSubBlock.gif    /**//// <summary>
11InBlock.gif    /// 
12InBlock.gif    /// </summary>
13ExpandedSubBlockEnd.gif    /// 

14InBlock.gif    [ToolboxItemFilter("System.Web.UI",ToolboxItemFilterType.Require),
15InBlock.gif    Designer(typeof(PowerAsp.NET.Designer.WebDialogDesigner))
16InBlock.gif    ]
17InBlock.gif    public class WebDialog:Component
18ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
19InBlock.gif        public WebDialog()
20ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
21ExpandedSubBlockEnd.gif        }

22InBlock.gif        private enum DialogMode
23ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
24InBlock.gif            None = 0,
25InBlock.gif            Alert = 1
26ExpandedSubBlockEnd.gif        }

27InBlock.gif        private Page _page = null;
28InBlock.gif        private bool _isHooked = false;
29InBlock.gif
30InBlock.gif        private const string SCP_SCRIPT_START = "\n<script language=\"javascript\">\n";
31InBlock.gif        private const string SCP_ALERT = "window.alert('{0}');\n";
32InBlock.gif        private const string SCP_SCRIPT_END = "</script>\n";
33InBlock.gif
34InBlock.gif        private string _mesage = null;
35InBlock.gif        private DialogMode _mode = DialogMode.None;
36InBlock.gif
37InBlock.gif        [Browsable(false),
38InBlock.gif        DefaultValue(null)
39InBlock.gif        ]
40InBlock.gif        public Page _Page
41ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
42InBlock.gif            get
43ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
44InBlock.gif                return _page;
45ExpandedSubBlockEnd.gif            }

46InBlock.gif            set
47ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
48InBlock.gif                _page = value;
49ExpandedSubBlockEnd.gif            }

50ExpandedSubBlockEnd.gif        }

51InBlock.gif
52InBlock.gif        private void HookedPagePreRender(object sender,EventArgs args)
53ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
54InBlock.gif            if(DialogMode.Alert ==  _mode)
55ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
56InBlock.gif                _page.RegisterStartupScript(this.GetHashCode().ToString(),
57InBlock.gif                    SCP_SCRIPT_START+string.Format(SCP_ALERT,_mesage)+SCP_SCRIPT_END);
58ExpandedSubBlockEnd.gif            }

59ExpandedSubBlockEnd.gif        }

60InBlock.gif
61InBlock.gif        private void HookPageLoad()
62ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
63InBlock.gif            if((!_isHooked) && (_page != null))
64ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
65InBlock.gif                _page.PreRender +=new EventHandler(HookedPagePreRender);
66InBlock.gif                _isHooked = true;
67ExpandedSubBlockEnd.gif            }

68ExpandedSubBlockEnd.gif        }

69InBlock.gif        public void ShowAlertDialog(string message)
70ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
71InBlock.gif            _mode = DialogMode.Alert;
72InBlock.gif            _mesage = message;
73InBlock.gif            HookPageLoad();
74ExpandedSubBlockEnd.gif        }

75ExpandedSubBlockEnd.gif    }

76ExpandedBlockEnd.gif}

77None.gif
ContractedBlock.gif ExpandedBlockStart.gif ComponentDesigner
 1None.gifusing System;
 2None.gifusing System.ComponentModel;
 3None.gifusing System.ComponentModel.Design;
 4None.gifusing System.Web.UI;
 5None.gifusing PowerAsp.NET.Comtrols;
 6None.gif
 7None.gifnamespace PowerAsp.NET.Designer
 8ExpandedBlockStart.gifContractedBlock.gifdot.gif{
 9ExpandedSubBlockStart.gifContractedSubBlock.gif    /**//// <summary>
10InBlock.gif    /// WebDialogDesigner 的摘要说明。
11ExpandedSubBlockEnd.gif    /// </summary>

12InBlock.gif    public class WebDialogDesigner:ComponentDesigner
13ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
14InBlock.gif        public override void Initialize(IComponent component)
15ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
16InBlock.gif            base.Initialize (component);//要先调,不知道为啥。
17InBlock.gif
18InBlock.gif
19InBlock.gif            IContainer container = Component.Site.Container;
20InBlock.gif            foreach(IComponent comp in container.Components)
21ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
22InBlock.gif                if(comp is Page)
23ExpandedSubBlockStart.gifContractedSubBlock.gif                dot.gif{
24InBlock.gif                    ((WebDialog)component)._Page = (Page)comp;
25ExpandedSubBlockEnd.gif                }

26ExpandedSubBlockEnd.gif            }
  
27ExpandedSubBlockEnd.gif        }

28InBlock.gif
29InBlock.gif        public WebDialogDesigner()
30ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
31ExpandedSubBlockEnd.gif        }

32ExpandedSubBlockEnd.gif    }

33ExpandedBlockEnd.gif}

34None.gif
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值