zhao
2021-07-19 8347f2fbddbd25369359dcb2da1233ac48a19fdc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
using System.Text;
using System.IO;
using System.Threading;
 
namespace HH.WMS.Utils
{
    public class ZScript
    {
        #region  Alert()
        /**/
        /// <summary>
        /// 简单弹出对话框功能
        /// 代码调用:
        /// UIHelper.Alert(this.Page,"OKOK");
        /// 
        /// 
        /// </summary>
        /// <param name="pageCurrent">
        /// 当前的页面
        /// </param>
        /// <param name="strMsg">
        /// 弹出信息的内容
        /// </param>
        public static void Alert(System.Web.UI.Page pageCurrent, string strMsg)
        {
            //Replace \n
            strMsg = strMsg.Replace("\n", "file://n/");
            //Replace \r
            strMsg = strMsg.Replace("\r", "file://r/");
            //Replace "
            strMsg = strMsg.Replace("\"", "\\\"");
            //Replace '
            strMsg = strMsg.Replace("\'", "\\\'");
 
            pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
                System.Guid.NewGuid().ToString(),
                "<script>window.alert('" + strMsg + "')</script>"
                );
 
            //以下代码是兼容.net1.1版本的,但到了2.0时代此API就过时了
            //pageCurrent.RegisterStartupScript(
            //    System.Guid.NewGuid().ToString(),
            //    "<script>window.alert('" + strMsg + "')</script>"
            //    );
        }
        public static void Alert(System.Web.UI.Page pageCurrent, string strMsg, string GoBackUrl)
        {
            //Replace \n
            strMsg = strMsg.Replace("\n", "file://n/");
            //Replace \r
            strMsg = strMsg.Replace("\r", "file://r/");
            //Replace "
            strMsg = strMsg.Replace("\"", "\\\"");
            //Replace '
            strMsg = strMsg.Replace("\'", "\\\'");
 
            pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
                System.Guid.NewGuid().ToString(),
                "<script>window.alert('" + strMsg + "');location='" + GoBackUrl + "'</script>"
                );
 
            //以下代码是兼容.net1.1版本的,但到了2.0时代此API就过时了
            //pageCurrent.RegisterStartupScript(
            //    System.Guid.NewGuid().ToString(),
            //    "<script>window.alert('" + strMsg + "')</script>"
            //    );
        }
 
 
        #endregion
 
        #region ScrollMessage
        /**/
        /// <summary>
        /// 简单的滚动信息栏
        /// 代码调用
        ///         UIHelper.ScrollMessage(this.Page, "滚动的内容");
        /// </summary>
        /// <param name="pageCurrent">
        /// 当前页面
        /// </param>
        /// <param name="strMsg">
        /// 要滚动的信息
        /// </param>
        public static string ScrollMessage(string strMsg)
        {
            //Replace \n
            strMsg = strMsg.Replace("\n", "file://n/");
            //Replace \r
            strMsg = strMsg.Replace("\r", "file://r/");
            //Replace "
            strMsg = strMsg.Replace("\"", "\\\"");
            //Replace '
            strMsg = strMsg.Replace("\'", "\\\'");
 
 
            StringBuilder sb = new StringBuilder();
            sb.Append("<MARQUEE>");
            sb.Append(strMsg);
            sb.Append("</MARQUEE>");
            return sb.ToString();
            //pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
            //        System.Guid.NewGuid().ToString(),sb.ToString());
        }
 
 
        /**/
        /// <summary>
        /// 指定滚动文字的详细方法
        /// 
        /// </summary>
        /// <param name="pageCurrent">
        /// 当前的页面
        /// </param>
        /// <param name="strMsg">
        /// 要滚动的文字
        /// </param>
        /// <param name="aligh">
        /// align:是设定活动字幕的位置,居左、居中、居右、靠上和靠下三种位置
        /// left center  right top bottom 
        /// </param>
        /// <param name="bgcolor">
        /// 用于设定活动字幕的背景颜色,一般是十六进制数。如#CCCCCC 
        /// </param>
        /// <param name="direction">
        /// 用于设定活动字幕的滚动方向是向左、向右、向上、向下
        /// left|right|up|down 
        /// </param>
        /// <param name="behavior">
        /// 用于设定滚动的方式,主要由三种方式:scroll slide和alternate
        /// 
        /// </param>
        /// <param name="height">
        /// 用于设定滚动字幕的高度
        /// 
        /// </param>
        /// <param name="hspace">
        /// 则设定滚动字幕的宽度
        /// </param>
        /// <param name="scrollamount">
        /// 用于设定活动字幕的滚动距离
        /// </param>
        /// <param name="scrolldelay">
        /// 用于设定滚动两次之间的延迟时间
        /// </param>
        /// <param name="width"></param>
        /// <param name="vspace">
        /// 分别用于设定滚动字幕的左右边框和上下边框的宽度
        /// 
        /// </param>
        /// <param name="loop">
        /// 用于设定滚动的次数,当loop=-1表示一直滚动下去,直到页面更新
        /// </param>
        /// <param name="MarqueejavascriptPath">
        /// 脚本的存放位置
        /// </param>
        /// <returns></returns>
        public static string ScrollMessage(System.Web.UI.Page pageCurrent, string strMsg, string aligh, string bgcolor,
                                    string direction, string behavior, string height, string hspace,
                                    string scrollamount, string scrolldelay, string width, string vspace, string loop,
                                    string MarqueejavascriptPath)
        {
            StreamReader sr = new StreamReader(pageCurrent.MapPath(MarqueejavascriptPath));
            StringBuilder sb = new StringBuilder();
            string line;
            try
            {
                while ((line = sr.ReadLine()) != null)
                {
                    sb.AppendLine(line);
 
                }
                sr.Close();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            sb.Replace("$strMessage", strMsg);
            sb.Replace("$aligh", aligh);
            sb.Replace("$bgcolor", bgcolor);
            sb.Replace("$direction", direction);
            sb.Replace("$behavior", behavior);
            sb.Replace("$height", height);
            sb.Replace("$hspace", hspace);
            sb.Replace("$scrollamount", scrollamount);
            sb.Replace("$scrolldelay", scrolldelay);
            sb.Replace("$width", width);
            sb.Replace("$vspace", vspace);
            sb.Replace("$loop", loop);
            //pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
            //            System.Guid.NewGuid().ToString(), sb.ToString());
            return sb.ToString();
        }
 
        #endregion
 
        #region  Redirect()
        /**/
        /// <summary>
        /// Add the javascript method to redirect page on client
        /// Created : Wang Hui, May 18,2006
        /// Modified: 
        /// </summary>
        /// <param name="pageCurrent"></param>
        /// <param name="strPage"></param>
        public static void Redirect(System.Web.UI.Page pageCurrent, string strPage)
        {
            pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
                    System.Guid.NewGuid().ToString(),
                    "<script>window.location.href='" + strPage + "'</script>"
                    );
 
            //以下方法是兼容1.1的,2.0过时
            //pageCurrent.RegisterStartupScript(
            //    System.Guid.NewGuid().ToString(),
            //    "<script>window.location.href='" + strPage + "'</script>"
            //    );
        }
        /**/
        /// <summary>
        /// 主要用于跳出带有框架的页面
        /// </summary>
        /// <param name="pageCurrent">当前页面如this.page</param>
        /// <param name="strPage">要跳出的页面</param>
        public static void RedirectFrame(System.Web.UI.Page pageCurrent, string strPage)
        {
            pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
                    System.Guid.NewGuid().ToString(),
                    "<script>window.top.location.href='" + strPage + "'</script>"
                    );
 
            //以下方法是兼容1.1的,2.0过时
            //pageCurrent.RegisterStartupScript(
            //    System.Guid.NewGuid().ToString(),
            //    "<script>window.location.href='" + strPage + "'</script>"
            //    );
        }
 
        #endregion
 
        #region AddConfirm
        /**/
        /// <summary>
        /// Add the confirm message to button
        /// Created : GuangMing Chu 1,1,2007
        /// Modified: GuangMing Chu 1,1,2007
        /// Modified: GuangMing Chu 1,1,2007
        /// 代码调用:
        ///    UIHelper.AddConfirm(this.Button1, "真的要删了??");
        /// 点确定按钮就会执行事件中的代码,点取消不会
        /// </summary>
        /// <param name="button">The control, must be a button</param>
        /// <param name="strMsg">The popup message</param>
        public static void AddConfirm(System.Web.UI.WebControls.Button button, string strMsg)
        {
            strMsg = strMsg.Replace("\n", "file://n/");
            strMsg = strMsg.Replace("\r", "file://r/");
            strMsg = strMsg.Replace("\"", "\\\"");
            strMsg = strMsg.Replace("\'", "\\\'");
            button.Attributes.Add("onClick", "return confirm('" + strMsg + "')");
        }
 
        /**/
        /// <summary>
        /// Add the confirm message to button
        /// Created : GuangMing Chu, 1 1,2007
        /// Modified: GuangMing Chu, 1 1,2007
        /// Modified:
        /// 代码调用:
        ///       UIHelper.AddConfirm(this.Button1, "真的要删了??");
        /// 点确定按钮就会执行事件中的代码,点取消不会
        ///      
        /// </summary>
        /// <param name="button">The control, must be a button</param>
        /// <param name="strMsg">The popup message</param>
        public static void AddConfirm(System.Web.UI.WebControls.ImageButton button, string strMsg)
        {
            strMsg = strMsg.Replace("\n", "file://n/");
            strMsg = strMsg.Replace("\r", "file://r/");
            strMsg = strMsg.Replace("\"", "\\\"");
            strMsg = strMsg.Replace("\'", "\\\'");
            button.Attributes.Add("onClick", "return confirm('" + strMsg + "')");
        }
 
        /**/
        /// <summary>
        /// Add the confirm message to one column of gridview
        /// 代码调用:
        ///         UIHelper myHelp = new UIHelper();
        ///         myHelp.AddConfirm(this.GridView1,1, "ok");
        /// 请使用时注意,此方法的调用必须实例化,调用
        /// </summary>
        /// <param name="grid">The control, must be a GridView</param>
        /// <param name="intColIndex">The column index. It's usually the column which has the "delete" button.</param>
        /// <param name="strMsg">The popup message</param>
        public static void AddConfirm(System.Web.UI.WebControls.GridView grid, int intColIndex, string strMsg)
        {
            strMsg = strMsg.Replace("\n", "file://n/");
            strMsg = strMsg.Replace("\r", "file://r/");
            strMsg = strMsg.Replace("\"", "\\\"");
            strMsg = strMsg.Replace("\'", "\\\'");
            for (int i = 0; i < grid.Rows.Count; i++)
            {
                grid.Rows[i].Cells[intColIndex].Attributes.Add("onclick", "return confirm('" + strMsg + "')");
            }
        }
        #endregion
 
        #region AddShowDialog
        /**/
        /// <summary>
        /// Add the javascript method showModalDialog to button
        /// 为Button按钮加入一个弹出窗体对话框
        /// 代码调用
        ///         UIHelper.AddShowDialog(this.Button1, "www.sina.com.cn", 300, 300);
        /// 
        /// 
        /// 
        /// </summary>
        /// <param name="button">The control, must be a button</param>
        /// <param name="strUrl">The page url, including query string</param>
        /// <param name="intWidth">Width of window</param>
        /// <param name="intHeight">Height of window</param>
        public static void AddShowDialog(System.Web.UI.WebControls.Button button, string strUrl, int intWidth, int intHeight)
        {
            string strScript = "";
            strScript += "var strFeatures = 'dialogWidth=" + intWidth.ToString() + "px;dialogHeight=" + intHeight.ToString() + "px;center=yes;help=no;status=no';";
            strScript += "var strName ='';";
 
            if (strUrl.Substring(0, 1) == "/")
            {
                strUrl = strUrl.Substring(1, strUrl.Length - 1);
            }
 
            strUrl = BaseUrl + "DialogFrame.aspx?URL=" + strUrl;
 
            strScript += "window.showModalDialog(\'" + strUrl + "\',window,strFeatures);return false;";
 
            button.Attributes.Add("onClick", strScript);
        }
        #endregion
 
        #region  AddShowDialog
        /**/
        /// <summary>
        /// Add the javascript method showModalDialog to button
        /// </summary>
        /// <param name="button">The control, must be a link button</param>
        /// <param name="strUrl">The page url, including query string</param>
        /// <param name="intWidth">Width of window</param>
        /// <param name="intHeight">Height of window</param>
        public static void AddShowDialog(System.Web.UI.WebControls.LinkButton button, string strUrl, int intWidth, int intHeight)
        {
            string strScript = "";
            strScript += "var strFeatures = 'dialogWidth=" + intWidth.ToString() + "px;dialogHeight=" + intHeight.ToString() + "px;center=yes;help=no;status=no';";
            strScript += "var strName ='';";
 
            if (strUrl.Substring(0, 1) == "/")
            {
                strUrl = strUrl.Substring(1, strUrl.Length - 1);
            }
 
            strUrl = BaseUrl + "DialogFrame.aspx?URL=" + strUrl;
 
            strScript += "window.showModalDialog(\'" + strUrl + "\',strName,strFeatures);return false;";
 
            button.Attributes.Add("onClick", strScript);
        }
        #endregion
 
        #region  AddShowDialog
        /**/
        /// <summary>
        /// Add the javascript method showModalDialog to button
        /// </summary>
        /// <param name="button">The control, must be a button</param>
        /// <param name="strUrl">The page url, including query string</param>
        /// <param name="intWidth">Width of window</param>
        /// <param name="intHeight">Height of window</param>
        public static void AddShowDialog(System.Web.UI.WebControls.ImageButton button, string strUrl, int intWidth, int intHeight)
        {
            string strScript = "";
            strScript += "var strFeatures = 'dialogWidth=" + intWidth.ToString() + "px;dialogHeight=" + intHeight.ToString() + "px;center=yes;help=no;status=no';";
            strScript += "var strName ='';";
 
            if (strUrl.Substring(0, 1) == "/")
            {
                strUrl = strUrl.Substring(1, strUrl.Length - 1);
            }
 
            strUrl = BaseUrl + "DialogFrame.aspx?URL=" + strUrl;
 
            strScript += "window.showModalDialog(\'" + strUrl + "\',window,strFeatures);return false;";
 
            button.Attributes.Add("onClick", strScript);
        }
        #endregion
 
        #region ClearTextBox
        /**/
        /// <summary>
        /// 将选定的TextBox值清空
        /// </summary>
        /// <param name="myTextBox"></param>
        public static void ClearTextBox(System.Web.UI.WebControls.TextBox myTextBox)
        {
            myTextBox.Attributes.Add("onclick", "this.value=''");
        }
        #endregion
 
        #region OpenWindow
        /**/
        /// <summary>
        /// Use "window.open" to popup the window
        /// Created : Wang Hui, Feb 24,2006
        /// Modified: Wang Hui, Feb 24,2006
        /// 打开窗体的对话框功能
        /// 代码调用:
        /// 
        /// 
        ///         UIHelper.OpenWindow(this.Page, "www.sina.com.cn", 400, 300);
        ///         UIHelper.ShowDialog(this.Page, "lsdjf.com", 300, 200);
        /// 
        /// 
        /// 
        /// </summary>
        /// <param name="strUrl">The url of window, start with "/", not "http://"</param>
        /// <param name="intWidth">Width of popup window</param>
        /// <param name="intHeight">Height of popup window</param>
        public static void OpenWindow(System.Web.UI.Page pageCurrent, string strUrl, int intWidth, int intHeight, int intLeft, int intTop, string WinName)
        {
            #region 老版本
            //string strScript = "";
            //strScript += "var strFeatures = 'width:" + intWidth.ToString() + "px;height:" + intHeight.ToString() + "px';";
            //strScript += "var strName ='__WIN';";
            /**/
            ////strScript += "alert(strFeatures);";
 
            ////--- Add by Wang Hui on Feb 27
            //if (strUrl.Substring(0, 1) == "/")
            //{
            //    strUrl = strUrl.Substring(1, strUrl.Length - 1);
            //}
            /**/
            ////--- End Add by Wang Hui on Feb 27
 
            //strUrl = BaseUrl + strUrl;
 
            //strScript += "window.open(\"" + strUrl + "\",strName,strFeatures);";
 
            //pageCurrent.RegisterStartupScript(
            //    System.Guid.NewGuid().ToString(),
            //    "<script language='javascript'>" + strScript + "</script>"
            //    );
 
 
            //pageCurrent.RegisterStartupScript(
            //    System.Guid.NewGuid().ToString(),
            //    "<script language='javascript'>" + strScript + "</script>"
            //    );
            #endregion
 
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat(@"myleft={0};mytop={1};", intLeft.ToString(), intTop.ToString());
            sb.AppendLine();
            sb.AppendFormat(@"settings='top=' + mytop + ',left=' + myleft + ',width={0},height={1},location=no,directories=no,menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,fullscreen=no';",
                             intWidth.ToString(), intHeight.ToString());
            sb.AppendLine();
            sb.AppendFormat(@"window.open('{0}','{1}', settings);", strUrl, WinName);
 
            pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
                    System.Guid.NewGuid().ToString(),
                    "<script language='javascript'>" + sb.ToString() + "</script>"
                    );
 
        }
        #endregion
 
        #region ShowDialog
        /**/
        /// <summary>
        /// Use "window.showModalDialog" to show the dialog
        /// Created : Wang Hui, Feb 24,2006
        /// Modified: Wang Hui, Feb 27,2006
        /// 此窗体是模式窗体,和C/S结构中的模式窗体是一致的
        /// </summary>
        /// <param name="strUrl">The url of dialog, start with "/", not "http://"</param>
        /// <param name="intWidth">Width of dialog</param>
        /// <param name="intHeight">Height of dialog</param>
        public static void ShowDialog(System.Web.UI.Page pageCurrent, string strUrl, int intWidth, int intHeight)
        {
            string strScript = "";
            strScript += "var strFeatures = 'dialogWidth=" + intWidth.ToString() + "px;dialogHeight=" + intHeight.ToString() + "px;center=yes;help=no;status=no';";
            strScript += "var strName ='';";
 
            //--- Add by Wang Hui on Feb 27 
            if (strUrl.Substring(0, 1) == "/")
            {
                strUrl = strUrl.Substring(1, strUrl.Length - 1);
            }
            //--- End Add by Wang Hui on Feb 27
 
            strUrl = BaseUrl + "DialogFrame.aspx?URL=" + strUrl;
 
            //strScript += "window.showModalDialog(\"" + strUrl + "\",strName,strFeatures);";
            strScript += "window.showModalDialog(\"" + strUrl + "\",window,strFeatures); ";
 
            pageCurrent.ClientScript.RegisterStartupScript(
                pageCurrent.GetType(), System.Guid.NewGuid().ToString(),
                "<script language='javascript'>" + strScript + "</script>"
                );
        }
        #endregion
 
        #region CloseWindows
        /**/
        /// <summary>
        /// 关闭窗体,没有任何提示的关闭窗体
        /// </summary>
        /// <param name="pageCurrent"></param>
        public static void CloseWindows(System.Web.UI.Page pageCurrent)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<script>window.opener=null;window.close();</script>");
            pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
                System.Guid.NewGuid().ToString(), sb.ToString());
        }
 
 
 
        /**/
        /// <summary>
        /// 有提示信息的关闭窗体
        /// </summary>
        /// <param name="pageCurrent"></param>
        /// <returns></returns>
        public static void CloseWindows(System.Web.UI.Page pageCurrent, string strMessage)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<script>if(confirm(\"" + strMessage + "\")==true){window.close();}</script>");
            pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
                                System.Guid.NewGuid().ToString(), sb.ToString());
        }
        /**/
        /// <summary>
        /// 有等待时间的关闭窗体
        /// </summary>
        /// <param name="pageCurrent"></param>
        /// <param name="WaitTime">等待时间,以毫秒为记量单位</param>
        public static void CloseWindows(System.Web.UI.Page pageCurrent, int WaitTime)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<script language=\"javascript\">");
            //加入此行功能后没有提提示功能
            sb.Append("window.opener=null;");
            sb.Append("setTimeout");
            sb.Append("(");
            sb.Append("'");
            sb.Append("window.close()");
            sb.Append("'");
 
            sb.Append(",");
            sb.Append(WaitTime.ToString());
            sb.Append(")");
            sb.Append("</script>");
            pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
                        System.Guid.NewGuid().ToString(), sb.ToString());
 
        }
        #endregion
 
        #region  ShowStatusBar
        public static void ShowStatus(System.Web.UI.Page pageCurrent, string StatusString)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<script language=\"javascript\">");
            sb.Append("window.status=");
            sb.Append("\"");
            sb.Append(StatusString);
            sb.Append("\"");
            sb.Append("</script>");
            pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
                System.Guid.NewGuid().ToString(), sb.ToString());
        }
        #endregion
 
        #region PlayMediaFile
        /**/
        /// <summary>
        /// 调用Media播放mp3或电影文件
        /// </summary>
        /// <param name="pageCurrent">
        /// 当前的页面对象
        /// </param>
        /// <param name="PlayFilePath">
        /// 播放文件的位置
        /// </param>
        /// <param name="MediajavascriptPath">
        /// Mediajavascript的脚本位置
        /// </param>
        /// <param name="enableContextMenu">
        /// 是否可以使用右键
        /// 指定是否使右键菜单有效
        /// 指定右键是否好用,默认为0不好用
        /// 指定为1时就是好用
        /// </param>
        /// <param name="uiMode">
        /// 播放器的大小显示
        /// None,mini,或full,指定Windows媒体播放器控制如何显示
        /// </param>
        public static string PlayMediaFile(System.Web.UI.Page pageCurrent,
                        string PlayFilePath, string MediajavascriptPath,
                        string enableContextMenu, string uiMode)
        {
            StreamReader sr = new StreamReader(pageCurrent.MapPath(MediajavascriptPath));
            StringBuilder sb = new StringBuilder();
            string line;
            try
            {
                while ((line = sr.ReadLine()) != null)
                {
                    sb.AppendLine(line);
 
                }
                sr.Close();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            sb.Replace("$URL", pageCurrent.MapPath(PlayFilePath));
            sb.Replace("$enableContextMenu", enableContextMenu);
            sb.Replace("$uiMode", uiMode);
            //pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
            //            System.Guid.NewGuid().ToString(), sb.ToString());
            return sb.ToString();
        }
        #endregion
 
        #region ShowProgBar
        /**/
        /// <summary>
        /// 主要实现进度条的功能,这段代码的调用就要实现进度的调度
        /// 实现主要过程
        /// default.aspx.cs是调用页面
        /// 放入page_load事件中
        ///            UIHelper myUI = new UIHelper();
        ///            Response.Write(myUI.ShowProgBar(this.Page,"../JS/progressbar.htm"));
        ///            Thread thread = new Thread(new ThreadStart(ThreadProc));
        ///            thread.Start();
        ///            LoadData();//load数据 
        ///            thread.Join();
        ///            Response.Write("OK");
        /// 
        /// 其中ThreadProc方法为
        ///     public void ThreadProc()
        ///    {
        ///    string strScript = "<script>setPgb('pgbMain','{0}');</script>";
        ///    for (int i = 0; i <= 100; i++)
        ///     {
        ///        System.Threading.Thread.Sleep(10);
        ///        Response.Write(string.Format(strScript, i));
        ///        Response.Flush();
        ///     }
        ///    }
        /// 其中LoadData()
        ///     public void LoadData()
        ///        {
        ///            for (int m = 0; m < 900; m++)
        ///            {
        ///                for (int i = 0; i < 900; i++)
        ///                {
        ///
        ///                }
        ///            }
        ///        }
        /// 
        /// </summary>
        /// <param name="pageCurrent"></param>
        /// <param name="ShowProgbarScript"></param>
        /// <returns></returns>
        public static string ShowProgBar(System.Web.UI.Page pageCurrent, string ShowProgbarScript)
        {
            StreamReader sr = new StreamReader(pageCurrent.MapPath(ShowProgbarScript), System.Text.Encoding.Default);
            StringBuilder sb = new StringBuilder();
            string line;
            try
            {
                while ((line = sr.ReadLine()) != null)
                {
                    sb.AppendLine(line);
 
                }
                sr.Close();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            //pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
            //            System.Guid.NewGuid().ToString(), sb.ToString());
            return sb.ToString();
        }
        #endregion
 
        #region fixedHeader
        public static string fixedHeader()
        {
            StringBuilder s = new StringBuilder();
            s.Append(@"<table width='100%' border='1' cellspacing='0' style='MARGIN-TOP:-2px'>");
            s.Append(@"<TR class='fixedHeaderTr' style='BACKGROUND:navy;COLOR:white'>");
            s.Append(@"<TD nowrap>Header A</TD>");
            s.Append(@"<TD nowrap>Header B</TD>");
            s.Append(@"<TD nowrap>Header C</TD>");
            s.Append(@"</TR>");
            for (int m = 0; m < 100; m++)
            {
                s.Append(@"<TR>");
                s.Append(@"<TD>A").Append(m).Append("</TD>");
                s.Append(@"<TD>B").Append(m).Append("</TD>");
                s.Append(@"<TD>C").Append(m).Append("</TD>");
                s.Append(@"</TR>");
            }
            s.Append(@"</table>");
            return s.ToString();
        }
        #endregion
 
        #region refreshPage
        public static void refreshPage(System.Web.UI.Page pageCurrent)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<script language=\"javascript\">");
            sb.Append("window.location.reload(true);");
            sb.Append("</script>");
            pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
                        System.Guid.NewGuid().ToString(), sb.ToString());
 
        }
        #endregion
 
        #region Page_revealTrans
        //进入页面<meta http-equiv="Page-Enter" content="revealTrans(duration=x, transition=y)">
        //推出页面<meta http-equiv="Page-Exit" content="revealTrans(duration=x, transition=y)"> 
        //这个是页面被载入和调出时的一些特效。duration表示特效的持续时间,以秒为单位。transition表示使用哪种特效,取值为1-23:
        //  0 矩形缩小 
        //  1 矩形扩大 
        //  2 圆形缩小
        //  3 圆形扩大 
        //  4 下到上刷新 
        //  5 上到下刷新
        //  6 左到右刷新 
        //  7 右到左刷新 
        //  8 竖百叶窗
        //  9 横百叶窗 
        //  10 错位横百叶窗 
        //  11 错位竖百叶窗
        //  12 点扩散 
        //  13 左右到中间刷新 
        //  14 中间到左右刷新
        //  15 中间到上下
        //  16 上下到中间 
        //  17 右下到左上
        //  18 右上到左下 
        //  19 左上到右下 
        //  20 左下到右上
        //  21 横条 
        //  22 竖条 
        //  23 以上22种随机选择一种
 
        public static string Page_revealTrans(System.Web.UI.Page currentPage, string duration,
                                       string transition)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<meta http-equiv=\"Page-Enter\"");
            sb.Append("content=\"");
            sb.Append("revealTrans(duration=" + duration);
            sb.Append(",transition=" + transition);
            sb.Append(")\">");
            //currentPage.ClientScript.RegisterStartupScript(currentPage.GetType(),
            //        System.Guid.NewGuid().ToString(), sb.ToString());
            return sb.ToString();
        }
        #endregion
 
        /// <summary>
        /// 显示一段自定义的输出代码
        /// </summary>
        /// <param name="page">页面指针,一般为This</param>
        public static void RegisterStartupScript(System.Web.UI.Page page, string script)
        {
            var sb = new StringBuilder();
            sb.Append("<script type=\"text/javascript\"> ");
            sb.Append(script.Trim());
            sb.Append("</script>");
            page.ClientScript.RegisterStartupScript(page.GetType(), page.GetType().Name, sb.ToString());
        }
 
        public static void RegisterClientScriptBlock(System.Web.UI.Page page, string script)
        {
            var sb = new StringBuilder();
            sb.Append("<script type=\"text/javascript\"> ");
            sb.Append(script.Trim());
            sb.Append("</script>");
            page.ClientScript.RegisterClientScriptBlock(page.GetType(), page.GetType().Name, sb.ToString());
        }
        
 
        /**/
        /// <summary>
        /// 调用客户端JavaScript函数
        /// </summary>
        /// <param name="page">页面指针,一般为This</param>
        /// <param name="scriptName">函数名,带参数,如:FunA(1);</param>
        public static void CallClientScript(System.Web.UI.Page page, string scriptName)
        {
            String csname = "PopupScript";
            Type cstype = page.GetType();
            System.Web.UI.ClientScriptManager cs = page.ClientScript;
            if (!cs.IsStartupScriptRegistered(cstype, csname))
            {
                String cstext = scriptName;
                cs.RegisterStartupScript(cstype, csname, cstext, true);
            }
        }
 
        /**/
        /// <summary>
        /// 弹出对话框(弹出对话框后css会失效)
        /// </summary>
        /// <param name="message">提示信息</param>
        public static void ShowMessage(string message)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<script language=\"javascript\"> \n");
            sb.Append("alert(\"" + message.Trim() + "\"); \n");
            sb.Append("</script>");
 
            System.Web.HttpContext.Current.Response.Write(sb.ToString());
        }
 
        /**/
        /// <summary>
        /// 弹出对话框(不影响css样式)
        /// </summary>
        /// <param name="page">页面指针,一般为this</param>
        /// <param name="scriptKey">脚本键,唯一</param>
        /// <param name="message">提示信息</param>
        public static void ShowMessage(System.Web.UI.Page page, string scriptKey, string message)
        {
            System.Web.UI.ClientScriptManager csm = page.ClientScript;
            if (!csm.IsClientScriptBlockRegistered(scriptKey))
            {
                string strScript = "alert('" + message + "');";
                csm.RegisterClientScriptBlock(page.GetType(), scriptKey, strScript, true);
            }
        }
 
        /**/
        /// <summary>
        /// 为控件添加确认提示对话框
        /// </summary>
        /// <param name="Control">需要添加提示的对话框</param>
        /// <param name="message">提示信息</param>
        public static void ShowConfirm(System.Web.UI.WebControls.WebControl Control, string message)
        {
            Control.Attributes.Add("onclick", "return confirm('" + message + "');");
        }
 
        /**/
        /**/
        /**/
        /// <summary>
        /// 显示一个弹出窗口,并转向目标页(导航)
        /// </summary>
        public static void ShowAndRedirect(string message, string url)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<script language=\"javascript\"> \n");
            sb.Append("alert(\"" + message.Trim() + "\"); \n");
            sb.Append("window.location.href=\"" + url.Trim().Replace("'", "") + "\";\n");
            sb.Append("</script>");
 
            System.Web.HttpContext.Current.Response.Write(sb.ToString());
        }
 
        /**/
        /// <summary>
        /// 显示一个弹出窗口,重新加载当前页
        /// </summary>
        public static void ShowAndReLoad(string message)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<script language=\"javascript\"> \n");
            sb.Append("alert(\"" + message.Trim() + "\"); \n");
            sb.Append("window.location.href=window.location.href;\n");
            sb.Append("</script>");
 
            System.Web.HttpContext.Current.Response.Write(sb.ToString());
        }
 
        /**/
        /// <summary>
        /// 显示一个弹出窗口,刷新当前页(危险的,有可能陷入死循环)
        /// </summary>
        public static void ShowAndRefresh(string message)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<script language=\"javascript\"> \n");
            sb.Append("alert(\"" + message.Trim() + "\"); \n");
            sb.Append("document.execCommand('Refresh')");
            sb.Append("</script>");
 
            System.Web.HttpContext.Current.Response.Write(sb.ToString());
        }
 
        /**/
        /// <summary>
        /// 显示一个弹出窗口,并关闭当前页
        /// </summary>
        /// <param name="message"></param>
        public static void ShowAndClose(string message)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("<script language=\"javascript\">\n");
            sb.Append("alert(\"" + message.Trim() + "\"); \n");
            sb.Append("window.close();\n");
            sb.Append("</script>\n");
            System.Web.HttpContext.Current.Response.Write(sb.ToString());
        }
 
        /**/
        /// <summary>
        /// 显示一个弹出窗口,并转向上一页
        /// </summary>
        /// <param name="message"></param>
        public static void ShowPre(string message)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<script language=\"javascript\"> \n");
            sb.Append("alert(\"" + message.Trim() + "\"); \n");
            sb.Append("var p=document.referrer; \n");
            sb.Append("window.location.href=p;\n");
            sb.Append("</script>");
 
            System.Web.HttpContext.Current.Response.Write(sb.ToString());
        }
 
        /**/
        /// <summary>
        /// 页面重载
        /// </summary>
        public static void ReLoad()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<script language=\"javascript\"> \n");
            sb.Append("window.location.href=window.location.href;");
            sb.Append("</script>");
            System.Web.HttpContext.Current.Response.Write(sb.ToString());
 
        }
 
        /**/
        /// <summary>
        /// 重定向
        /// </summary>
        public static void Redirect(string url)
        {
            //string path = "http://" + System.Web.HttpContext.Current.Request.Url.Host + ":" + System.Web.HttpContext.Current.Request.Url.Port + url;
            string path = "http://" + System.Web.HttpContext.Current.Request.Url.Host + url;
            StringBuilder sb = new StringBuilder();
            sb.Append("<script language=\"javascript\"> \n");
            sb.Append(string.Format("window.location.href='{0}';", @path.Replace("'", "")));
            sb.Append("</script>");
 
            System.Web.HttpContext.Current.Response.Write(sb.ToString());
        }
 
        #region  Static Property Get BaseUrl(静态属性获取URL地址)
        /**/
        /// <summary>
        /// 这个静态属性的调用必须用以下代码方法调用
        /// 代码调用:
        /// Response.Write(UIHelper.BaseUrl);
        /// </summary>
        public static string BaseUrl
        {
            get
            {
                //strBaseUrl用于存储URL地址
                string strBaseUrl = "";
                //获取当前HttpContext下的地址
                strBaseUrl += "http://" + HttpContext.Current.Request.Url.Host;
                //如果端口不是80的话,那么加入特殊端口
                if (HttpContext.Current.Request.Url.Port.ToString() != "80")
                {
                    strBaseUrl += ":" + HttpContext.Current.Request.Url.Port;
                }
                strBaseUrl += HttpContext.Current.Request.ApplicationPath;
 
                return strBaseUrl + "/";
            }
        }
        #endregion
    }
}