Click here to Skip to main content
14,735,283 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have some javascript function like this-
function updateVaues(paramValues)
{
  document.getElemntById('<%= txtRequisitionNo.ClientID %>').value=paramValues[0];
 //to fill gridviewItem I am calling c# method from javascript as--
  <% fillGrid(paramValues[0]); %>

}


But I am getting error that paramValues does not exist

Then how can I pass paramValues[0] to fillGrid() in c#
Posted
Updated 15-Feb-14 7:43am
v4

You cannot do it. Just think about it: Javascript is executed on client side, and C# code is one the server side. Whatever happens between client and server side could be anything but not "call". The server-side code only works in response to some HTTP request from the client side. In particular, you can use Ajax to send a request. Please see:
http://en.wikipedia.org/wiki/Ajax_%28programming%29[^].

One convenient way to send an HTTP request using Ajax is using jQuery .ajax():
https://api.jquery.com/jQuery.ajax[^].

—SA
   
   
v2
Comments
neelamblue 15-Feb-14 12:55pm
   
function called within-
http://www.aspsnippets.com/forums/Articles/Pass-function-as-argument-or-parameter-in-JavaScript.aspx[^]
are of javascript But I need to pass javascript variable to C# method
   
v2

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