Close the Popup After Update [Resolved]

Posted by Vuyiswamb under ASP.NET AJAX on 2/22/2012 | Points: 10 | Views : 2572 | Status : [Member] [MVP] [Administrator] | Replies : 2
Good Morning All

I am Opening a Page as a Popup i am using Telerik WIndow which has similar functionality when opening a Popup like this

 function OpenPopUp(val_real, vis) {
var myWidth = 0, myHeight = 0;
if (typeof (window.innerWidth) == 'number') {
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
} else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
//IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;

myWidth = myWidth / 2 - 150;
myHeight = myHeight / 2 - 50;'MyPage.aspx?Val=' + val_read, 'width=700,height=160,top=' + myHeight + ',left=' + myWidth)
return false;


this "myPage.aspx" page has a button that person some updates to the Database on the server side. This is opened as a popup and there is a grid below , so what i want to do after the Update to the Database has happened , i want to refresh the Grid, i have this code

//This code is used to provide a reference to the radwindow "wrapper"
function GetRadWindow() {
var oWindow = null;
if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz az well)
return oWindow;

function CloseOnReload() {
//alert("Dialog is about to close itself");

function RefreshParentPage() {
//alert("Dialog is about to reload parent page");

function RedirectParentPage(newUrl) {
alert("Dialog is about to redirect parent page to " + newUrl);
GetRadWindow().BrowserWindow.document.location.href = newUrl;

function CallFunctionOnParentPage(fnName) {
alert("Calling the function " + fnName + " defined on the parent page");
var oWindow = GetRadWindow();
if (oWindow.BrowserWindow[fnName] && typeof (oWindow.BrowserWindow[fnName]) == "function") {

function RefreshParentPageWithoutWarning() {

and on the server side i have this

Response.Write("<Script>return RefreshParentPageWithoutWarning();</script>")



ScriptManager.RegisterStartupScript(Page, Me.GetType(), "", "RefreshParentPageWithoutWarning()", True)

My problem here is that it Refresh the page before it does a Database Update, and if it refreshes the page , the Database update ends up not being done.


Thank you for posting at Dotnetfunda


Posted by: Vuyiswamb on: 2/23/2012 [Member] [MVP] [Administrator] NotApplicable | Points: 25


no that part was in the save button , so i figuired it out

                Dim page As Page = HttpContext.Current.Handler

ScriptManager.RegisterStartupScript(page, page.GetType(), "err_msg", "CloseOnReload();", True)

Thank you for posting at Dotnetfunda

Vuyiswamb, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sheonarayan on: 2/22/2012 [Administrator] HonoraryPlatinum | Points: 25

Are you writing the RegisterStartup... code in the Page_Load, it should not be. You should write this into the Save method once all the database operation is done.

Alternatively after saving the record into the database, you redirect to the same page with some querystring, in the page_load check for the querystring and then write RegisterStartup......

Hope this helps.


Sheo Narayan

Vuyiswamb, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response