呼叫按钮单击事件从一个Web表单到另一个 [英] Call button click event from one web form to another

查看:95
本文介绍了呼叫按钮单击事件从一个Web表单到另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个web application.which包含多个Web表单。
我需要的是:我的web表单包含酮IFrame中(这将打开另一个aspx页面很少文本框和按钮控制)与关闭按钮

I am developing a web application.which contains multiple web forms. What i need is :-one of my web form contains IFrame (which will open another aspx page with few Textbox and button controls) with close button.

    If i click on the button in the child form(Iframe form), once complete its action it should call the close button function of the parent form.

here is the code.

父窗体code

Parent form code

protected void BTNCClose_Click(object sender, EventArgs e)
            {
                MethodToExecute();
            }
            public void MethodToExecute() //call this method
            {
                UPCCharges.Update();
                if (HttpContext.Current.Session["CCost"] != null)
                {
                    TxtCCost.Text = Session["CCost"].ToString();
                }
                if (HttpContext.Current.Session["CYeild"] != null)
                {
                    TxtCYeild.Text = Session["CYeild"].ToString();
                }
                if (HttpContext.Current.Session["CName"] != null)
                {
                    TxtCName.Text = Session["CName"].ToString();
                }
                if (TxtCName.Text != "" && TxtCYeild.Text != "" && TxtCCost.Text != "")
                {
                    TxtCrJobId.Text = Session["CJobID"].ToString();
                    Session.Remove("CCost"); Session.Remove("CYeild");
                    Session.Remove("CName"); Session.Remove("CJobID");

                }
                Diva.Visible = false;
                IFMC.Visible = false;

            }

这是子窗体(在iFrame中)

and this is child form(inside the IFrame)

protected void BTNCCloseChild_Click(object sender, EventArgs e)
{                
    for (int vLoop2 = 0; vLoop2 < gvInner.Items.Count; vLoop2++)
    {
       if (TxtTotalCFrom1 != null && TxtTotalCFrom2 != null)
       {
           TextBox TxtTotalCFrom = (TextBox)gvInner.Items[vLoop2].FindControl("TxtTCFrom");
           TextBox TxtTotalCYeild = (TextBox)gvInner.Items[vLoop2].FindControl("TxtTCYeild");
           Session["CCost"] = (mobjGenlib.ConvertDecimal(TxtTFrom1.Text) + mobjGenlib.ConvertDecimal(TxtTFrom2.Text)).ToString();
           Session["CYeild"] = (mobjGenlib.ConvertDecimal(TxtRO.Text) - mobjGenlib.ConvertDecimal(TxtTFrom.Text)).ToString();
           Session["CName"] = gvInner.Items.Count.Items[vLoop2].Cells[1].Text;
           Session["CJobID"] = gvInner.Items.Count.Items[vLoop2].Cells[2].Text;
       }
    }

 //after this i want to call that parent form BTNCClose_Click
}

任何一个可以帮助我提前来解决这个感谢。

can any one help me to solve this thanks in advance.

推荐答案

这是可以处理的一种方式。

This is one way that you can handle

在子窗体的 BTNCCloseChild_Click 事件,在末尾加上以下code

in the BTNCCloseChild_Click event of the child form, add the following code at the end

string script =@"$('the selector of your parent window button',
                    window.parent.document).click();";
Page.ClientScript.RegisterStartupScript(this.GetType(), "CloseParent", script);

您必须改变'你的父窗口按钮选择,Appro公司以$ P $颈部jQuery选择唯一选择父窗体的按钮。

You have to change the 'the selector of your parent window button', to appropreate jquery selector to uniquely select the button of the parent form.

您可能需要使用 window.top 而不是 window.parent ,如果有在嵌套的iframe。

You may have to use window.top instead of window.parent, if there are nested iframes.

这篇关于呼叫按钮单击事件从一个Web表单到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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