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

Navigate parent page from modalpopup

2 Answers 293 Views
Window
This is a migrated thread and some comments may be shown as answers.
vivek
Top achievements
Rank 1
vivek asked on 25 Jan 2009, 08:59 PM
I want to navigate to the different page on click of button which is on modal popup.When I do this through my existing code its opening the new page to same popup window , i want to open a new page to parent page and close modal popup.
default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Pages_Default" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <telerik:RadWindowManager ID="RadWindowManager1"  runat="server" style="z-index:8000" Behaviors="Close,Move,Reload" 
          Modal="true" Animation="None" ShowContentDuringLoad="true" VisibleOnPageLoad="true"
               Skin="WebBlue">
           <Windows>
                <telerik:RadWindow 
                            OpenerElementID=""     
                            Width="820px"                
                            Height="540px"
                            NavigateUrl="RoleList.aspx"
                            Runat="server" 
                            Id="Radwindow1" 
                            VisibleStatusbar="false" ClientCallBackFunction="CallParentRole" >
                </telerik:RadWindow> 
          </Windows>  
        </telerik:RadWindowManager>

    </form>
</body>
</html>


default.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Pages_Default : QMSPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
      
    }
  
}

Rolelist.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RoleList.aspx.cs" Inherits="RoleList" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    
    <script type="text/javascript">
    function CallParentRole(radWindow, returnValue)
        {
             
             document.getElementById("Button1").click();
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
     <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <table border="1" style="width:200px;">
        <tr>
            <td>
                <asp:RadioButtonList ID="rblRole" runat="server">
                </asp:RadioButtonList>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Button ID="btnGo" runat="server" Text="Go" onclick="btnGo_Click" />
            </td>
        </tr>
        </table>   
    </form>
</body>
</html>

RoleList.aspx.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class RoleList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            MembershipUser user = Membership.GetUser();
            if (user == null)
                Response.Redirect("~/login.aspx");

            string[] str = Roles.GetRolesForUser(user.UserName);
            if (str.Length == 0)
            {
                Response.Redirect("~/Logoff.aspx");
            }

            for (int i = 0; i < str.Length; i++)
            {
                ListItem li = new ListItem();
                li.Text = str[i].ToString();
                if (i == 0)
                {
                    li.Selected = true;
                }
                rblRole.Items.Add(li);
            }            
        }
    }
    protected void btnGo_Click(object sender, EventArgs e)
    {
        Session["RoleName"] = rblRole.SelectedItem.Value;        
        Response.Redirect("~/Pages/default.aspx");
        
    }
}

can any one help me in this... :)

2 Answers, 1 is accepted

Sort by
0
Fiko
Telerik team
answered on 27 Jan 2009, 03:09 PM
Hi Vivek,

I created a simple project that reproduce your scenario and I implemented the desired functionality in it. For your convenience I attached the project to the thread and bellow I will shortly explain the used approach:
  • declare onClose() JavaScript function on the default.aspx and attach it to the OnClientClose event of the RadWindow control
  • declare two function - GetRadWindow() and closeRadWindow() in the popup window
  • use the btnGo_Click() function in RoleList.aspx.cs to dynamically load a JavaScript function that will close the RadWindow

I hope this helps.

Kind regards,
Fiko
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Felipe Saldana
Top achievements
Rank 1
answered on 27 Jan 2009, 10:57 PM
Thanks....this worked for me.
Tags
Window
Asked by
vivek
Top achievements
Rank 1
Answers by
Fiko
Telerik team
Felipe Saldana
Top achievements
Rank 1
Share this question
or