Store javascript variable into the ASP.NET string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sana krishna
    New Member
    • Apr 2008
    • 7

    Store javascript variable into the ASP.NET string

    How can we take the value of a variable in javascript function to the ASP.NET string
    I wish to display the value of P using Response.write when I click the Button.
    //my code
    Code:
    <html>
    <form>
    <input type="Button" onclick="count();"/>
    </form>
    </html>
    <script language='javascript'>
    function count(s,n)
    {
    n=5;
    s=10;
     p=n+s;
    document.write("Function value"+p);
    }
    </script>
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Originally posted by sana krishna
    How can we take the value of a variable in javascript function to the ASP.NET string
    I wish to display the value of P using Response.write when I click the Button.
    //my code
    Code:
    <html>
    <form>
    <input type="Button" onclick="count();"/>
    </form>
    </html>
    <script language='javascript'>
    function count(s,n)
    {
    n=5;
    s=10;
     p=n+s;
    document.write("Function value"+p);
    }
    </script>
    Create a hidden field.
    Hidden Fields can be accessed by your .NET code and can be accessed by JavaScript (using document.getEle mentById(client IdOfHiddenField )).

    -Frinny

    Comment

    Working...