Link to home
Start Free TrialLog in
Avatar of godcomputer
godcomputer

asked on

how do i get data back from a function call to javascript function back to asp .net

i have a listview control and it will fire a javascript call
function HighlightRow(nListID)
                  {
                        if (document.getElementById("lv_chk_lvi_" + nListID).checked==true)
                              document.getElementById("lv_row_" + nListID).style.backgroundColor='#ccccff';
                        else
                              document.getElementById("lv_row_" + nListID).style.backgroundColor='#ffffff';
                  }
when in asp .net i have this
ListItem.CheckBoxDHTML = "onclick=javascript:HighlightRow('#LVI#')"

what i want to do is when i select a button. and call a function thats javascript that will go in and return the values of the checked items on the asp.net listview control.

i want to basically end up returning an array of values from a a javascript function that will tell me which IDs of the listview have been selected.
Avatar of JerSchneid
JerSchneid

Are these checkboxes in your ListView that the user is clicking?

Will the user eventually click a "submit" or "save" button that will post back to the page?

If so, you can just loop through the rows in the ListView and check if each checkbox was checked when the user clicked the submit button.

For example:

for (int i = 0; i < _myListView.Items.Count; i++)
{
      if (((CheckBox)_myListView.Items[i].FindControl("_myCheckBoxInListViewRow")).Checked)
            //This checkbox was checked, so do something
}
Avatar of godcomputer

ASKER

the checkboxes are being created from a serverside control with a .write to the document page so for some reason i cant use findcontrol? its not finding my items.
ASKER CERTIFIED SOLUTION
Avatar of JerSchneid
JerSchneid

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial