<%@ Page Language="C#" %> <script runat="server"> protected void btnGetVal_Click(object sender, EventArgs e) { Response.Write(hdStoreVal.Value); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title></title> <script type="text/javascript"> function btnSetVal_onclick() { var v = document.getElementById("txtValue").value; document.getElementById("hdStoreVal").value = v; //alert("done."); } </script> </head> <body> <form id="form1" runat="server"> <div> <asp:TextBox ID="txtValue" runat="server"></asp:TextBox> <asp:HiddenField ID="hdStoreVal" runat="server" /> <input id="btnSetVal" type="button" value="set value via javascript" onclick="return btnSetVal_onclick()" /> <asp:Button ID="btnGetVal" runat="server" Text="get value from C# " onclick="btnGetVal_Click" /> </div> </form> </body> </html>
Friday, 19 April 2013
jQuery: Session variable Set & Get value
You can’t set session in javascript. The javascipt is the operation of the client side. You should know the session is stored in server and you won’t get it in the client side. If you want to pass value you can use hidden field.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment