發表文章

具有潛在危險 Request.Form 的值已從用戶端

具有潛在危險 Request.Form 的值已從用戶端 ValidateInput: 對指定Action允許輸入特殊字元         [HttpPost] [ValidateInput(false)]         public JsonResult SaveST0401M( string status)         {            ...             return Json(new { result = result, msg = msg });         } AllowHtml: 對特定屬性允許輸入特殊字元 public class TestModelsAllowHtml {      [Display(Name = "AllowHtml" )]      [AllowHtml]      public string AllowHtml { get ; set ; } } JavaScript escape($.trim($("#txtCODE_NO").val())) // unescape() 函数可对通过 escape() 编码的字符串进行解码。 Asp.net MVC C#  Controller.cs CODE_NO = HttpUtility.UrlDecode(txtCODE_NO); 參考資料: 1. https://dotblogs.com.tw/brooke/2016/10/27/172920 2.  http://love-coding.blogspot.tw/2015/09/aspnet.html 3. http://www.w3school.com.cn/js/jsref_unescape....

ajax錯誤時,回傳error message內容

ajax錯誤時,回傳的error message內容 $.ajax({ url: '@Url.Action("ST0401R", "ST04")', type: "post", ... error: function (xhr, ajaxOptions, thrownError) { alert(xhr.responseText); return false; } }); xhr是XMLHttpRequest物件,有以下屬性及方法 1.status :Returns the HTTP status code. 2.statusText :Returns the HTTP status text.  3.getResponseHeader() method 4.getAllResponseHeaders() method Response Entity Body 5.response :Returns 就回傳內容 6.responseXML :Returns 就回傳XML內容 參考網址: ajax錯誤時,回傳的error message內容 http://fishjerky.blogspot.tw/2010/06/ajaxerror-message.html

NPOI 建立EXCEL

建立新的EXCEL public void CreateExcelFile()         {             IWorkbook workbook = new XSSFWorkbook();             XSSFSheet u_sheet = (XSSFSheet)workbook.CreateSheet("Sheet"); //建立一個工作表 //建立資料列             IRow row = u_sheet.CreateRow(0); // 创建单元格              ICell cell = row .CreateCell(0); //輸出EXCEL檔             MemoryStream MS = new MemoryStream();             workbook.Write(MS);             Response.AddHeader("content-disposition", "attachment; filename=Emp.xlsx");             Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";             Response.BinaryWrite(MS.ToArray()); //釋放資源             MS.Clos...

NPOI 匯出EXCEL 檔案

            try             {                 // 定义要写入的Excel文件地址                 string excel = Server.MapPath(@"~\template\memberlist.xls");                 // 创建Excel文件流                 using (FileStream fileStream = new FileStream(excel, FileMode.Open, FileAccess.Read))                 {                     // 创建NPOI的Excel操作对象                     IWorkbook hssfWorkbook = null;                     if (excel.IndexOf(".xlsx") > 0) // 2007版本                         hssfWorkbook = new XSSFWorkbook(fileStream); ...

C# 日期格式設定

//--CultureInfo.CreateSpecificCulture("zh-tw")指定繁體語系 //--CultureInfo.InstalledUICulture由系統決定語系 DateTime.Now.ToString("yyyy-MM-dd (ddd) tt hh:mm:ss", CultureInfo.InstalledUICulture); //--2009-08-05(星期三) 下午 09:03:08  參考來源 [C# 資訊]DateTime.ToString(string format) 日期時間格式輸出 - 程式成事 http://ad87515.pixnet.net/blog/post/191046845-%5Bc%23-%E8%B3%87%E8%A8%8A%5Ddatetime.tostring%28string-format%29%E3%80%80%E6%97%A5%E6%9C%9F%E6%99%82%E9%96%93