Link to home
Start Free TrialLog in
Avatar of brgdotnet
brgdotnetFlag for United States of America

asked on

How to save a java script "this" object in an asp.net hidden variable.

I have an asp.net button, and when it is pressed, it calls a Java Script function that will check all of the check boxes in GridView.
When the button is pressed it pass the "this" object/pointer to the function which checks all of the check boxes.

I am wondering, is their a way to save the "this" pointer/object in a hidden variable so that I can access it at a later time?
On this same web form I also have java script/DIV popup dialog box. I want to call. When the popup dialog box is opened,
I also need to pass the this pointer, but I need to somehow save that object for use later. Can it be stored in a hidden variable?

<asp:Button ID="btnCheckAll" Text = "Check All" runat="server" OnClientClick=CheckAllCheckBoxes(objRef); return false;" />

function CheckAllCheckBoxes(objRef)
{

  var row = objRef.parentNode.parentNode;
  var GridView = row.parentNode;

  var inputList = GridView.getElementsByTagName("input");
  for(var i = 0; i < inputList.length; i++)
   {
   


   }


}
ASKER CERTIFIED SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

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
Avatar of brgdotnet

ASKER

Thank you LVL51 Sir. I won't be able to test this out until tomorrow. Do you know if the value can be saved in an asp.net control as well, such as a hidden variable or or hidden text box etc?
no, it is a dom object

but you can store id to a hidden var

<asp:hiddenvalue id=myObj />

var button;
function CheckAllCheckBoxes(objRef){
  button = objRef; // on client use
  document.getElementById("<%=myObj.ClientID%>") = objRef.id; // on server use, store the id
  ...
}

Open in new window