Click here to Skip to main content
15,070,139 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hiii all
i need to call c# function from javascript function i tried on it and i found a bit problem my javascript function was;
function test()
'<%fillSession(); %>

and give that function to
<br />
<input id="btn_Chat" type="button" value="Start Chat" onclick="test()"  /><br />

and my C# function is normal function.

The problem here is that this function is loaded in the page load and by default an exception appears. i need to load it in the click of the button.

Any help, please???


Make a webmethod on your page or make a service then call your method

moon2011 3-Jul-11 4:48am
Thanks A lot for Your help.
You can use Page Method call

Please look below link[^]

You need to read a book on ASP.NET. A basic one. All your javascript is executed in your browser. It doesn't matter where your code is, the server stuff ends BEFORE the javascript runs, and js CANNOT see methods on the server. You can read up on AJAX, but given that you made this mistake, I'd assume that's too complex for you, and you're generally out of your depth. Buy a book.

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