RadWindow close and redirect

5 posts, 1 answers
  1. Alin
    Alin avatar
    26 posts
    Member since:
    Mar 2011

    Posted 17 May 2011 Link to this post

    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.
  2. Answer
    Marin Bratanov
    Admin
    Marin Bratanov avatar
    4931 posts

    Posted 17 May 2011 Link to this post

    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.

  3. Alin
    Alin avatar
    26 posts
    Member since:
    Mar 2011

    Posted 17 May 2011 Link to this post

    Ok,

    Thx a lot , I'll try this.
  4. Alin
    Alin avatar
    26 posts
    Member since:
    Mar 2011

    Posted 17 May 2011 Link to this post

    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.
  5. Alin
    Alin avatar
    26 posts
    Member since:
    Mar 2011

    Posted 17 May 2011 Link to this post

    I found that 

    window.top.location.href
     resolves the problem :)
Back to Top