Friday 8 May 2015

Update textbox data on click of button on another page with telerik rad window



dark is parent window

 modal is individual page which is opened with telerik rad window

on click of save on modal page, we need to update parent page's benefeciary name also


On parent aspx
---------------------------------------------------
<%@ MasterType VirtualPath="~/Site.master" %>


function OnSubItemClose(oWnd, args) {
       if (args._argument != null) {
           console.log(args);
       }
   }



<telerik:RadWindowManager runat="server" ID="radmanager">
        <Windows>
            <telerik:RadWindow ID="ListDialog" runat="server" ReloadOnShow="true" ShowContentDuringLoad="false" Width="500px" Height="400px"
                Modal="true" VisibleStatusbar="false" ShowOnTopWhenMaximized="true" AutoSize="false"
                EnableViewState="false" KeepInScreenBounds="false" Behaviors="Close"
                VisibleTitlebar="true" VisibleOnPageLoad="false">
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>


<asp:TextBox ID="txt_beneficiary" runat="server"  ClientIDMode="Static" />

<asp:Button ID="btnbeneficiary" Text="..." runat="server"
                                onclick="btnbeneficiary_Click" />


On parent page code
----------------------------
private void SetWindow(string navurl, string onclientclose)
    {
        radmanager.Windows.Clear();
        ListDialog.NavigateUrl = navurl;
        ListDialog.VisibleOnPageLoad = true;
        ListDialog.OnClientClose = onclientclose;

        radmanager.Windows.Add(ListDialog);
    }
    protected void btnbeneficiary_Click(object sender, EventArgs e)
    {
        if (!ddl_CenterList.Enabled)
        {
            SetWindow("~/cp_beneficiary.aspx?Memid=" + ViewState["MemberID"].ToString(), "OnSubItemClose");
        }
        else
        {
            lblError.Text = "Please take appointment first.";
        }
    }


on modal page aspx
---------------------------------
<%@ MasterType VirtualPath="~/Site.master" %>


 <script type="text/javascript">

        function GetRadWindow() {
            var oWindow = null;
            if (window.radWindow)
                oWindow = window.radWindow;
            else if (window.frameElement.radWindow)
                oWindow = window.frameElement.radWindow;
            return oWindow;
        }

        function UpdateName() {
            GetRadWindow().BrowserWindow.document.getElementById("txt_beneficiary").value = <%= txtBenName.ClientID%>.value;
        }
    </script>

<asp:Button Text="Save" runat="server" ID="btnSave" onclick="btnSave_Click" OnClientClick="UpdateName(); return true;" />

No comments:

Post a Comment