This is a migrated thread and some comments may be shown as answers.
Data Transfer
1 Answer 6 Views
This is a migrated thread and some comments may be shown as answers.
Anzar
Top achievements
Rank 2
Anzar asked on 13 Aug 2013, 12:07 PM
Hi,
I shall have to pass bulk data between page to radwindow and vice versa. A sample application code is below. In this by using PreviousPageType' data transferred (Click on Ordinary Button). But in radwindow it shows the error 'Object reference not set to an instance of an object.'(Click on Popup button). How to achieve this method in radwiondow?.



Default.aspx
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <telerik:RadScriptBlock ID="RadScriptBlock" runat="server">
        <script type="text/javascript">
            function btnShowPopup_Clicked(sender, args) {
                var winSearch = radopen("DefaultPopup.aspx");
                if (winSearch) {
                    winSearch.hide();
                    winSearch.set_behaviors(Telerik.Web.UI.WindowBehaviors.Close | Telerik.Web.UI.WindowBehaviors.Move)
                    winSearch.add_close(searchWindow_OnClientClose);
                    winSearch.set_height(400);
                    winSearch.set_width(780);
                    winSearch.set_visibleStatusbar(false);
                    winSearch.set_destroyOnClose(true);
                    winSearch.set_modal(true);
                    winSearch.set_title("Popup");
                    winSearch.center();
                    winSearch.show();
                }
            }
            function RadWindow_Close(sender, args) {
                var manager = sender.get_windowManager();
                if (manager)
                    manager.removeWindow(sender);
            }
            function searchWindow_OnClientClose(oWnd, args) {
                var arg = args.get_argument();
                if (arg) {
                    var ajaxManager = $find("<%= radAjaxManager.ClientID %>");
                    if (ajaxManager)
                        ajaxManager.ajaxRequest(arg);
                }
            }
        </script>
    </telerik:RadScriptBlock>
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadAjaxManager ID="radAjaxManager" runat="server" UpdatePanelsRenderMode="Inline"
        OnAjaxRequest="radAjaxManager_AjaxRequest">
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" BackgroundPosition="Center"
        InitialDelayTime="300">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadWindowManager ID="radWinManager" runat="server" DestroyOnClose="True">
        <Windows>
            <telerik:RadWindow ID="RadWindow1" runat="server" Style="display: none;" OnClientClose="RadWindow_Close">
                <Shortcuts>
                    <telerik:WindowShortcut CommandName="CommandName" Shortcut="" />
                </Shortcuts>
            </telerik:RadWindow>
        </Windows>
        <Shortcuts>
            <telerik:WindowShortcut CommandName="CommandName" Shortcut="" />
        </Shortcuts>
    </telerik:RadWindowManager>
    <asp:TextBox ID="txtFirst" runat="server"></asp:TextBox>
    <asp:Button ID="Button1" runat="server" Text="Ordinary" OnClick="Button1_Click" />
    <telerik:RadButton ID="btnShowPopup" runat="server" Text="Popup" AutoPostBack="false"
        OnClientClicked="btnShowPopup_Clicked">
    </telerik:RadButton>
</asp:Content>
Default.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
namespace WebApplication1
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
 
        }
 
        protected void Button1_Click(object sender, EventArgs e)
        {
            this.Name = this.txtFirst.Text;
            Server.Transfer("~/DefaultPopup.aspx");
        }
       // public string Name { get; set; }
 
        protected void radAjaxManager_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
        {
 
        }
 
 
         public string Name { get { return Convert.ToString(ViewState["SName"]); } set { ViewState["SName"] = value; } }
    }
}


DefaultPopup.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DefaultPopup.aspx.cs" Inherits="WebApplication1.DefaultPopup" %>
 
<%@ PreviousPageType VirtualPath="~/Default.aspx" %>
<%@ 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">
<head runat="server">
    <title></title>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
        </script>
    </telerik:RadCodeBlock>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
        <telerik:RadWindowManager ID="radWinManager" runat="server" DestroyOnClose="True"
            KeepInScreenBounds="true">
        </telerik:RadWindowManager>
    </div>
    </form>
</body>
</html>

DefaultPopup.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
namespace WebApplication1
{
    public partial class DefaultPopup : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Write("Data from PreviousPage:" + PreviousPage.Name);
        }
    }
}

Thanks & Regards
Anzar. M

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 14 Aug 2013, 10:17 AM
Hello Anzar,

When a page is loaded in a RadWindow it is a separate GET request which loads it in an iframe, so there is no previous page that you are transferred from.

What I can suggest is storing and accessing the desired data/objects in the Session or the Cache in the code-behind of each page.
Since you must reach the code-behind before opening the RadWIndow I advise that you examine this sticky thread on opening the RadWindow from the server button click event: http://www.telerik.com/community/forums/aspnet-ajax/window/opening-radwindow-from-the-server.aspx. You can simply register a call to the already existing btnShowPopup_Clicked function as explained here: http://www.telerik.com/help/aspnet-ajax/radwindow-troubleshooting-javascript-from-server-side.html.
A similar approach can be taken for closing the popup from the DefaultPopup page - a code-behind Click will store the needed data and register a script that will close the popup with JavaScript. You can see a similar logic in action here: http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandwindow/defaultcs.aspx?product=window. Examine the Editform pages.


Regards,
Marin Bratanov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Asked by
Anzar
Top achievements
Rank 2
Answers by
Marin Bratanov
Telerik team
Share this question
or