I have a parent page that launches a telerik radwindow. Every thing works well. My problem is when the radwindow closed, the parent reload again. I don't want this. how can I close radwin
Once the radwindow is done processeing the value, I need it to return it to the parent page, and I would like the parent page to have access to this value in my code开发者_StackOverflow社区 behind page.
Parent ASPX:
<telerik:RadWindowManager ID="RadWindowManager1" runat="server" DestroyOnClose="true" Width="750px" Height="500px" OnClientClose="onClientClose">
<windows>
<telerik:RadWindow ID="RadWindow1" runat="server">
</telerik:RadWindow>
</windows>
</telerik:RadWindowManager>
<%-- RadAjaxManager --%>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
<ajaxsettings>
<telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadAjaxManager1" />
<telerik:AjaxUpdatedControl ControlID="RadGrid1" />
</UpdatedControls>
</telerik:AjaxSetting>
</ajaxsettings>
</telerik:RadAjaxManager>
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
// Insert in RadWindow
function showForm(url) {
window.radopen(url, "RadWindow1");
return false;
}
function onClientClose(oWnd, args) {
// get the transferred arguments
var arg = args.get_argument();
if (arg == '' || arg == null) {
// No need to refresh RadGrid
}
else {
$find("<%= RadAjaxManager1.ClientID %>").ajaxRequest(arg);
}
}
</script>
</telerik:RadCodeBlock>
Parent Code Behind:
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
{
var result = Int32.Parse(e.Argument); // return argument from child
}
Child ASPX
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
//mandatory for the RadWindow dialogs functionality
function getRadWindow() {
if (window.radWindow) {
return window.radWindow;
}
if (window.frameElement && window.frameElement.radWindow) {
return window.frameElement.radWindow;
}
return null;
}
// Fires when the changes are saved
function onClientClose(arg) {
// Pass the arguments from the dialog to the callback function on the main page.
getRadWindow().close(arg);
}
</script>
</telerik:RadCodeBlock>
Child code behind
protected void ChildSave_Click(object sender, EventArgs e)
{
ClientScriptManager cs = Page.ClientScript;
cs.RegisterStartupScript(typeof(Page), "CloseScript_" + UniqueID,
"onClientClose('1');", true); // Return value 1 to parent
}
Have you added a OnClientClose javascript to take the control from the open window?
Just check this out.
Actually Telerik's support is pretty good on these matters (one of the best i've seen) and you should post your question in their forum if you do not get anything favorable here.
As Bumble Bee said, you most probably have either a function hooked to OnClientClose that submits the page, or you are calling something like GetRadWindow().BrowserWindol.location.reload() from the content page.
You say however, that you want to have the value in parent's page code behind. To do this, you will have to make a trip to the server. Since you don't want to reload the page, the easiest way to do this is to use Ajax - and if you are using RadControls, there is a RadAjaxManager to help you in this task :)
What you could do is to fire an Ajax request on the parent page, that will use RadAjaxManager's client-side API to fire an Ajax request, which will get you the data on the server. A scenario, similar to yours is shown in this demo. In it, when a RadWindow is closed (in the content page), we call a JavaScript function in the parent page, that fires the Ajax request via RadAjaxManager and rebinds the grid on the server - all is done without postbacks. Check these help articles for more information on the subject:
- http://www.telerik.com/help/aspnet-ajax/ajax-client-side-api.html
- http://www.telerik.com/help/aspnet-ajax/window-programming-calling-functions.html
- http://www.telerik.com/help/aspnet-ajax/window-programming-using-radwindow-as-dialog.html
精彩评论