2010-08-20 72 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

相关问题