Close and refresh without postback on the parent

4 posts, 1 answers
  1. Deniz Torlak
    Deniz Torlak avatar
    2 posts
    Member since:
    Nov 2009

    Posted 30 Nov 2011 Link to this post

    Hi there,

    I have a situation and actually I can explain it using one of your examples. 
    I am using a page like this;
    http://demos.telerik.com/aspnet-ajax/window/examples/contenttemplatevsnavigateurl/defaultcs.aspx

    My code uses the contenttemplate version and there is a small form with in the radwindow. Then the save button is clicked it does a postback from codebehind like in your example. What I want to do is when I click the save button I want to call a function in the parent page which runs some code and updates one of the 3 grids on the page and I want to do this using ajax without refreshing the whole parent page. 

    However even if I use the ajaxmanager or the ajaxpanel I can open the radwindow via ajax but the save button always does a postback and make the whole parent page refresh (behaves like in your example code)

    How can I do the postback via ajax from the radwindow (using contenttemplate) without refreshing the whole parent page?

    thanks
    Deniz
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 30 Nov 2011 Link to this post

    Hello,

    Take a look into the following forum thread which discussed the same.
    How to trigger an Ajax postback on parentpage after closing radwindow

    Thanks,
    Princy.
  3. Deniz Torlak
    Deniz Torlak avatar
    2 posts
    Member since:
    Nov 2009

    Posted 02 Dec 2011 Link to this post

    Ok I guess I am missing something here. I prepared a  very simple example that represents my core problem

    OpenWindow button opens the rad window with ajax but when I click the update button in the radwindow it does a full postpack on the parent page instead just closing the radwindow doing an ajax update on the CurrentText textbox. 

    so what am i doing wrong?

    Here is aspx page code 
    <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/iMarina.master" AutoEventWireup="true" CodeFile="AjaxandWindow.aspx.cs" Inherits="Sayfalar_Test_AjaxandWindow" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
     
    <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
     
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
     
        <telerik:RadTextBox ID="CurrentText" runat="server"></telerik:RadTextBox>
        <telerik:RadButton ID="OpenWindow" runat="server" onclick="OpenWindow_Click" Text="Edit"></telerik:RadButton>
     
        <telerik:RadWindow ID="RadWindow1" runat="server">
            <ContentTemplate>
            <telerik:RadTextBox ID="UpdatedText" runat="server"></telerik:RadTextBox>
            <telerik:RadButton ID="Update" runat="server"  onclick="Update_Click" Text="Update"></telerik:RadButton>       
            </ContentTemplate>
        </telerik:RadWindow>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="OpenWindow">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadWindow1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="Update">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="CurrentText" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default" MinDisplayTime="5000">
        </telerik:RadAjaxLoadingPanel>
    </asp:Content>

    And here is the code behind:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
     
    public partial class Sayfalar_Test_AjaxandWindow : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
     
        }
        protected void OpenWindow_Click(object sender, EventArgs e)
        {
            this.RadWindow1.VisibleOnPageLoad = true;
        }
     
        protected void Update_Click(object sender, EventArgs e)
        {
            this.RadWindow1.VisibleOnPageLoad = false;
            CurrentText.Text = UpdatedText.Text;
        }
     
    }


  4. Marin Bratanov
    Admin
    Marin Bratanov avatar
    5243 posts

    Posted 06 Dec 2011 Link to this post

    Hello Deniz,

    I am not sure exactly how you have set up your RadWIndows, but I advise you examine the following help article on properly using RadWindow with AJAX: http://www.telerik.com/help/aspnet-ajax/radwindow-ajaxifying.html. I also suggest you examine this one on the correct way to open it from the code-behind: http://www.telerik.com/help/aspnet-ajax/radwindow-troubleshooting-opening-from-server.html which, I believe, can reduce the number of the required AJAX settings. The same approach can be adopted for executing a script that will close the RadWindow. You may also find useful this article on calling functions from the RadWindow in case you are using the NavigateUrl: http://www.telerik.com/help/aspnet-ajax/window-programming-calling-functions.html. Similar approach is shown in this online demo as well.


    Regards,
    Marin
    the Telerik team
    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 their blog feed now
Back to Top