I am using RadControl AJAX, I want to open a radwindow from code behind after some functions are handled, I try to use registerStartupScript as below:
and my aspx page is:
But it doesn't work. Any suggestions?
Thanks in advance!
string newWindowUrl = "Popups/Default1.aspx?WindowArgs=" + windowArgs;
string javaScript =
"<
script
type
=
'text/javascript'
>\n" +
"<!--\n" +
"var newwindow = window.radopen('" + newWindowUrl + "' +',' + 'RadWindow1');\n" +
"newwindow.focus();\n" +
"// -->\n" +
"</
script
>\n";
Page.ClientScript.RegisterStartupScript(t, "Email", javaScript);
<
telerik:RadWindowManager
ID
=
"RadWindowManager1"
ShowContentDuringLoad
=
"false"
VisibleStatusbar
=
"false"
EnableViewState
=
"true"
ReloadOnShow
=
"true"
runat
=
"server"
Skin
=
"Default"
EnableShadow
=
"false"
>
<
Windows
>
<
telerik:RadWindow
ID
=
"RadWindow1"
VisibleTitlebar
=
"false"
runat
=
"server"
Behaviors
=
"Close, Move, Resize"
AutoSize
=
"true"
NavigateUrl
=
"~/Popups/Default1.aspx"
>
</
telerik:RadWindow
>
</
Windows
>
</
telerik:RadWindowManager
>
But it doesn't work. Any suggestions?
Thanks in advance!
7 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 24 Mar 2011, 05:47 AM
Hello,
This issue is because the window does not appear because when the code is executed, not all controls on the page are fully rendered yet.
What you can do to avoid that is to use the Sys.Application.add_load function to hook to the
ShowWindow function to the load event
Take a look at the following links for more on this.
Open RadWindow in codebehind
Executing JavaScript function from server-side code
Another approach is by setting the VisiibleOnPageLoad property to true on the desired event.
Thanks,
Shinu.
This issue is because the window does not appear because when the code is executed, not all controls on the page are fully rendered yet.
What you can do to avoid that is to use the Sys.Application.add_load function to hook to the
ShowWindow function to the load event
Take a look at the following links for more on this.
Open RadWindow in codebehind
Executing JavaScript function from server-side code
Another approach is by setting the VisiibleOnPageLoad property to true on the desired event.
Thanks,
Shinu.
0
Shannnon
Top achievements
Rank 1
answered on 24 Mar 2011, 06:03 PM
Thank Shinu, that way does work but it only work for asp button but radButton, radwindow doesn't show. Why is that? I am using rad for AJAX.
Thanks.
Thanks.
0
Hello Shannnon,
How are you trying to open the RadWindow through the RadButton and the asp button respectively?
The code you provided with the first question does not require user interaction to open the window, so in order to help you I need to know what the scenario is.
At this point I can only guess, but you could be expecting a postback from the button to trigger the RadWindow, while the RadButton is probably configured to not postback (the UseSubmitBehavior or AutoPostBack property is set to false).
Kind regards,
Marin
the Telerik team
How are you trying to open the RadWindow through the RadButton and the asp button respectively?
The code you provided with the first question does not require user interaction to open the window, so in order to help you I need to know what the scenario is.
At this point I can only guess, but you could be expecting a postback from the button to trigger the RadWindow, while the RadButton is probably configured to not postback (the UseSubmitBehavior or AutoPostBack property is set to false).
Kind regards,
Marin
the Telerik team
0
Shannnon
Top achievements
Rank 1
answered on 25 Mar 2011, 08:27 PM
The way that this thread suggested does work, however, there is an issue using registerStartupScript to open RadWindow. My senario is this: I have a RadGrid associates with RadAjaxManager using RadAjaxLoadingPanel, after I close the popup RadWindow and continue to do something on the RadGrid that doesn't require postback such as paging and using RadFilter to filter the grid, the RadWindow show again because the showWindow() function writtern to the javascript is still there. i tried to use window.opener._doPostBack() or window.opener.location.reload() in onunload() in body tag in the popup page but I kept getting error "window.opner is undefined". BTW, I am not using MasterPage.
Please help me, thanks a lot!
Please help me, thanks a lot!
0
Hi Shannnon,
First of all window.opener is a reference created in child browser window when the window.open() function is used, but not in the case of RadWindow, as RadWIndow is actually a part of the page (either a div, or an iFrame, depending on the content).
To get a reference to the browser window from the RadWindow you can use the oWnd.BrowserWindow property, where oWnd is a reference to the RadWindow (either in code-behind, or obtained via JavaScript).
If you want to reload the main page after the RadWindow is closed you can use the following JavaScript function attached to the OnClientClose event of the RadWindow:
If that is not the case please specify what exactly is your intention and what is the showWindow() function that is causing you trouble.
All the best,
Marin
the Telerik team
First of all window.opener is a reference created in child browser window when the window.open() function is used, but not in the case of RadWindow, as RadWIndow is actually a part of the page (either a div, or an iFrame, depending on the content).
To get a reference to the browser window from the RadWindow you can use the oWnd.BrowserWindow property, where oWnd is a reference to the RadWindow (either in code-behind, or obtained via JavaScript).
If you want to reload the main page after the RadWindow is closed you can use the following JavaScript function attached to the OnClientClose event of the RadWindow:
function
closeWindow()
{
var
oWnd = $find(
"<%=RadWindow1.ClientID %>"
);
var
browser = oWnd.BrowserWindow;
browser.location.reload();
}
If that is not the case please specify what exactly is your intention and what is the showWindow() function that is causing you trouble.
All the best,
Marin
the Telerik team
0
David
Top achievements
Rank 1
answered on 22 Jul 2011, 12:24 AM
I have a RadWindow that I create in the aspx markup. It has a ContentTemplate with html markup inside that that I want displayed.
The markup the content for this window, so it does not have a navigateurl property set.
How do I open this RadWindow from C# in the code behind file.
I do not want to open it on PageLoad. I just want to open it on a buttonClick event from a button on the page.
All the code samples show how to open it via Javascript or in the codebehind on PageLoad using a RadWindowManager.
Thanks,
David
0
Hi David,
I would recommend injecting a JavaScript function from the server-side that will open the RadWindow. For more information on this approach please examine the following aricle: http://www.telerik.com/help/aspnet-ajax/radwindow-troubleshooting-javascript-from-server-side.html. How to open a RadWIndow via JavaScript is explained in the following article: http://www.telerik.com/help/aspnet-ajax/window-programming-opening.html.
Kind regards,
Marin
the Telerik team
I would recommend injecting a JavaScript function from the server-side that will open the RadWindow. For more information on this approach please examine the following aricle: http://www.telerik.com/help/aspnet-ajax/radwindow-troubleshooting-javascript-from-server-side.html. How to open a RadWIndow via JavaScript is explained in the following article: http://www.telerik.com/help/aspnet-ajax/window-programming-opening.html.
Kind regards,
Marin
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!