Click here to Skip to main content
15,903,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How i can send any variable value from jvascript function to c# code function in asp.net
Posted
Updated 11-Jan-10 19:51pm
v3

use Hidden fields for this

set output of your javascript code in your hidden field

than in csharp function access value of that hidden field
 
Share this answer
 
The other option is to make an AJAX call, which will call your code behind.
 
Share this answer
 
anyone can explain me in detail plz... :omg:
 
Share this answer
 
If you are going to use hidden field techniqe

than

when you call javascript than assign value by

document.getElementById("hiddenfieldid").value = "yourvalue";




on server side code means in c# code you access this hiddle field

hiddenfieldid.value or may be hiddenfieldid.text and get value



for this thing to work u have to make hiddenfield runtat server
 
Share this answer
 
i got the Answer yepee... :laugh:

<script type="text/javascript">
function confirmdelete()
{
document.getElementById("hans").value = confirm("Are u Sure u want to delete");
var i = document.getElementById('hans').value;
}

</script>


<input type="hidden" id="hans" runat="server" />


nw u can access the variable hans at server side
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900