Yesterday some one mail me and asked, how to pass javascript value to server side.Passing javascript value thought server side is very simple.
Here’s is the solution
Following is the Default.aspx page script
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>How to pass Javascript value to Server Side</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#<%=btnClick.ClientID %>").click(function () {
$("input[id='hPassvalue']").val("welcome to aspxtutorial.com");
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="hPassvalue" type="hidden" runat="server" />
<asp:Button ID="btnClick" runat="server" OnClick="btnClick_Click" Text="Click" />
</div>
</form>
</body>
</html>
Following is the Default.aspx.cs page script.
protected void btnClick_Click(object sender, EventArgs e)
{
Response.Write(hPassvalue.Value.ToString());
}
Output

Download
Pass Javascript value to Server Side.zip (1.02 kb)
Live demo