welcome Netizen

Share Your Knowledge.It is a way to achieve immortality

Thursday, April 26, 2012

Get Java Script Variables values at code behind in


Here you have to see the process to get the JavaScript Variables values at sever side by using the below code..
First you have to write the script function to pass the value in variable..

<script type="text/javascript">
        function ret() {
            var t = document.createElement("INPUT");
            t.type = "hidden";
   = "t";

            t.value = "Get the value on server side";

Then we need to call the function onclient click button event……

<asp:Button ID="Button3" runat="server" Text="Button"  OnClientClick ="ret();" />

Finally we get the data in code behind by using below code..

Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim str As String
        str = Request.Form("t")
        lbltxt.Text = str
    End Sub
 I hope you like the easy way to get the JavaScript variable at code behind..
Post your comments.


Post a Comment