.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

How to pass values from Javascript to code behind code function?

Posted By: Ram     Posted Date: February 10, 2015    Points:5   Category :C#
Hi,

Please explain in detail that how to pass parameter values from javascript to c#.code function?

For example:

When i click button i need to call this function through javascript and pass values for x and y should be from javascript...

.cs
public void Add(int x,int y)
{
int k=x+y;
}




Responses
Author: Amit Mehra             
Posted Date: February 11, 2015     Points: 20   

Hi,

Try like this

In Javascript function

function AddFronJS()
{
var a=5,b=10;

//Call server side function
<% Add(a,b)%>

}


Hope this helps


Thanks,
Amit
Please "Mark As Answer " if this post help you.
Author: Alankar             
Posted Date: April 06, 2015     Points: 20   

Hi Ram,

You can post your data to the server using javascript

you can go through below URL where you'll get sample code for posting data in ASP.NET application.


http://www.codeproject.com/Tips/832696/How-to-send-Data-from-JavaScript-to-Csharp-Server

Author: Debendra             
Posted Date: January 22, 2016     Points: 20   

http://stackoverflow.com/questions/25707198/pass-a-value-to-a-javascript-function-from-c-sharp-code-behind
http://www.codeproject.com/Questions/727946/how-to-pass-parameter-to-csharp-method-from-javasc
http://www.codeproject.com/Questions/804996/how-to-pass-csharp-function-return-value-as-parame
http://stackoverflow.com/questions/25707198/pass-a-value-to-a-javascript-function-from-c-sharp-code-behind




Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend