简体   繁体   English

如何使用javascript在弹出子窗口的父页面中单击按钮?

[英]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.. 我像这样在子页面按钮中调用callClick()函数。

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 . 这是因为,当我们添加母版页时,所有id都会与其他一些字符串联系在一起。 To avoid this add attribute ClientIdMode="Static" to all the asp controls. 为了避免这种情况,将属性ClientIdMode =“ Static”添加到所有asp控件。 Eg: 例如:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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