Click here to Skip to main content
15,896,912 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Scenario-

In Parent window : a gridview is there

column1  column2  column3
 
 a         b       linkbutton1

 c         d       linkbutton2



when clicked on linkbutton a child window popus up. i add something. And then close the child window[no button is made in child window to close..just normal close].

Again i click on linkbutton to check whether what i have added is there or not. but i dont find.

But if i log out completely from the application...again navigate to the parent page...and click on link button i find the thing that i added in child window is there...


--So is it like parent window is not refreshing when child window is closed. How to tackle this ? kindly help .


---------------------------------------------------------------------------------------
Parent page code :

protected void gridShuttleAdmin_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //onmouse over and mouse out on the grid color changes
            e.Row.Attributes.Add("onmouseover", "this.previous_color=this.style.backgroundColor;this.style.backgroundColor='PaleGreen'");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.previous_color;");

            Label lbltrip = (Label)e.Row.FindControl("lbltrip");
            if (lbltrip != null)
            {
                Label lblshuttledetailname = (Label)e.Row.FindControl("lblshuttledetailname");
                Label lblshuttlefacilityid = (Label)e.Row.FindControl("lblshuttlefacilityid");
                Label lblfacilityid = (Label)e.Row.FindControl("lblfacilityid");
                LinkButton lbtn = (LinkButton)e.Row.FindControl("lnkviewID");
                lbtn.Attributes.Add("onClick", "var sFeatures='dialogHeight: 700px;dialogWidth: 1000px;'; window.showModalDialog('Shuttle_StopDetails.aspx?shuttlefacilityid=" + lblshuttlefacilityid.Text + "&facility=" + lblfacilityid.Text + "&Trip=" + lbltrip.Text + "','',sFeatures);window.document.forms[0].submit();");

            }
        }
    }


--------------------------------child page------------------------------------------------
 protected void gridShuttleDetails_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "AddNew")
        {
            int identityCreated;
            TMS.Business.ShuttleStopDetails ObjShuttleStopdetails = new TMS.Business.ShuttleStopDetails();
            TMS.API.ShuttleMaster.ShuttleMaster_IN objShuttleRouteManager = (TMS.API.ShuttleMaster.ShuttleMaster_IN)FillObjectFromScreen();
            int index = gridShuttleDetails.Rows.Count - 1;
            GridViewRow row = gridShuttleDetails.Rows[index];
            var Departurtime = ((Label)row.FindControl("lblDeparture")).Text;
            var lblFacilityNamecheck = ((Label)row.FindControl("lblFacilityName")).Text;
            if (lblFacilityNamecheck != "" && (objShuttleRouteManager.Shuttle_Facility_Name == lblFacilityNamecheck))
            {

                //ScriptManager.RegisterStartupScript(Page, typeof(Page), "", "alert('" + System.Configuration.ConfigurationSettings.AppSettings["Facility_Check"].ToString() + "');", true);

                ScriptManager.RegisterStartupScript(Page, typeof(Page), "", "alert('Please Enter A Different Facility')", true);

            }

            else
            {
                identityCreated = ObjShuttleStopdetails.Create(objShuttleRouteManager);

                if (identityCreated > 0)
                {
                    ScriptManager.RegisterStartupScript(Page, typeof(Page), "", "alert('" + System.Configuration.ConfigurationSettings.AppSettings["Save_Record"].ToString() + "');", true);
                    BindShuttleDetails();
                    UpdatePanel1.Update();

                }
                
            }
        }
    }


I am closing on top right >< of child winow.
Posted
Updated 25-Oct-13 2:39am
v4
Comments
Sergey Alexandrovich Kryukov 24-Oct-13 16:51pm    
Please show what did you try to refresh the parent page. We had a discussion here: somebody argued that different windows become fully independent, but I demonstrated that it's quite possible to modify something in the parent window from the child one, on the client side.
—SA
anurag19289 25-Oct-13 7:53am    
question updated : in parent page

lbtn.Attributes.Add("onClick", "var sFeatures='dialogHeight: 700px;dialogWidth: 1000px;'; window.showModalDialog('Shuttle_StopDetails.aspx?shuttlefacilityid=" + lblshuttlefacilityid.Text + "&facility=" + lblfacilityid.Text + "&Trip=" + lbltrip.Text + "','',sFeatures);window.document.forms[0].submit();");

then in child page on rowcommand adding a new item in the footer of grid view....and then closing the child window....and then clicking the linkbutton of parent window to check whether updated or not....
anurag19289 25-Oct-13 10:12am    
Hi Sergey-

I asked my lead regarding this doubt.

He told me to put this code

<%@ OutputCache Location="None" VaryByParam="none" %> .

And it worked. But i m not clear exactly why we need this. It would be a greate help if you explain me this.

Please see my comment to the question. On the client side, you can do some manipulations on the parent browser window from the JavaScript on the child. To access a parent window, you need to use the property window.parent:
http://www.w3schools.com/jsref/prop_win_parent.asp[^],
see also: http://www.w3schools.com/jsref/dom_obj_document.asp[^].

This way, you can get access to window and its document object and directly manipulate DOM elements of the parent document.

—SA
 
Share this answer
 
please write a function in javascript in parent page which will reload the page .

Example:
function reloadParent()
{
window.location.reload();
}
The in your child page just call opener.reloadParent(); in javascript after you finish your operation in child page.
 
Share this answer
 
Comments
anurag19289 25-Oct-13 7:45am    
Let me try this and get back to you...
thatraja 25-Oct-13 7:53am    
That'll work
anurag19289 25-Oct-13 7:57am    
Hi bikram-

The in your child page just call opener.reloadParent(); in javascript after you finish your operation in child page.

where to write this exactly..

In the rowcommand event of gridview : the data is inserted

if (identityCreated > 0) {

ScriptManager.RegisterStartupScript(Page, typeof(Page), "", "alert('" + System.Configuration.ConfigurationSettings.AppSettings["Save_Record"].ToString() + "');", true);

BindShuttleDetails();

UpdatePanel1.Update();
}

Then shall i write after updatepanel1.update();? Kindly help
anurag19289 25-Oct-13 8:53am    
Parent page is refreshing but....if i click on parent page link button and check in child window the new item which i recently added..i dont find....

i log out and log in again and navigate to that page and click on linkbutton. I find the record is inserted....

what can be the issue...even if i hit search button and populate the grid and click on the link button ...i find the new data is not inserted......but if i close the application and login and navigate to the page and click on link button ..then i find that record
anurag19289 25-Oct-13 10:13am    
<%@ OutputCache Location="None" VaryByParam="none" %> .

This when i put in child window...now its working

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900