Problem MasterPage with RadAjaxManager

2 posts, 0 answers
  1. erik vazquez
    erik vazquez avatar
    2 posts
    Member since:
    Apr 2010

    Posted 10 Mar 2011 Link to this post

    Hi
    I have a problem with MasterPage and RadAjaxManager because when the RadGrid (in contentPage) fires an autoPostBack, the RadAjaxManager never catch de event and the whole page is refreshed. I already saw some examples where show how to use  MasterPage with RadAjaxManager, but I can´t get do it in my project.

    MasterPage:
    <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Maestra.master.cs" Inherits="sicoge.Maestra.Maestra" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <head id="Head1" runat="server">
        <title>Página sin título</title>
        <asp:ContentPlaceHolder ID="head" runat="server">
        </asp:ContentPlaceHolder>
        <link rel="Stylesheet" type="text/css" href="../common/master.css"/>
        <style type="text/css">
            .style1
            {
                width: 100%;
            }
        </style>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
     
            <asp:LoginStatus ID="LoginStatus1" runat="server"
                LogoutPageUrl="~/webForms/login.aspx" LogoutAction="RedirectToLoginPage"
                onloggingout="LoginStatus1_LoggingOut" LoginText="Iniciar sesión."
                LogoutText="Cerrar sesión."/>
            <asp:LoginStatus ID="LoginStatus2" runat="server"
                LoginImageUrl="~/images/log_in.png" LoginText=""
                LogoutAction="RedirectToLoginPage" LogoutImageUrl="~/images/logout.png"
                LogoutPageUrl="~/webForms/login.aspx" LogoutText=""
                onloggingout="LoginStatus2_LoggingOut" />
     
        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
         
        </asp:ContentPlaceHolder>
     
     
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        </telerik:RadAjaxManager>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
        <telerik:RadSkinManager ID="RadSkinManager1" runat="server" Skin="Default">
        </telerik:RadSkinManager>
        <telerik:RadFormDecorator ID="RadFormDecorator1" Runat="server"
            Skin="Default" />
    </div>
        </form>

    ContentPage :

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MisSolicitudes.aspx.cs" MasterPageFile="~/Maestra/Maestra.Master" Inherits="sicoge.webForms.MisSolicitudes" Title="Mis Solicitudes" %>
     
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
     
    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
        <link rel="Stylesheet" type="text/css" href="../common/Forms.css" />
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
        <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="GrdSolicitudes">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadAjaxPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManagerProxy>
        <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
                         <telerik:RadGrid ID="GrdSolicitudes" runat="server"
                             AllowFilteringByColumn="True" AllowPaging="True" DataSourceID="SqlDataSource1"
                             GridLines="None" ShowGroupPanel="True" Culture="Spanish (Mexico)"
                             Width="906px">
    <HeaderContextMenu EnableImageSprites="True" CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>
     
                             <GroupPanel Text="Arrastre y suelte aqui una columna para agrupar.">
                             </GroupPanel>
     
    <MasterTableView AutoGenerateColumns="False" DataKeyNames="IdSolicitud" DataSourceID="SqlDataSource1"
                                 NoMasterRecordsText="No hay registros para mostrar.">
    <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
     
    <RowIndicatorColumn>
    <HeaderStyle Width="20px"></HeaderStyle>
    </RowIndicatorColumn>
     
    <ExpandCollapseColumn>
    <HeaderStyle Width="20px"></HeaderStyle>
    </ExpandCollapseColumn>
        <Columns>
            <telerik:GridBoundColumn DataField="IdSolicitud" DataType="System.Int32"
                HeaderText="IdSolicitud" ReadOnly="True" SortExpression="IdSolicitud"
                UniqueName="IdSolicitud" Visible="False">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Folio" HeaderText="Folio"
                SortExpression="Folio" UniqueName="Folio">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="IdSeccion" DataType="System.Int32"
                HeaderText="IdSeccion" SortExpression="IdSeccion" UniqueName="IdSeccion">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="IdEstadoSolicitud" DataType="System.Int32"
                HeaderText="IdEstadoSolicitud" SortExpression="IdEstadoSolicitud"
                UniqueName="IdEstadoSolicitud">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="FechaSolicitud" DataType="System.DateTime"
                HeaderText="FechaSolicitud" SortExpression="FechaSolicitud"
                UniqueName="FechaSolicitud">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Observaciones" HeaderText="Observaciones"
                SortExpression="Observaciones" UniqueName="Observaciones">
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
                             <GroupingSettings GroupContinuedFormatString="... continuación de la pág anterior. "
                                 GroupContinuesFormatString=" Continua en la siguiente pág."
                                 GroupSplitDisplayFormat="Mostrando {0} de {1} elementos." />
                             <ClientSettings AllowDragToGroup="True">
                                 <Selecting AllowRowSelect="True" />
                                 <Scrolling AllowScroll="True" UseStaticHeaders="True" />
                                 <Resizing AllowColumnResize="True" />
                             </ClientSettings>
                         </telerik:RadGrid>
                         </telerik:RadAjaxPanel>

    And ContentPage CS:

    using System;
    using System.Collections;
    using System.Configuration;
    using System.Data;
    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;
    using Telerik.Web.UI;
     
     
    namespace sicoge.webForms
    {
        public partial class MisSolicitudes : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                RadAjaxManager ajm = this.Master.FindControl("RadAjaxManager1") as RadAjaxManager;
                ajm.AjaxSettings.AddAjaxSetting(GrdSolicitudes, RadAjaxPanel1);
            }
             
        }
    }

    The exception that it fires is: System.NullReferenceException: Referencia a objeto no establecida como instancia de un objeto.

    Línea 20:         {
    Línea 21:             RadAjaxManager ajm = this.Master.FindControl("RadAjaxManager1") as RadAjaxManager;
    Línea 22:             ajm.AjaxSettings.AddAjaxSetting(GrdSolicitudes, RadAjaxPanel1);
    Línea 23:         }
    Línea 24:


    Also, when I put a RadAjaxManagerProxy in the contentPage and I try to configure it (Configure Ajax Manager), nothing controls are showed in the "Select the controls that will initiate AJAX request" panel and I cant configure anything.

  2. Pavlina
    Admin
    Pavlina avatar
    6187 posts

    Posted 11 Mar 2011 Link to this post

    Hello Erik,

    Attached to this message is a sample working project which handles the desired functionality. Examine it and see if it works for you.

    Greetings,
    Pavlina
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Back to Top