aspx Tutorial

NET Articles,jQuery demo, asp.net with jQuery, online tutorial,Jquery, SilverLight, Javascript, asp.net,JSON, MVC,.NET Articles,demo, Web Services,
Advertise Here

Toolbar

Get our toolbar!

Advertize



Posted by Aamir Hasan   on Wednesday, November 10, 2010 Total Views:  

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

Protected by Copyscape Online Plagiarism Tool

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Advertizement 1
Advertizement 2
Advertizement 3
Advertizement 4
Advertizement 5