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.
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;
}
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
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);
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.
You may have to use window.top
instead of window.parent
, if there are nested iframes.
Add this line:
ScriptManager.RegisterStartupScript(this, typeof(string), "script", " parent.location.href = parent.location.href;", false);
after this or instead of this //after this i want to call that parent form BTNCClose_Click
After storing the values in session object it will refresh the parent page and the values will be updated.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.