【问题标题】:How to click a button from parent page in pop-up child window using javascript?如何使用javascript在弹出的子窗口中单击父页面中的按钮?
【发布时间】:2014-11-13 19:57:42
【问题描述】:

我正在尝试从弹出的子窗口中单击父页面中的按钮。父页面使用母版页,而子窗口不使用。每当父页面没有母版页但没有母版页时,我的代码就可以工作。

下面是我的代码。

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

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

我像这样在子页面按钮中调用 callClick() 函数..

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

提前致谢。

【问题讨论】:

  • window.opener.location.href='' 试试这个
  • @RajeevMehta...那我要在“”里面放什么?

标签: javascript asp.net


【解决方案1】:

这是因为,当我们添加母版页时,所有的 id 都会与一些额外的字符串联系起来。 为了避免这种情况,将属性 ClientIdMode="Static" 添加到所有 asp 控件。 例如:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-31
    • 1970-01-01
    相关资源
    最近更新 更多