Question

I want to use __doPostBack javascript function.

__doPostBack(obj.UniqueID,'');

But I only know ClientID of my object -

ctl00_cpholder_myObjId 
document.getElementById("ctl00_cpholder_myObjId").id //This will get ctl00_cpholder_myObjId,but UniqueID is ctl00$cpholder$myObjId

How can I get UniqueID for PostBack? Can I simply replace '_' with '$'?
Thank u.

Was it helpful?

Solution

If you have client id and want to get unique id from javascript, you can try

var uniqueId = document.getElementById("ctl00_cpholder_myObjId").name;

or

var uniqueId = document.getElementById("ctl00_cpholder_myObjId").getAttribute("name");

name property will return unique id.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top