ASP MVC Passing value into modal window

后端 未结 3 918
旧时难觅i
旧时难觅i 2021-01-22 13:04

I have this view with a modal window. When I click to open the modal window, I\'d like to pass the parameter item.InstrumentId into the modal window so that I can c

3条回答
  •  情话喂你
    2021-01-22 13:21

    1.Use ID for Anchor Link.
    2.Notice this line Anchor Link Value= in code. It has Anchor Link Value=. When you open modal you can see Anchor Link Value=10320320 and you can inspect href too.

    $('#myModal1').on('show.bs.modal', function(e) {
      var modalId = $(e.relatedTarget).data('id');
      $('#InstrumentIDLink').attr('href', 'url+'+ modalId)
      $('#InstrumentIDLink').text('Anchor Link Value='+ modalId);
    
    })
    
    
    
    

    From bootstrap 3+ you can use e.relatedTarget to get element that triggered the modal

提交回复
热议问题