Click here to Skip to main content
15,889,335 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am calling a javascript function on button click using onclientclick with below function.

arrValue array will have all the required values and how can I move this array values to server side for further process.


What I have tried:

function addValues() {
       debugger;
       var arrValue = [];
       var hdnValue = document.getElementById("hdn").value;
       var strValue = hdnValue.split(',');
       for (var i = 0; i < strValue.length; i++) {
           var ddlValue = document.getElementById(strValue[i]).value;
           arrValue.push(ddlValue);
       }
   }
Posted
Updated 8-Jan-18 23:19pm
Comments
Karthik_Mahalingam 9-Jan-18 5:27am    
pass the data on postback or ajax call?

Google is your friend: Be nice and visit him often. He can answer questions a lot more quickly than posting them here...

A very quick search gave nearly half a million hits: Pass array from javascript to server side c# - Google Search[^]

In future, please try to do at least basic research yourself, and not waste your time or ours.
 
Share this answer
 
You can use Ajax.

$.ajax({
   type: "POST",
   data: {arrValue :arrValue },
   url: "index.aspx",
   success: function(msg){
     
   }
});


Or use like below

[^]

please up vote if the solution works out of 5
 
Share this answer
 
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