📖
BPackCore CodingConventions
  • 공통
  • Desktop Application
    • UI 디자인 및 실행구조
    • 디렉토리 구조
    • 명명규칙 및 구현
      • Model
      • IPocket
      • Pocket
      • Zipper
      • Carrying
        • Args (FormArgs)
        • MainForm
        • SubForm
        • EditForm
        • StrapControl
        • FileUp/Download
      • Tips
    • 다국어처리
  • Web Application - Mobile
    • UI 디자인
    • 디렉토리 구조
    • 명명규칙 및 구현
      • Model
      • Controller
      • View
      • Tips
    • 다국어처리
  • Database
    • 명명규칙
      • 용어사전
    • SP 구현
      • Template
      • 일련번호발행
    • ERD 작성규칙 및 샘플
  • 소스형상관리(Git/Gitlab)
  • WebAPI
Powered by GitBook
On this page
  • ASP.NET Core <-> Javascript
  • Viewbag 으로 List<>를 Array로 변환
  • C#
  • List To Dictionary
  1. Web Application - Mobile
  2. 명명규칙 및 구현

Tips

ASP.NET Core <-> Javascript

Viewbag 으로 List<>를 Array로 변환

<script>
    //Controller에서 넘어온 List<dynamic>을 javascript Array로 변환
    var langMenuDic = @Html.Raw(Json.Serialize(ViewBag.LangMenuDic));
    $(document).ready(function () {
       console.log(langMenuDic);
        $('#btn_pda_mm').html(langMenuDic.find(a => { return a.MENU_ID == "PDA_MM" }).MENU_NAME);
        $('#btn_pda_pc').html(langMenuDic.find(a => { return a.MENU_ID == "PDA_PC" }).MENU_NAME);
        $('#btn_pda_qc').html(langMenuDic.find(a => { return a.MENU_ID == "PDA_QC" }).MENU_NAME);
        $('#btn_pda_sd').html(langMenuDic.find(a => { return a.MENU_ID == "PDA_SD" }).MENU_NAME);
    });
</script>

Dictionary로 반환했을때 View에서 사용

<h4 style="margin-bottom:0px">
    <span class="badge badge-success">
        @Html.Raw(ViewBag.LangMenuDic["PDA_MM_Outbound"])
    </span>
</h4>
<!--배열처럼 사용할 수 있다-->

C#

List To Dictionary

var data = sp.PocketQuery<dynamic>(sql, new
{
    LANG_CODE = Models.Common.Login.LoginUserInfo.LangCode(HttpContext)
}, System.Data.CommandType.Text);
//List To Dictionary
ViewBag.LangMenuDic = data.ToDictionary(a => a.MENU_ID, a => a.MENU_NAME);
PreviousViewNext다국어처리

Last updated 5 years ago