![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
1
using System;
2
using System.Data;
3
using System.Configuration;
4
using System.Web;
5
using System.Web.Security;
6
using System.Web.UI;
7
using System.Web.UI.WebControls;
8
using System.Web.UI.WebControls.WebParts;
9
using System.Web.UI.HtmlControls;
10
using System.Text;
11
using System.Collections;
12![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
13
using System.Collections.Generic;
14![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
15![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
16![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**//// <summary>
17
/// Function 的摘要说明
18![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
19
/// </summary>
20
public class Fun
21![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
22
public Fun()
23![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
24
//
25
// TODO: 在此处添加构造函数逻辑
26
//
27![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
28
}
29![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
30![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
31
/// 判断输入字符是否超出限制
32
/// </summary>
33
/// <param name="inputStr">输入的字符串</param>
34
/// <param name="maxLength">数据库允许的最大字符长度</param>
35
public static int InputLimit(string inputStr, int maxLength)
36![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
37
int len = 0;
38
for (int i = 0; i < inputStr.Trim().Length; ++i)
39![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
40
len += (inputStr[i] > 255) ? 2 : 1; //汉字占两个字节,字母站一个字节
41![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
42
}
43
if (len > maxLength)
44![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
45
return 1;
46
}
47
else
48![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
49
return -1;
50
}
51
}
52![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
53![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
54
/// 若Session过期,则跳至登录页面
55
/// </summary>
56
public static void SessionOut()
57![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
58
if (HttpContext.Current.Session["UserId"] == null)
59![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
60
AlertReload("登录超时,请重新登录!", "http://www.cnblogs.com/login3.aspx");
61
}
62
}
63![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
64![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
65
/// 取得GridView 的主健
66![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
67
/// </summary>
68
/// <param name="AGridView"></param>
69
/// <param name="e"></param>
70
/// <returns></returns>
71
public static string GetGridViewID(object sender, GridViewCommandEventArgs e)
72![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
73
GridView FGridView = new GridView();
74
FGridView = (GridView)sender;
75
return FGridView.DataKeys[Convert.ToInt32(e.CommandArgument)].Value.ToString();
76
}
77![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
78![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
79
/// 取得GridView 的主健
80![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
81
/// </summary>
82
/// <param name="AGridView"></param>
83
/// <param name="e"></param>
84
/// <returns></returns>
85
public static string GetGridViewID(GridView AGridView, GridViewRowEventArgs e)
86![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
87
return AGridView.DataKeys[e.Row.RowIndex].Value.ToString();
88
}
89![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
90![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
91![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
92
/// 取得当前行
93![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
94
/// </summary>
95
/// <returns></returns>
96
public static int GetIndesByColName(GridView AGridView,string colName)
97![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
98
DataControlField oColField;
99
int ndx = 0;
100![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
101
foreach (DataControlField oCol in AGridView.Columns)
102![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
103
if (oCol.GetType() == typeof(BoundField))
104![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
105
BoundField bfield = (BoundField)oCol;
106
if (bfield.DataField.ToUpper() == colName.ToUpper())
107![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
108
break;
109
}
110
}
111
ndx++;
112
}
113
return ndx;
114![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
115
116
}
117![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
118![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
119
/// </summary>
120
/// <param name="AGridView"></param>
121
/// <param name="e"></param>
122
/// <returns></returns>
123
public static GridViewRow GetGridViewRow(GridView AGridView, GridViewCommandEventArgs e)
124![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
125
int index = Convert.ToInt32(e.CommandArgument);
126
return AGridView.Rows[index];
127
}
128![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
129![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
130
/// 设置GridView样式
131
/// </summary>
132
/// <param name="AGridView"></param>
133
/// <param name="e"></param>
134
/// <returns></returns>
135
public static void SetGridViewStyle(GridView AGridView)
136![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
137
AGridView.HeaderStyle.CssClass = "tablehead";
138
AGridView.CssClass = "tablebodylist";
139
AGridView.BorderWidth = 0;
140
AGridView.CellPadding = 0;
141
AGridView.CellSpacing = 1;
142
AGridView.RowStyle.CssClass = "rowOdd";
143
}
144![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
145![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
146
public static void MsgBox(Page page, string msg)
147![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
148
StringBuilder StrScript = new StringBuilder();
149
StrScript.Append("<script language=javascript>");
150
StrScript.Append("alert('" + msg + "');");
151
StrScript.Append("</script>");
152
if (!page.IsStartupScriptRegistered("MessageBox"))
153![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
154
page.RegisterStartupScript("MessageBox", StrScript.ToString());
155
}
156
}
157![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
158
public static void MsgBox2(Page page, string msg)
159![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
160
StringBuilder StrScript = new StringBuilder();
161
StrScript.Append("<script language=javascript>");
162
StrScript.Append("alert('" + msg + "');");
163
StrScript.Append(" window.close(); ");
164
StrScript.Append("</script>");
165
166
if (!page.IsStartupScriptRegistered("MessageBox"))
167![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
168
page.RegisterStartupScript("MessageBox", StrScript.ToString());
169
}
170
}
171![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
172![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
173![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
174
public static void GoUrl(Page page, string url)
175![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
176
StringBuilder StrScript = new StringBuilder();
177
StrScript.Append("<script language=javascript>");
178
StrScript.Append(" OpenWin('" + url + "',400,350,50,50) ");
179
StrScript.Append("</script>");
180
if (!page.IsStartupScriptRegistered("MessageBox"))
181![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
182
page.RegisterStartupScript("MessageBox", StrScript.ToString());
183
}
184
}
185![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
186
public static void GoUrl(Page page, string url, int width, int height, int top, int left)
187![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
188
StringBuilder StrScript = new StringBuilder();
189
StrScript.Append("<script language=javascript>");
190
StrScript.Append(" OpenWin('" + url + "'," + width + "," + height + "," + top + "," + left + ") ");
191
StrScript.Append("</script>");
192
if (!page.IsStartupScriptRegistered("MessageBox"))
193![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
194
page.RegisterStartupScript("MessageBox", StrScript.ToString());
195
}
196
}
197![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
198![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
199
public static void GoUrl(Page page, string url, int width, int height, int top, int left, string strtoolbar)
200![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
201
StringBuilder StrScript = new StringBuilder();
202
StrScript.Append("<script language=javascript>");
203
StrScript.Append("window.open('" + url + "','newwindow', 'height=" + height + ", width=" + width + ", top=" + top + ", left=" + left + ", toolbar=no, menubar=no, scrollbars=no, location=no, status=no' ) ;");
204
StrScript.Append("</script>");
205
if (!page.IsStartupScriptRegistered("MessageBox"))
206![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
207
page.RegisterStartupScript("MessageBox", StrScript.ToString());
208
}
209
}
210![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
211
public static void GoshowModalDialog(Page page, string url, int width, int height, int top, int left)
212![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
213
StringBuilder StrScript = new StringBuilder();
214
StrScript.Append("<script language=javascript>");
215
StrScript.Append(" window.showModalDialog(\"" + url + "\", window.document,\"dialogWidth:" + width + "px; dialogHeight:" + height + "px;help:" + top + ";status:" + left + ";\");");
216
StrScript.Append("</script>");
217
StrScript.Append("<base target=\"_self\">");
218
if (!page.IsStartupScriptRegistered("MessageBox"))
219![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
220
page.RegisterStartupScript("MessageBox", StrScript.ToString());
221
}
222
}
223
public static void MsgBox_GoBack(Page page, string msg)
224![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
225
StringBuilder StrScript = new StringBuilder();
226
StrScript.Append("<script language=javascript>");
227
StrScript.Append("alert('" + msg + "');");
228
StrScript.Append(" history.go(-1); ");
229
StrScript.Append("</script>");
230
if (!page.IsStartupScriptRegistered("MessageBox"))
231![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
232
page.RegisterStartupScript("MessageBox", StrScript.ToString());
233
}
234
}
235![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
236
public static void MsgBox_GoUrl(Page page, string msg, string url)
237![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
238
StringBuilder StrScript = new StringBuilder();
239
StrScript.Append("<script language=javascript>");
240
StrScript.Append("alert('" + msg + "');");
241
StrScript.Append(" document.location.href='" + url + "' ");
242
StrScript.Append("</script>");
243
if (!page.IsStartupScriptRegistered("MessageBox"))
244![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
245
page.RegisterStartupScript("MessageBox", StrScript.ToString());
246
}
247
}
248![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
249
//openwin_full("index.aspx");
250
public static void GoFullUrl(Page page, string url)
251![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
252
StringBuilder StrScript = new StringBuilder();
253
StrScript.Append("<script language=javascript>");
254
StrScript.Append(" openwin_full('" + url + "') ");
255
StrScript.Append("</script>");
256
if (!page.IsStartupScriptRegistered("MessageBox"))
257![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
258
page.RegisterStartupScript("MessageBox", StrScript.ToString());
259
}
260
}
261![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
262![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
263
public static void MsgBox_GoErr(Page page, string msg, int level)
264![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
265
StringBuilder StrScript = new StringBuilder();
266
StrScript.Append("<script language=javascript>");
267
StrScript.Append("alert('" + msg + "');");
268
if (level == 0)
269
StrScript.Append(" document.location.href='err.htm' ");
270
else if (level == 1)
271
StrScript.Append(" document.location.href='../err.htm' ");
272
else if (level == 2)
273
StrScript.Append(" document.location.href='http://www.cnblogs.com/err.htm' ");
274
else
275
StrScript.Append(" document.location.href='http://www.cnblogs.com/../err.htm' ");
276![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
277
StrScript.Append("</script>");
278
if (!page.IsStartupScriptRegistered("MessageBox"))
279![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
280
page.RegisterStartupScript("MessageBox", StrScript.ToString());
281
}
282
}
283![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
284
public static void MsgBox_Close_Refresh(Page page, string msg)
285![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
286
StringBuilder StrScript = new StringBuilder();
287
StrScript.Append("<script language=javascript>");
288
StrScript.Append("alert('" + msg + "');");
289
StrScript.Append("window.opener.location.reload();");
290
StrScript.Append(" window.close(); ");
291
StrScript.Append(" ; ");
292
StrScript.Append("</script>");
293
if (!page.IsStartupScriptRegistered("MessageBox"))
294![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
295
page.RegisterStartupScript("MessageBox", StrScript.ToString());
296
}
297
}
298![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
299
public static void Close_Refresh(Page page)
300![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
301
StringBuilder StrScript = new StringBuilder();
302
StrScript.Append("<script language=javascript>");
303
StrScript.Append("window.opener.location.reload();");
304
StrScript.Append(" window.close(); ");
305
StrScript.Append(" ; ");
306
StrScript.Append("</script>");
307
if (!page.IsStartupScriptRegistered("MessageBox"))
308![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
309
page.RegisterStartupScript("MessageBox", StrScript.ToString());
310
}
311
}
312![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
313
314![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
315
public static void MsgBox_Refresh(Page page, string msg)
316![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
317
StringBuilder StrScript = new StringBuilder();
318
StrScript.Append("<script language=javascript>");
319
StrScript.Append("alert('" + msg + "');");
320
StrScript.Append("document.location.reload();");
321
StrScript.Append(" ; ");
322
StrScript.Append("</script>");
323
if (!page.IsStartupScriptRegistered("MessageBox"))
324![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
325
page.RegisterStartupScript("MessageBox", StrScript.ToString());
326
}
327
}
328![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
329![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
330
public static void MsgBox_Close_RefreshParent(string msg)
331![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
332
System.Web.HttpContext.Current.Response.Write("<script>window.opener.location.href=window.opener.location.href;alert('" + msg + "');</script>"); //弹出提示窗口.
333
System.Web.HttpContext.Current.Response.Write("<script>window.close();</script>");
334
}
335![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
336
public static void Close_RefreshParent2()
337![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
338
System.Web.HttpContext.Current.Response.Write("<script>window.opener.location.href=window.opener.location.href;</script>"); //弹出提示窗口.
339
System.Web.HttpContext.Current.Response.Write("<script>window.close();</script>");
340
}
341![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
342![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
343
public static void MsgBox_Div(Page page, string msg)
344![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
345
StringBuilder StrScript = new StringBuilder();
346
StrScript.Append("<script language=javascript>");
347
StrScript.Append("alert('" + msg + "');");
348
StrScript.Append("parent.divhide();");
349
StrScript.Append("parent.location.reload();");
350
StrScript.Append(" ; ");
351
StrScript.Append("</script>");
352
if (!page.IsStartupScriptRegistered("MessageBox"))
353![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
354
page.RegisterStartupScript("MessageBox", StrScript.ToString());
355
}
356
}
357![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
358
public static void MsgBox_DivHide(Page page)
359![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
360
StringBuilder StrScript = new StringBuilder();
361
StrScript.Append("<script language=javascript>");
362
363
StrScript.Append("window.parent.location.href=window.parent.location.href;");
364
StrScript.Append("parent.divhide();");
365
StrScript.Append("</script>");
366
if (!page.IsStartupScriptRegistered("MessageBox"))
367![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
368
page.RegisterStartupScript("script", StrScript.ToString());
369
}
370![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
371
}
372![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
373
public static void MsgBox_Div2(Page page, string msg)
374![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
375
StringBuilder StrScript = new StringBuilder();
376
StrScript.Append("<script language=javascript>");
377
StrScript.Append("alert('" + msg + "');");
378
StrScript.Append("parent.divhide();");
379
StrScript.Append(" ; ");
380
StrScript.Append("</script>");
381
if (!page.IsStartupScriptRegistered("MessageBox"))
382![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
383
page.RegisterStartupScript("MessageBox", StrScript.ToString());
384
}
385
}
386![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
387
/// 刷新父页面
388![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
389
/// </summary>
390
/// <param name="page"></param>
391
/// <param name="msg"></param>
392
public static void MsgBoxNoncePage(Page page, string msg)
393![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
394
StringBuilder StrScript = new StringBuilder();
395
StrScript.Append("<script language=javascript>");
396
StrScript.Append("alert('" + msg + "');");
397
StrScript.Append("parent.location.reload();");
398
StrScript.Append(" ; ");
399
StrScript.Append("</script>");
400
if (!page.IsStartupScriptRegistered("MessageBox"))
401![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
402
page.RegisterStartupScript("MessageBox", StrScript.ToString());
403
}
404
}
405
public static void MsgBox_Div33(Page page, string msg)
406![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
407
StringBuilder StrScript = new StringBuilder();
408
StrScript.Append("<script language=javascript>");
409
StrScript.Append("alert('" + msg + "');");
410
StrScript.Append("parent.location.reload();");
411
StrScript.Append(" window.close(); ");
412
StrScript.Append(" ; ");
413
StrScript.Append("</script>");
414
if (!page.IsStartupScriptRegistered("MessageBox"))
415![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
416
page.RegisterStartupScript("MessageBox", StrScript.ToString());
417
}
418
}
419![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
420![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
421
public static string ChkBoxEmpty(TextBox tbBox, string msg)
422![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
423
if (tbBox.Text == null || tbBox.Text.Length == 0)
424
return msg;
425
else
426
return "";
427
}
428![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
429
public static string ChkDropEmpty(DropDownList ddl, string msg)
430![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
431
if (ddl.SelectedValue == "-1")
432
return msg;
433
else
434
return "";
435
}
436![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
437
public static string ChkRadioEmpty(RadioButtonList rbl, string msg)
438![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
439
if (rbl.SelectedIndex == -1)
440
return msg;
441
else
442
return "";
443
}
444![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
445
public static string ChkBoxComp(TextBox tbBox1, TextBox tbBox2, string msg)
446![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
447
if (tbBox1.Text == tbBox2.Text)
448
return "";
449
else
450
return msg;
451
}
452![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
453![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
454
//文本框中的数据填入数据库
455
public static string ToData(string str)
456![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
457
str = str.Trim();
458
str = str.Replace("'", "<$>");
459
str = str.Replace("\n", "<br>");
460
str = str.Replace(" ", " ");
461
return str;
462
}
463![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
464
//数据库的数据填入text
465
public static string DataToText(string str)
466![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
467
if ((str != null) && (str != string.Empty))
468![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
469
str = str.Replace("<$>", "'");
470
str = str.Replace("<br>", "\n");
471
str = str.Replace(" ", " ");
472
return str;
473
}
474
else
475![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
476
return "";
477
}
478
}
479![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
480
//数据库的数据填入html
481
public static string DataToHtml(string str)
482![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
483
if ((str != null) && (str != string.Empty))
484![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
485
str = str.Replace("<$>", "'");
486
return str;
487
}
488
else
489![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
490
return "";
491
}
492
}
493![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
494![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
495![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
496
/// 转换成int
497
/// </summary>
498
/// <param name="str"></param>
499
/// <returns>错误返回1</returns>
500
public static int Int(string str)
501![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
502
if ((str != null) && (str != string.Empty))
503![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
504
try
505![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
506
return int.Parse(str);
507
}
508
catch
509![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
510
return 1;
511
}
512
}
513
else
514![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
515
return 1;
516
}
517
}
518![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
519![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
520
public static string String(object str)
521![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
522
if (str != null)
523![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
524
try
525![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
526
string strNow;
527
strNow = str.ToString();
528
strNow = strNow.Replace("'", "");
529
strNow = strNow.Trim();
530
return strNow;
531
}
532
catch
533![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
534
return "";
535
}
536
}
537
else
538
return "";
539
}
540![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
541![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
542
public static string StringToUrl(object str)
543![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
544
if (str != null)
545![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
546
try
547![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
548
string strNow;
549
strNow = str.ToString();
550
strNow = strNow.Replace("&", "aZhWnHsOOfr");
551
strNow = strNow.Trim();
552
return strNow;
553
}
554
catch
555![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
556
return "";
557
}
558
}
559
else
560
return "";
561
}
562![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
563
public static string UrlToString(object str)
564![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
565
if (str != null)
566![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
567
try
568![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
569
string strNow;
570
strNow = str.ToString();
571
strNow = strNow.Replace("aZhWnHsOOfr", "&");
572
strNow = strNow.Trim();
573
return strNow;
574
}
575
catch
576![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
577
return "";
578
}
579
}
580
else
581
return "";
582
}
583![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
584![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
585![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
586
/// 分割字符串到序列
587
/// </summary>
588
/// <param name="str"></param>
589
public static ArrayList SpliString(string str, string strSpli)
590![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
591![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
592
ArrayList FArrayList = new ArrayList();
593![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
string[] strArr = str.Split(new string[1]
{ strSpli }, StringSplitOptions.None);
594
FArrayList.AddRange(strArr);
595
return FArrayList;
596
}
597![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
598![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
599![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//******************************************************************************
600
****************************************************************************/
601![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
602![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
603![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
604
/// 字符串输入转换 有利于系统安全
605![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
606
/// </summary>
607
/// <param name="txt"></param>
608
/// <returns></returns>
609
public static string Input(string txt)
610![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
611
txt = txt.Replace("'", "''").TrimEnd();
612
return txt;
613
}
614
public static string Input2(string txt)
615![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
616
txt = txt.Replace("'", "").TrimEnd();
617
return txt;
618
}
619![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
620![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
621
/// 输出为html格式转换,有利于系统安全
622![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
623
/// </summary>
624
/// <param name="txt"></param>
625
/// <returns></returns>
626
public static string Output(string txt)
627![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
628
string x = new string((char)32, 1); //先把空格给字符串x
629
string y = new string((char)13, 1); //先把换行赋给字符串y
630
txt = txt.TrimEnd();
631
txt = txt.Replace("&", "&");
632
txt = txt.Replace("<", "<");
633
txt = txt.Replace(">", ">");
634
txt = txt.Replace(x, " "); //替换空格
635
txt = txt.Replace(y, "<br>"); //替换换行符
636
return txt;
637
}
638![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
639![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
640
/// 对话框打开模式
641
/// </summary>
642
public enum Target
643![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
644
_back = 5,
645
_blank = 1,
646
_close = 6,
647
_parent = 4,
648
_self = 2,
649
_top = 3
650
}
651![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
652![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
653
/// 对话框
654![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
655
/// </summary>
656
/// <param name="strMsg"></param>
657
public static void Alert(string strMsg)
658![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
659
HttpContext.Current.Response.Write("<script language=\"javascript\" defer>alert('" + strMsg + "');</script>");
660
}
661![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
662![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
663
/// 对话框
664![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
665
/// </summary>
666
/// <param name="strMsg"></param>
667
/// <param name="tag"></param>
668
public static void Alert(string strMsg, Target tag)
669![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
670
HttpResponse response1 = HttpContext.Current.Response;
671
response1.Write("<script language=\"javascript\" defer>");
672
response1.Write("alert('" + strMsg + "');");
673
if (tag == Target._back)
674![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
675
response1.Write("window.history.back();");
676
}
677
if (tag == Target._close)
678![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
679
response1.Write("window.close();");
680
}
681
response1.Write("</script>");
682
response1.End();
683
}
684![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
685![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
686
/// 对话框
687![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
688
/// </summary>
689
/// <param name="strMsg"></param>
690
/// <param name="isEnd"></param>
691
public static void Alert(string strMsg, bool isEnd)
692![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
693
HttpResponse response1 = HttpContext.Current.Response;
694
response1.Write("<script language=\"javascript\" defer>alert('" + strMsg + "');</script>");
695
if (isEnd)
696![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
697
response1.End();
698
}
699
}
700![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
701![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
702
/// 对话框
703![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
704
/// </summary>
705
/// <param name="strMsg"></param>
706
/// <param name="tag"></param>
707
/// <param name="isEnd"></param>
708
public static void Alert(string strMsg, Target tag, bool isEnd)
709![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
710
HttpResponse response1 = HttpContext.Current.Response;
711
response1.Write("<script language=\"javascript\" defer>");
712
response1.Write("alert('" + strMsg + "');");
713
if (tag == Target._back)
714![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
715
response1.Write("window.history.back();");
716
}
717
if (tag == Target._close)
718![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
719
response1.Write("window.close();");
720
}
721
response1.Write("</script>");
722
if (isEnd)
723![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
724
response1.End();
725
}
726
}
727![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
728![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
729
///
730
/// </summary>
731
/// <param name="strMsg"></param>
732
public static void AlertReload(string strMsg)
733![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
734
HttpResponse response1 = HttpContext.Current.Response;
735![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
response1.Write(string.Concat(new string[]
{ "<script language=\"javascript\" defer>alert('", strMsg, "');window.location.href='", HttpContext.Current.Request.Path, "';</script>" }));
736
response1.End();
737
}
738![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
739![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
740
///
741
/// </summary>
742
/// <param name="strMsg"></param>
743
/// <param name="strUrl"></param>
744
public static void AlertReload(string strMsg, string strUrl)
745![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
746
HttpResponse response1 = HttpContext.Current.Response;
747![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
response1.Write(string.Concat(new string[]
{ "<script language=\"javascript\" defer>alert('", strMsg, "');window.location.href='", strUrl, "';</script>" }));
748
response1.End();
749
}
750![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
751![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
752
///
753
/// </summary>
754
/// <param name="strUrl"></param>
755
/// <param name="tag"></param>
756
/// <param name="isEnd"></param>
757
public static void AlertReload(string strUrl, Target tag, bool isEnd)
758![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
759
HttpResponse response1 = HttpContext.Current.Response;
760
response1.Write("<script language=\"javascript\" defer>");
761
switch (((int)tag))
762![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
763
case 1:
764![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
765
response1.Write("window.open(\"" + strUrl + "\");");
766
break;
767
}
768
case 2:
769![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
770
response1.Write("window.location.href='" + strUrl + "';");
771
break;
772
}
773
case 3:
774![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
775
response1.Write("window.top.location.href='" + strUrl + "';");
776
break;
777
}
778
case 4:
779![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
780
response1.Write("window.parent.location.href='" + strUrl + "';");
781
break;
782
}
783
case 5:
784![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
785
response1.Write("window.history.back();");
786
break;
787
}
788
default:
789![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
790
response1.Write("window.location.href='" + strUrl + "';");
791
break;
792
}
793
}
794
response1.Write("</script>");
795
if (isEnd)
796![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
797
response1.End();
798
}
799
}
800![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
801![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
802
///
803
/// </summary>
804
/// <param name="strMsg"></param>
805
/// <param name="strUrl"></param>
806
/// <param name="isEnd"></param>
807
public static void AlertReload(string strMsg, string strUrl, bool isEnd)
808![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
809
HttpResponse response1 = HttpContext.Current.Response;
810![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
response1.Write(string.Concat(new string[]
{ "<script language=\"javascript\" defer>alert('", strMsg, "');window.location.href='", strUrl, "';</script>" }));
811
if (isEnd)
812![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
813
response1.End();
814
}
815
}
816![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
817![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
818
///
819
/// </summary>
820
/// <param name="strMsg"></param>
821
/// <param name="strUrl"></param>
822
/// <param name="tag"></param>
823
/// <param name="isEnd"></param>
824
public static void AlertReload(string strMsg, string strUrl, Target tag, bool isEnd)
825![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
826
HttpResponse response1 = HttpContext.Current.Response;
827
response1.Write("<script language=\"javascript\" defer>");
828
response1.Write("alert('" + strMsg + "');");
829
switch (((int)tag))
830![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
831
case 1:
832![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
833
response1.Write("window.open(\"" + strUrl + "\");");
834
break;
835
}
836
case 2:
837![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
838
response1.Write("window.location.href='" + strUrl + "';");
839
break;
840
}
841
case 3:
842![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
843
response1.Write("window.top.location.href='" + strUrl + "';");
844
break;
845
}
846
case 4:
847![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
848
response1.Write("window.parent.location.href='" + strUrl + "';");
849
break;
850
}
851
case 5:
852![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
853
response1.Write("window.history.back();");
854
break;
855
}
856
default:
857![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
858
response1.Write("window.location.href='" + strUrl + "';");
859
break;
860
}
861
}
862
response1.Write("</script>");
863
if (isEnd)
864![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
865
response1.End();
866
}
867
}
868![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
869
public static string LeftString(string str_value, int str_len)
870![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
871
int p_num = 0;
872
int i;
873
string New_Str_value = "";
874
if (str_value == "")
875![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
876
New_Str_value = "";
877
}
878
else
879![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
880
int Len_Num = str_value.Length;
881![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
882
for (i = 0; i <= Len_Num - 1; i++)
883![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
884
if (i > Len_Num) break;
885
char c = Convert.ToChar(str_value.Substring(i, 1));
886
if (((int)c > 255) || ((int)c < 0))
887![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
888
p_num = p_num + 2;
889
}
890
else
891![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
892
p_num = p_num + 1;
893
}
894![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
895
if (p_num >= str_len)
896![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
897
New_Str_value = str_value.Substring(0, i + 1);
898
break;
899
}
900
else
901![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
902
New_Str_value = str_value;
903
}
904
}
905![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
906
}
907
return New_Str_value;
908
}
909![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
910
public static string LeftString(string str_value, int str_len, string strz)
911![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
912
int p_num = 0;
913
int i;
914
string New_Str_value = "";
915
if (str_value == "")
916![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
917
New_Str_value = "";
918
}
919
else
920![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
921
if (str_value.Contains(strz))
922![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
923![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
924
string stra = str_value.Substring(0, str_value.IndexOf(strz));
925
string strb = str_value.Substring(str_value.IndexOf(strz) + strz.Length, str_value.Length - str_value.IndexOf(strz) - strz.Length);
926
strb = Fun.LeftString(strb, 4);
927
New_Str_value = stra + strz + strb;
928
}
929
else
930![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
931
New_Str_value = str_value.ToString().Trim();
932
}
933
}
934
return New_Str_value;
935
}
936
public static string ChkCheckBoxListEmpty(CheckBoxList cbl, string msg)
937![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
938
if (cbl.SelectedIndex == -1)
939
return msg;
940
else
941
return "";
942
}
943![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
944
public static void MsgBox_DiveHide2(Page page, string msg)
945![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
946
StringBuilder StrScript = new StringBuilder();
947
StrScript.Append("<script language=javascript>");
948
StrScript.Append("alert('" + msg + "');");
949
StrScript.Append("window.parent.location.href=window.parent.location.href;"); StrScript.Append("parent.divhide();");
950
StrScript.Append("</script>");
951
if (!page.IsStartupScriptRegistered("MessageBox"))
952![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
953
page.RegisterStartupScript("MessageBox", StrScript.ToString());
954
}
955![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
956![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
957
}
958![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
959
public static void MsgBox_Div2(Page page)
960![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
961
StringBuilder StrScript = new StringBuilder();
962
StrScript.Append("<script language=javascript>");
963
StrScript.Append("parent.divhide();");
964
StrScript.Append("parent.location.reload();");
965
StrScript.Append(" ; ");
966
StrScript.Append("</script>");
967
if (!page.IsStartupScriptRegistered("MessageBox"))
968![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
969
page.RegisterStartupScript("MessageBox", StrScript.ToString());
970
}
971
}
972![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
973
public static string ClearRepet(string str)
974![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
975
Hashtable ht = new Hashtable();
976
int flag = 0;
977
string[] arr = str.Split(',');
978
for (int i = 0; i < arr.Length; i++)
979![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
980
foreach (DictionaryEntry de in ht)
981![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
982
if ( arr[i].ToString() == de.Value.ToString())
983![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
984
flag = 1;
985
break;
986
}
987
}
988
if (arr[i].Length > 0 && flag == 0)
989![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
990
ht.Add(i, arr[i]);
991
}
992
else
993
flag = 0;
994
}
995
string result = "";
996
foreach (DictionaryEntry de in ht)
997![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
998
result += "," + de.Value.ToString();
999
}
1000
if (result.Length > 0)
1001![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
1002
result = result.Substring(1);
1003
}
1004
return result;
1005
}
1006![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
1007
}
1008![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
posted on
2008-09-10 09:13
poop
阅读(
528)
评论()
编辑
收藏
举报