views:

19

answers:

1

Hello all,

I'm trying to show Value of Html.TextAreaFor in Javascript Confirm Box but my code doesn't work. Maybe somebody has a good idea how to fix it..

This is my code:

<% 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>

Thank you all and take care, Ragims

A: 
document.getElementById("Quote").val();

OR

document.getElementByName("Quote").val();
Rony
it doesnt work...:(
Ragims
if i do it like you say, happens postback, and javascript method is not called at all
Ragims
can you confirm whether ViewQuote() is getting called at all? and since you are using MVC I strongly recomend you to use jQuery for your javascripts
Rony
<script type="text/javascript"> $(document).ready( function () { $('#view').click({ alert($('#Quote').val();); }); });</script>
Rony