This is a migrated thread and some comments may be shown as answers.
RadWindow With Rad Grid
1 Answer 56 Views
This is a migrated thread and some comments may be shown as answers.
Nithya Rani
Top achievements
Rank 1
Nithya Rani asked on 31 Jan 2012, 06:38 AM
Hi

In my page i have 2 textboxes for code,  name and i have one button. While click the button radwindow will open.
Inside the radwindow i have called the normal aspx page. While clicking the radbutton i was passing the textbox id's to the popup page. In the radgrid i have link button. When i click the link button the code and name should be assigned to the querystring and radwindow should close. Then the selected value should assign to the textboxes. Please find the attached project for the same. in that attachement i have given normal window and the radwindow.

RadWindowCallingPage.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="RadWindowCallingPage.aspx.cs" Inherits="RadWindowCallingPage" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
    <script type="text/javascript">        function FunctionWithDescriptionssss(controlID, DescrcontrolID, popupName) {
            var text = document.getElementById(controlID).value;
            var textdesc = document.getElementById(DescrcontrolID).value;
            document.getElementById(controlID).readOnly = true;
            var url = popupName + ".aspx?controlID=" + controlID + "&controlText=" + text + "&DescrcontrolID=" + DescrcontrolID + "&txtDescr=" + textdesc + "";
            var pop = window.radopen(url, "Lookup", "top=20,left=100,width=650,Height=500,scrollbars=yes,resizable=no,status=yes", "");
        }
        function FunctionWithDescription(controlID, DescrcontrolID, popupName) {
            var text = document.getElementById(controlID).value;
            var textdesc = document.getElementById(DescrcontrolID).value;
            document.getElementById(controlID).readOnly = true;
            var url = popupName + ".aspx?controlID=" + controlID + "&controlText=" + text + "&DescrcontrolID=" + DescrcontrolID + "&txtDescr=" + textdesc + "";
            var pop = window.open(url, "Lookup1", "top=20,left=100,width=650,Height=500,scrollbars=yes,resizable=no,status=yes", "");
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <telerik:RadWindowManager runat="server" RestrictionZoneID="offsetElement" ID="RadWindowManager1"
        EnableShadow="true" ShowOnTopWhenMaximized="false">
        <Windows>
            <telerik:RadWindow ID="test1" NavigateUrl="lookup.aspx" VisibleOnPageLoad="false"
                Top="20" Left="100" runat="server">
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>
    <table width="60%">
        <tr>
            <td>
                S.No
            </td>
            <td>
                <telerik:RadTextBox ID="txtcode" runat="server">
                </telerik:RadTextBox>
            </td>
            <td>
                Name
            </td>
            <td>
                <telerik:RadTextBox ID="txtdesc" runat="server">
                </telerik:RadTextBox>
            </td>
        </tr>
        <tr>
            <td>
                Radwindow
            </td>
            <td>
                <asp:Image ID="imgradwindow" runat="server" Height="17px" ImageUrl="~/images/PopupButtonImage.bmp"
                    Width="18px" ImageAlign="Right" TabIndex="2" />
            </td>
        </tr>
        <tr>
            <td>
                Normal Window Control
            </td>
            <td>
                <asp:Image ID="imgnormalwindow" runat="server" Height="17px" ImageUrl="~/images/PopupButtonImage.bmp"
                    Width="18px" ImageAlign="Right" TabIndex="2" />
            </td>
        </tr>
    </table>
</asp:Content>
RadWindowCallingPage.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class RadWindowCallingPage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        imgradwindow.Attributes.Add("onclick", "JavaScript:FunctionWithDescriptionssss('" + txtcode.ClientID + "','" + txtdesc.ClientID + "','lookup');");
        imgnormalwindow.Attributes.Add("onclick", "JavaScript:FunctionWithDescription('" + txtcode.ClientID + "','" + txtdesc.ClientID + "','lookup');");
       
    }
}

lookup.aspx

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

<%@ 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></title>
</head>
<body>
 
    <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div>
        <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false"
            onneeddatasource="RadGrid1_NeedDataSource">
            <MasterTableView AllowMultiColumnSorting="false" GridLines="Both" AllowSorting="true"
                TableLayout="Fixed" AllowAutomaticUpdates="true">
                <Columns>
                    <telerik:GridTemplateColumn HeaderText="Code" UniqueName="Code" DataField="CODE"
                        ItemStyle-HorizontalAlign="Left">
                        <HeaderStyle Width="35%" />
                        <ItemStyle Width="35%" />
                        <ItemTemplate>
                            <asp:LinkButton ID="lnkAccountCode" runat="server" OnClick="LinkButton1_Click"  Text='<%# DataBinder.Eval (Container.DataItem, "CODE") %>'
                                ValidationGroup='<%# DataBinder.Eval (Container.DataItem, "NAME") %>'></asp:LinkButton>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn HeaderText="Name" UniqueName="Name" DataField="NAME"
                        ItemStyle-HorizontalAlign="Left">
                        <HeaderStyle Width="60%" />
                        <ItemStyle Width="60%" />
                        <ItemTemplate>
                            <asp:LinkButton ID="lnkAccountDesc" runat="server" OnClick="LinkButton2_Click" Text='<%# DataBinder.Eval (Container.DataItem, "NAME") %>'
                                ValidationGroup='<%# DataBinder.Eval (Container.DataItem, "CODE") %>'></asp:LinkButton>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
    </div>
    </form>
</body>
</html>

lookup.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class lookup : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
          
        }
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        string Code = ((LinkButton)sender).Text.Trim();
        string Description = ((LinkButton)sender).ValidationGroup;

        string controlID = Request.QueryString["controlID"]+"_text";
        string txtID = Request.QueryString["controlID"];
        string DescrcontrolID = Request.QueryString["DescrcontrolID"] + "_text";

        if (Request.QueryString["txtDescr"] == null)
        {
            string strSupplierText = ((LinkButton)sender).ValidationGroup;
            string myScript = @"window.opener.document.getElementById('" + controlID + "').value = '" + Code.Trim() + "';window.close();";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "Myscript", myScript, true);
        }
        else
        {            
            string controlText = Request.QueryString["controlText"];
            string myscript1 = @"window.opener.document.getElementById('" + controlID + "').value = '" + Code.Trim() + "';window.opener.document.getElementById('" + DescrcontrolID + "').value = '" + Description.Trim() + "';window.close();";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "Myscript", myscript1, true);
        }            
    }
    protected void LinkButton2_Click(object sender, EventArgs e)
    {
        string Code = ((LinkButton)sender).ValidationGroup;
        string Description = ((LinkButton)sender).Text.Trim();
        string controlID = Request.QueryString["controlID"] + "_text";
        string txtID = Request.QueryString["controlID"];
        string DescrcontrolID = Request.QueryString["DescrcontrolID"] + "_text";

        if (Request.QueryString["txtDescr"] == null)
        {
            string strSupplierText = ((LinkButton)sender).ValidationGroup;
            string myScript = @"window.opener.document.getElementById('" + controlID + "').value = '" + Code.Trim() + "';window.close();";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "Myscript", myScript, true);
        }
        else
        {            
            string controlText = Request.QueryString["controlText"];
            string myscript1 = @"window.opener.document.getElementById('" + controlID + "').value = '" + Code.Trim() + "';window.opener.document.getElementById('" + DescrcontrolID + "').value = '" + Description.Trim() + "';window.close();";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "Myscript", myscript1, true);
        }
    }

   
    protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        RadGrid1.DataSource = GetTable();
    }

    static DataTable GetTable()
    {
        DataTable dt = new DataTable();
        dt.Columns.Add("CODE", typeof(int));
        dt.Columns.Add("NAME", typeof(string));

        dt.Rows.Add(1, "Nithya");
        dt.Rows.Add(2, "Divya");
        dt.Rows.Add(3, "Saranaya");
        dt.Rows.Add(4, "Revathi");
        dt.Rows.Add(5, "Abilasha");
        return dt;
    }
}

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 31 Jan 2012, 10:30 AM
Hello,

Take a look into the following demo and documentation which explained how to return a value while closing the window.
Window / Returning Values from a Dialog
Using RadWindow as a Dialog

Thanks,
Princy.
Asked by
Nithya Rani
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Share this question
or