简体   繁体   中英

How to click a button from parent page in pop-up child window using javascript?

I am trying to click a button in parent page from pop-up child window. The parent page uses a master page while the child window doesn't. My code works whenever the parent page has no master page but when there is it didn't.

Below is my code.

function clickParent()
{
  document.getElementById('<%=btnclick.ClientID %>').click();
}

function callClick()
{
  window.opener.clickParent();
}

I call the callClick() function in child page button like this..

ScriptManager.RegisterClientScriptBlock(Me.Page, Me.[GetType](), "parentRel", "clickParent();", True)

Thanks in advance.

This is because, when we add master page all the id will be contactinated with some additional string . To avoid this add attribute ClientIdMode="Static" to all the asp controls. Eg:

    <asp:TextBox ID="TextBox1"  ClientIDMode="Static" runat="server"></asp:TextBox>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM