Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a java script function which returns some value. and i have linkbutton_Click event. when i click on link Button i need to execute first java script function and must take value from it and execute C# code.


please give a solution with simple example
Posted
Updated 6-Oct-11 7:02am
v2

The only way for the JavaScript to call a server-side method is to use out of band techniques, such as a PageMethod. http://www.singingeels.com/Articles/Using_Page_Methods_in_ASPNET_AJAX.aspx[^]
 
Share this answer
 
Comments
Kartheek.chakrala 7-Oct-11 4:16am    
u guys giving c# code in javascript. but i need java script function in C# code.
[no name] 7-Oct-11 8:12am    
Your question wasn't very clear then if both didn't understand.

You can't call a JavaScript function from within C#. The best you can do is use RegisterClientScriptBlock
http://msdn.microsoft.com/en-us/library/bahh2fef.aspx
As Mark mentioned you need to use Page Methods mechanism in ASP.Net C#.

Check this out:

http://aspalliance.com/1922_PageMethods_In_ASPNET_AJAX.all[^]

hope it helps :)
 
Share this answer
 
v2
Comments
Kartheek.chakrala 7-Oct-11 4:16am    
u guys giving c# code in javascript. but i need java script function in C# code.

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