[3] Development/HTML5&CSS3
<textarea> 줄바꿈이 있을때 DB에 저장했다가 꺼내서 다시 <textarea>에 넣을때 500 Error
코볼
2021. 12. 21. 12:42
728x90
반응형
SMALL
C# ASP.net MVC 사용시
저장)
1. 변수에 담기 (View > Javascript Function)
var jsMemo = $("#txtaMemo").val().replace(/\n/g, "<br />");
2. .ajax에서 넘길때 (View > Javascript Function)
data: { targetID: jsTargetID, memo: encodeURI(jsMemo) },
3. .cs단에서 DB에 저장할때 (Controller > Function)
memo = memo == string.Empty ? null : memo;
CHI.CHI_TargetMemo_U(targetID, HttpUtility.UrlDecode(memo));
조회)
저장된 값을 Table Column에 보여 줄때 (View > html)
@(item.memo != null ? item.memo.Replace("<br />", "\r\n") : null)
수정을 위해 다시 <textarea></textarea>에 넣을때 (View > html)
$("#txtaMemo").val(jsMemo.replaceAll("<br />", "\r\n"));
728x90
반응형
LIST