how to pass the "this" object from C# to a Java Script function.

brgdotnet used Ask the Experts™
In my markup, If I pass the "this" pointer to my java script function, I am able to access the controls in my GridView control. See below code (Existing Code). What I really need to do though is to not pass the "this" object through but through C#. So how is the "this" pointer accessed through C#? considering I will pass it to a Java script function from C#? I know how to pass variables from C# to java script, but I just don't know how to access the "this" object.

Existing code :
<asp:button ID = "btnConfirmAll" Text="Confirm" runat="server" OnClientClick="processFunc(this); return false;" />

function processFunc(objRef)
  var row = objRef.parentNode.parentNode;
  var GridView = row.parentNode;
  var inputList = GridView.getElementsByTagName("input");

  for( var i = 0; i < inputList.length; i++)


Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Ryan ChongSoftware Team Lead

What I really need to do though is to not pass the "this" object through but through C#.
Not quite understand what you trying to mention here. can you elaborate further by giving some scenarios?
Most Valuable Expert 2017
Distinguished Expert 2018
You can't (in the strict sense) pass anything from C# to JavaScript - they run in two different time separated environments.

C# runs - generates HTML - then JavaScript runs.

The way you have it at the moment is you are generating JavaScript code that passes the JavaScript 'this' of the control to a JavaScript function - no C# there.

What is it you want to do differently and why - what are you trying to achieve?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial