How to set c# variable value in javascript

Unknown | 10:00 AM |

Here is the our aspx page that contains a JavaScript method and a hidden filed and button.
<script type="text/javascript">
  function SetValue() {
    var sValue = "Hello World";
    document.getElementById("Hidden1").value = str;
  }
</script>
<html>
  <head>
    <title>How to set c# variable value in javascript</title>
  </head>
  <body>
    <div>
      <asp:hiddenfield id="hdnVlaue" runat="server"></asp:hiddenfield>
      <asp:button id="btnClick" runat="server" onclientclick="SetValue()" onclick="&rdquo;" text="Click Me">         </asp:button>
    </div>
   </body>
</html>

Now in the click event of the btnClick, we will set value received by JavaScript function

protected void btnClick_Click(object sender, EventArgs e)
{
  string sValue = hdnVlaue.Value;
  Response.Write("The Received Value is " + sValue);


}

Category:

About http://dotnetvisual.blogspot.in/:
DOT NET TO ASP.NET is a web application framework marketed by Microsoft that programmers can use to build dynamic web sites, web applications and web services. It is part of Microsoft's .NET platform and is the successor to Microsoft's Active Server Pages (ASP) technology. ASP.NET is built on the Common Language Runtime, allowing programmers to write ASP.NET code using any Microsoft .NET language. create an application very easily ....