2021年12月7日 星期二

[Jquery] 文字換行

 $(this).html($(this).text().replace(new RegExp("\n", "gm"), "<br/>"))

 gm代表全部替換

2021年8月26日 星期四

[MVC]使用Ajax.BeginForm取得檔案欄位

form裡面一定要加入enctype = "multipart/form-data" Controller才會取得二進位制資料


@using (Ajax.BeginForm("FileUpload", "xxx", null, new AjaxOptions { HttpMethod = "Post",               OnSuccess = "" }, new{  @enctype = "multipart/form-data" }))
{
   <input type="file" name="files" class="form-control">
}


[Authorize]
[HttpPost]
public ActionResult FileUpload(FormCollection form, IEnumerable<HttpPostedFileBase> files)
{

}

2020年6月30日 星期二

2020年5月21日 星期四

[Jquery]Jquery on 事件執行多次

每次绑定前先取消上次的绑定

$('"#test").off().click(function () {
    //
});

or

$('"#test").unbind('click').click(function () {
    //
});

2020年5月19日 星期二

[VisualStudio]無法啟動 IIS Express Web 伺服器


1.將.vs資料夾刪除

  路徑:(專案資料夾)/.vs/

2.將config資料夾刪除

 路徑:%userprofile%/Documents/IISExpress/config/

2019年7月4日 星期四

[iCheck]設定iradio disabled使用原有樣式

如iradio設定為disabled 又不想顯示灰階圖示
調整一下圖片顯示位置即可。
<style>
.iradio_flat-green.checked.disabled{
    background-position: -110px 0 !important;
}
</style>

Visual Studio JS intellisense 失效解決方式

  試了好久,發現到工具>選項>IntelliCode js項目設定啟用,重新開啟VS就正常了! 後來發現是TypeScript3.2版有問題停用,使用4.3版的TypeScript即可