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.

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top