This is a migrated thread and some comments may be shown as answers.

RadWindow close and redirect

4 Answers 452 Views
Window
This is a migrated thread and some comments may be shown as answers.
Alin
Top achievements
Rank 1
Alin asked on 17 May 2011, 11:46 AM
Hello

I want to redirect to anther page after clicking a button in a radwindow popup, but the redirected page is loaded in the radwindow popup, which is what I want to avoid. The code I use in java script to open the popup is this:
function CloseAndRebind(){
 GetRadWindow().close();return false;
}
 function GetRadWindow() {
 var oWindow = null;<br>               
 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 as well)
 return oWindow;
}
function CancelEdit() {
GetRadWindow().close();
}
........
<telerik:RadButton ID="GoProcessBtn" runat="server" Width="32px" Height="32px"
  OnClick="ProceedBtn_OnClick" AutoPostBack="true"
  OnClientClicked="CloseAndRebind" ToolTip="Proceed" 
Text="Proceed">
<Image ImageUrl="Images/1305562168_Next.png" /><br>                   
</
telerik:RadButton>
<telerik:RadButton ID="CancelBtn" runat="server" Width="32px" AutoPostBack="false" Height="32px"
ToolTip="Cancel" Text="Cancel" OnClientClicked="CancelEdit">
<Image ImageUrl="Images/1305540585_gtk-dialog-error-hover.png" />
</telerik:RadButton>

And in the code behind of the page of the popup, I have this code attached to the clik event of ProcessBtn:
protected void ProceedBtn_OnClick(object sender, EventArgs e)
 { 
//hammer
ChannelId = GoProcessBtn.CommandName;
if(string.IsNullOrEmpty(ChannelId))
return;
Response.Redirect("~/ProcessGridEditing.aspx?Channel=" +
ChannelId + "&Version=" + VersionsListBox.SelectedValue);
}

Can you plz tell me what I could do to avoid this problem?
What actually happens is that the popup closes and the redirect isn't happening at all!
I guess is because of the "return false;" i put in javascript CloseAndRebind function.
Thx a lot.

4 Answers, 1 is accepted

Sort by
0
Accepted
Marin Bratanov
Telerik team
answered on 17 May 2011, 12:29 PM

Hi Alin,

Generally you cannot have both a client-side and a server-side event handlers on a button. Indeed, the return false; statement will prevent the postback. What I can suggest is that you redirect the user on the client side by using the window.location object of the main window (for which you get a reference through the BrowserWindow property of the RadWindow) in the CloseAndRebind() function. You can pass the required parameters from the server in a hidden field when the page is loaded and use them to build the desired URL.



Best wishes,
Marin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Alin
Top achievements
Rank 1
answered on 17 May 2011, 12:47 PM
Ok,

Thx a lot , I'll try this.
0
Alin
Top achievements
Rank 1
answered on 17 May 2011, 03:16 PM
Hey, could you plz give me a concrete example of the redirection?
I tried something like this

var selectedItem = null;
            var version = null;
            function CloseAndRebind() {
                //GetRadWindow().BrowserWindow.refreshGrid(args);
                var Channel = document.getElementById('ChannelHiddenId').value;
                if (selectedItem != null)
                    version = selectedItem.get_text();
                else {
                    var lb = $find('VersionsListBox');
                    version = lb.get_value();
                }
                //GetRadWindow().close();
                window.location = "http://localhost:37100/ProcessGridEditing.aspx?Channel=" + Channel + "&Version=" + version;
                //return false;
            }

But the redirection is just not working! If I uncomment //GetRadWindow().close();, the call gets to page ProcessGridEditing.aspx, with the ok parameters, but nothing happens
in the browser, no refresh. I tested this in debugging mode, of course.
Thx in advance.
0
Alin
Top achievements
Rank 1
answered on 17 May 2011, 03:32 PM
I found that 

window.top.location.href
 resolves the problem :)
Tags
Window
Asked by
Alin
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Alin
Top achievements
Rank 1
Share this question
or