开发者

Find the Masterpage Id of a control in content page

I have a control of id "C_44" in content page. I am stuck on how to find the rendered control id in master page using javascrip开发者_运维技巧t

Thanks


Since id's have to be unique, you should be able to document.getElementById('C_44');

However, if you 'insist' on searching through the children of the master control, try this:

var master = document.getElementById('masterId');
var children= master.childNodes;
for(var i = 0; i < children.length; i++)
{
  if(children.item(i).id == 'C_44')
  {
    //use child
  }
}


You can do this in two ways.

If you are using Asp.net 4, then you can set the clientidmode to static on the control. Then you would be able to access it with the same id.

The other approach is to make use of control.ClientId property. You can inject the clientid of the control as a javascript variable and use that variable in javascript.

Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜