弹出窗口的按钮未触发父页面按钮单击事件 [英] popup window's button not firing the parent page button click event

查看:68
本文介绍了弹出窗口的按钮未触发父页面按钮单击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在父页面中有一个按钮ImageButton10。在弹出窗口中,出现一个OK按钮。我想在子页面或弹出窗口的OK按钮触发时触发ImageButton10_click事件。这该怎么做。请帮忙。



我的代码如下

儿童页面

I have a button ImageButton10 in a parent page. In the popup window a button OK is present. I want fire ImageButton10_click event when the OK button of child page or popup window will fire. how to do this. Please help.

My code is as follows
In child page

<script type="text/javascript" language="javascript">
    function RefreshParent() {
        document.getElementById('ImageButton10').Click();
        window.close();
    } 
</script>




<asp:Button ID="Button2" runat="server"  Text="Ok" 

            Width="123px" onclientClick="RefreshParent();" />





父母



Parent

protected void ImageButton10_Click(object sender, ImageClickEventArgs e)
    {
        con.Open();
        string query = "select distinct Contact_Name from Contact where Account='" + TextBox2.Text + "'";
        DataTable dt = new DataTable();
        SqlDataAdapter adpt = new SqlDataAdapter(query, con);
        adpt.Fill(dt);
        DropDownList6.DataSource = dt;
        DropDownList6.DataTextField = "Contact_Name";
        DropDownList6.DataValueField = "Contact_Name";
        DropDownList6.DataBind();
        con.Close();
        DropDownList6.Items.Insert(0, "<--Select-->");
    }

推荐答案

删除你的javascript代码,并将onclick属性添加到你的按钮,如下所示



remove your javascript code and add the onclick attribute to your button as below

<asp:button id="Button2" runat="server" text="Ok"

            Width="123px" OnClick="ImageButton10_Click"  ></asp:button>





你不想调用脚本调用服务器端代码。



you dont want to call script to calling the Server side code.


这篇关于弹出窗口的按钮未触发父页面按钮单击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆