2010-08-20 35 views
0

我想在Javascript確認框中顯示Html.TextAreaFor的值,但我的代碼不起作用。也許有人有如何解決是一個好主意..JavaScript,HTML - 是否可以在Javascript ConfirmBox中顯示值Html.TextAreaFor?

這是我的代碼:

<% using (Html.BeginForm()) 
      { %> 
     <%= Html.Hidden("ThreadId", Html.Encode(this.Model.ThreadId))%> 
     <%= Html.TextAreaFor(m=>m.Quote,7,40,null)%> 
     <br /> <button name="view" value="ViewQuoteButton" onclick="return ViewQuote()"> 
      View 
     </button> 
     <% } %> 

<script type="text/javascript"> 

     function ViewQuote() { 

      if (confirm(document.valueOf("here I'trying to show value of TextAreaFor"))) { 

       return true; 
      } 
      else { 
      } return false; 
     } 
    </script> 

謝謝大家和照顧, Ragims

回答

0
document.getElementById("Quote").val(); 

OR

document.getElementByName("Quote").val(); 
+0

它不工作...... :( – 2010-08-20 17:13:53

+0

如果我這樣做,就像你說的,發生回發,並沒有調用JavaScript方法完全可以 – 2010-08-20 17:15:32

+0

確認ViewQuote()是否被調用?因爲你正在使用MVC我強烈建議更換您使用jQuery你的JavaScript – Rony 2010-08-20 17:27:27

相關問題