2015-02-10 64 views
1

我的鏈接:從jQuery的傳遞價值MVC控制器

<span class="list-subtitle"><span class="place-right icon-flag-2 fg-red smaller" onclick="ShowMessage('@item.MessageId');">23</span> 

我的Jquery:

<script> 
function ShowMessage(msgid) { 
     alert("Hello" + msgid); 
     $.Dialog({ 
      overlay: false, 
      shadow: true, 
      flat: false, 
      title: 'Studidesk - Conversations', 
      content: '', 
      onShow: function (_dialog) { 
       var html = [ 
        '<iframe width="800" height="480" src="/Channel/Comments/' + msgid +'" frameborder="0" allowfullscreen></iframe>' 
       ].join(""); 

       $.Dialog.content(html); 
      } 
     });   
    } 
</script> 

我的控制器(獲取)

public ActionResult Comments(string msgid) 
    { 
     var balObject = new BusinessLogic(); 
     List<StudiMessageDetails> comments = new List<StudiMessageDetails>(); 
     comments = balObject.FetchComment(msgid); 
     return PartialView("_commentsPost", comments); 
    } 

雖然查詢發送控制我行動方法

public ActionResult Comments(string msgid), 

它沒有價值MSGID,任何人可以幫助我渡過MSGID目前在

<span class="list-subtitle"><span class="place-right icon-flag-2 fg-red smaller" onclick="ShowMessage('@item.MessageId');">23</span> 

行動方法..當我點擊

jQuery是觸發:

<span class="list-subtitle"><span class="place-right icon-flag-2 fg-red smaller" onclick="ShowMessage('@item.MessageId');">23</span> 

回答

0

要打電話給你的動作,你需要定義路線。如果你還沒有定義的路線是,你可以這樣調用:

<script> 
    function ShowMessage(msgid) { 
      alert("Hello" + msgid); 
      $.Dialog({ 
       overlay: false, 
       shadow: true, 
       flat: false, 
       title: 'Studidesk - Conversations', 
       content: '', 
       onShow: function (_dialog) { 
        var html = [ 
         '<iframe width="800" height="480" src="/Channel/Comments?msgid=' + msgid +'" frameborder="0" allowfullscreen></iframe>' 
        ].join(""); 

        $.Dialog.content(html); 
       } 
      });   
     } 
    </script> 
+0

這工作......非常感謝:)... – 2015-02-10 06:44:14

+0

@MichaelPhilips我很高興幫助。當他們爲你工作時,不要忘記標記asnwers。 :) – Sefa 2015-02-10 06:46:38

+0

我可以通過點擊這樣的兩個值: – 2015-02-11 04:54:38

相關問題