2015-02-24 67 views
0

我正在开发一个Web应用程序,它包含多个Web窗体。 我需要的是:我的网页表单中的一个包含IFrame(它将打开另一个带有几个文本框和按钮控件的aspx页面),并带有关闭按钮。呼叫按钮单击事件从一个Web窗体到另一个

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. 

父窗体代码

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中)

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 
} 

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

回答

1

这是你可以在BTNCCloseChild_Click事件子窗体的处理

的一种方式,在最后添加如下代码

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

你必须改变“你的父母的选择窗口按钮',以appropreate jquery选择器来唯一选择父窗体的按钮。

如果存在嵌套的iframe,则可能必须使用window.top而不是window.parent

+0

谢谢对冲!!!!! – Appdev 2015-02-25 04:46:41

-2

添加此行:

ScriptManager.RegisterStartupScript(此的typeof(字符串), “脚本”, “parent.location.href = parent.location.href;”,假);

在此之后或代替该 //在这之后,我想调用父窗体BTNCClose_Click

在会话对象存储的值将刷新父页面和值将被更新后。

相关问题