public static string GetText(HiddenField hiddenCtrl) { if (hiddenCtrl == null) { throw new ArgumentNullException("获取文本内容的控件不能为空!"); } if (TextUtility.EmptyTrimOrNull(hiddenCtrl.Value)) { return(""); } return(TextFilter.FilterScript(hiddenCtrl.Value.Trim())); }
public static string GetText(HtmlInputControl valueCtrl) { if (valueCtrl == null) { throw new ArgumentNullException("获取文本内容的控件不能为空!"); } if (TextUtility.EmptyTrimOrNull(valueCtrl.Value)) { return(""); } return(TextFilter.FilterScript(valueCtrl.Value.Trim())); }
public static string GetText(ITextControl textCtrl) { if (textCtrl == null) { throw new ArgumentNullException("获取文本内容的控件不能为空!"); } if (TextUtility.EmptyTrimOrNull(textCtrl.Text)) { return(""); } return(TextFilter.FilterScript(textCtrl.Text.Trim())); }
public static string[] UploadFile(HttpPostedFile upfile, string limitType, int limitSize, bool autoName, string autoFilename, string savepath) { string str6; bool flag; string[] strArray = new string[5]; string[] strArray2 = null; if (!string.IsNullOrEmpty(limitType)) { strArray2 = TextUtility.SplitStrArray(limitType, ","); } int contentLength = upfile.ContentLength; string fileName = upfile.FileName; string originalStr = Path.GetFileName(fileName); switch (originalStr) { case null: case "": strArray[0] = "无文件"; strArray[1] = ""; strArray[2] = ""; strArray[3] = ""; strArray[4] = "<span style='color:red;'>失败</span>"; return(strArray); default: { string contentType = upfile.ContentType; string[] strArray3 = TextUtility.SplitStrArray(originalStr, "."); string strA = strArray3[strArray3.Length - 1]; int length = (originalStr.Length - strA.Length) - 1; string dateTimeLongString = ""; if (autoName) { dateTimeLongString = TextUtility.GetDateTimeLongString(); } else if (TextUtility.EmptyTrimOrNull(autoFilename)) { dateTimeLongString = originalStr.Substring(0, length); } else { dateTimeLongString = autoFilename; } str6 = dateTimeLongString + "." + strA; strArray[0] = fileName; strArray[1] = str6; strArray[2] = contentType; strArray[3] = contentLength.ToString(); flag = false; if ((limitSize <= contentLength) && (limitSize != 0)) { strArray[4] = "<span style='color:red;'>失败</span>,上传文件过大"; flag = false; } else if (strArray2 != null) { for (int i = 0; i <= (strArray2.Length - 1); i++) { if (string.Compare(strA, strArray2[i].ToString(), true) == 0) { flag = true; break; } strArray[4] = "<span style='color:red;'>失败</span>,文件类型不允许上传"; flag = false; } } else { flag = true; } break; } } if (flag) { try { string file = savepath + str6; FileManager.WriteFile(file, "临时文件"); upfile.SaveAs(file); strArray[4] = "成功"; } catch (Exception exception) { strArray[4] = "<span style='color:red;'>失败</span><!-- " + exception.Message + " -->"; } } return(strArray); }