radlistview dissapears after ajax postback call

3 posts, 0 answers
  1. maurice
    maurice avatar
    8 posts
    Member since:
    Aug 2010

    Posted 18 Oct 2011 Link to this post

    I am farely new to Telerik, First I ran into a problem where I could not load multiple RadAjaxManger on multiple user controls. I read a couple threads on this and found a solution that is working for me, Here. Problem now is that the listview is updating and everything on the server side  and the javascript part is working as well, but when it is done, the listview disappears. Can anyone see what i am doing wrong? Thanks for any answers.
    ListView(UserControl)
    <telerik:RadAjaxManagerProxy  ID="FullAlbumAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="FullAlbumAjaxManager1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="ListViewPanel1" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="lvFullControlAlbums" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="FullAlbumCounter" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="ListViewPanel1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="ListViewPanel1" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="lvFullControlAlbums" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="FullAlbumCounter" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="rdoSortDate">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="ListViewPanel1" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="lvFullControlAlbums" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="rdoSortName">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="ListViewPanel1" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="lvFullControlAlbums" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManagerProxy >
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" MinDisplayTime="0" />
        <asp:Panel ID="ListViewPanel1" runat="server">
         <div>
            <asp:RadioButton runat="server" ID="rdoSortDate" Text="Sort by date" AutoPostBack="true"
                OnCheckedChanged="rdosortDate_Change" GroupName="Sorter" />
            <br />
            <asp:RadioButton runat="server" ID="rdoSortName" Text="Sort by Name" AutoPostBack="true"
                OnCheckedChanged="rdosortName_Change" GroupName="Sorter" />
           <asp:Button runat="server" ID="ResyncFullAlbum" Text="Resync Full Album"
                 onclick="ResyncFullAlbum_Click"/>
        </div>
            <telerik:RadListView ID="lvFullControlAlbums" AllowPaging="true" runat="server" GroupItemCount="5"
                OnPageIndexChanged="Pager_Change" OnItemDataBound="AlbumSetup">
                <ClientSettings>
                    <ClientEvents OnListViewCreated="SetupListviewAccess"></ClientEvents>
                </ClientSettings>
                <LayoutTemplate>
                    <table id="Table2" runat="server">
                        <tr id="Tr1" runat="server">
                            <td id="Td3" runat="server">
                                <table id="groupPlaceholderContainer" runat="server" border="0" style="">
                                    <tr id="groupPlaceholder" runat="server">
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr id="Tr2" runat="server">
                            <td id="Td4" runat="server" style="">
                                <telerik:RadDataPager ID="RadDataPager1" runat="server" PagedControlID="lvFullControlAlbums"
                                    PageSize="10">
                                    <Fields>
                                        <telerik:RadDataPagerButtonField FieldType="Numeric" />
                                        <telerik:RadDataPagerTemplatePageField>
                                            <PagerTemplate>
                                                <div style="float: right">
                                                    <b>Items
                                                        <asp:Label runat="server" ID="CurrentPageLabel" Text="<%# Container.Owner.StartRowIndex+1%>" />
                                                        to
                                                        <asp:Label runat="server" ID="TotalPagesLabel" Text="<%# Container.Owner.TotalRowCount > (Container.Owner.StartRowIndex+Container.Owner.PageSize) ? Container.Owner.StartRowIndex+Container.Owner.PageSize : Container.Owner.TotalRowCount %>" />
                                                        of
                                                        <asp:Label runat="server" ID="TotalItemsLabel" Text="<%# Container.Owner.TotalRowCount%>" />
                                                        <br />
                                                    </b>
                                                </div>
                                            </PagerTemplate>
                                        </telerik:RadDataPagerTemplatePageField>
                                    </Fields>
                                </telerik:RadDataPager>
                            </td>
                        </tr>
                    </table>
                </LayoutTemplate>
                <EmptyDataTemplate>
                    <table id="Table1" runat="server" style="">
                        <tr>
                            <td>
                                No shared or created albums.<a href="#" id="NoDataCreateAlbum">Create New Album.</a>
                            </td>
                        </tr>
                    </table>
                </EmptyDataTemplate>
                <EmptyItemTemplate>
                    <td id="Td1" runat="server" />
                </EmptyItemTemplate>
                <ItemTemplate>
                    <td id="Td2" runat="server" style="display: inline-block; position: relative; margin: 0.7em;
                        text-align: left; vertical-align: top;">
                        <asp:HiddenField runat="server" ID="ShareCounter" />
                        <div id="HypeShareAlbum" style="padding: 0; margin: 0">
                            <input type="hidden" value="<%#Eval("ID") %>" />
                            <asp:HyperLink runat="server" ID="hypShareAlbum"></asp:HyperLink>
                            <input type="hidden" value="<%#Eval("CreatorID") %>" />
                        </div>
                        <div class="EditAlbumClass">
                            <asp:ImageButton ToolTip='<%#Eval("AlbumDescription") %>' runat="server" ID="AlbumImage"
                                Width="110" Height="110" ImageUrl='<%#Eval("AlbumDefaultImageUrl") %>' /></div>
                        <img src="../SiteImages/private.png" style="margin: 0" />
                        <span style="margin: 0">photos:
                            <%#Eval("PhotoCount")%></span><br />
                        <div id="hypDeleteAccess" style="padding: 0; margin: 0">
                            <input type="hidden" value="<%#Eval("ID") %>" />
                            <asp:LinkButton runat="server" ID="hypeDeleteAlbum" Visible="false" Text="Delete Album"></asp:LinkButton>
                            <asp:HyperLink ID="hypeDeleteMyAccess" runat="server" Visible="false" Text="Remove my Access"></asp:HyperLink>
                        </div>
                        <div class="EditAlbumClass">
                            <asp:HyperLink runat="server" ID="EditAlbum" ToolTip='<%#Eval("AlbumDescription") %>'
                                Font-Underline="false">
                                <p class="titleAlbums" runat="server" id="pTitle">
                                    <%#Eval("AlbumName") %></p>
                            </asp:HyperLink></div>
                    </td>
                </ItemTemplate>
                <GroupTemplate>
                    <tr id="itemPlaceholderContainer" runat="server">
                        <td id="itemPlaceholder" runat="server">
                        </td>
                    </tr>
                </GroupTemplate>
            </telerik:RadListView>
            <asp:HiddenField runat="server" ID="AccessChoice"/>
        </asp:Panel>
    Code Behind c#
    protected void Page_Load(object sender, EventArgs e)
           {
               manager1 = RadAjaxManager.GetCurrent(Page);
               manager1.AjaxSettings.AddAjaxSetting(manager1, lvFullControlAlbums);
               manager1.AjaxSettings.AddAjaxSetting(manager1, ListViewPanel1);
               manager1.AjaxSettings.AddAjaxSetting(manager1, FullAlbumCounter);
               manager1.AjaxSettings.AddAjaxSetting(FullAlbumAjaxManager1, lvFullControlAlbums);
               manager1.AjaxSettings.AddAjaxSetting(FullAlbumAjaxManager1, ListViewPanel1);
               manager1.AjaxSettings.AddAjaxSetting(FullAlbumAjaxManager1, FullAlbumCounter);
               manager1.AjaxSettings.AddAjaxSetting(ListViewPanel1, ListViewPanel1);
               manager1.AjaxSettings.AddAjaxSetting(ListViewPanel1, lvFullControlAlbums);
               manager1.AjaxSettings.AddAjaxSetting(ListViewPanel1, FullAlbumCounter);
               manager1.AjaxSettings.AddAjaxSetting(rdoSortDate, ListViewPanel1);
               manager1.AjaxSettings.AddAjaxSetting(rdoSortDate, lvFullControlAlbums);
               manager1.AjaxSettings.AddAjaxSetting(rdoSortName, ListViewPanel1);
               manager1.AjaxSettings.AddAjaxSetting(rdoSortName, lvFullControlAlbums);
               manager1.AjaxRequest += new RadAjaxControl.AjaxRequestDelegate(FullAlbumAjaxManager1_AjaxRequest);
                
           }
    protected void FullAlbumAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
           {
               string accesschoice = AccessChoice.Value;
               bool resetFullList = false;
               string id = "";
               if (e.Argument != null)
               {
                   id = e.Argument;
                   if (accesschoice == "Delete Album")
                   {
                       if (mygreatappz.control.Data.Albums.DeleteAlbum(id))
                       {
                           resetFullList = true;
                       }
                   }
                   else if (accesschoice == "Remove my Access")
                   {
                       if (mygreatappz.control.Data.AlbumAcesses.RemoveAccess(GlobalClass.GlobalVariables.User.ID, id))
                       {
                           resetFullList = true;
                       }
                   }
     
               }
               if (resetFullList)
               {
                   List<Album> newAlbums = new List<Album>();
                   foreach (Album album in GlobalClass.GlobalVariables.User.FullControlAlbums)
                   {
                       if (album.ID != id)
                       {
                           newAlbums.Add(album);
                       }
                   }
                   GlobalClass.GlobalVariables.User.FullControlAlbums = newAlbums;
               }
               RebindData();
           }
    JS file that makes the ajax call
    if (option == 'Remove my Access') {
                            var album = $(this).prev().val();
                            $('[id$=AccessChoice]').val(option);
                            $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest(album);
                            return false;
                        }
  2. maurice
    maurice avatar
    8 posts
    Member since:
    Aug 2010

    Posted 18 Oct 2011 Link to this post

    I removed the following on the server side. But now on my client side no dialog shows up when updating the listview.
    manager1.AjaxSettings.AddAjaxSetting(manager1, lvFullControlAlbums);
               manager1.AjaxSettings.AddAjaxSetting(manager1, ListViewPanel1);
               manager1.AjaxSettings.AddAjaxSetting(manager1, FullAlbumCounter);
               manager1.AjaxSettings.AddAjaxSetting(FullAlbumAjaxManager1, lvFullControlAlbums);
               manager1.AjaxSettings.AddAjaxSetting(FullAlbumAjaxManager1, ListViewPanel1);
               manager1.AjaxSettings.AddAjaxSetting(FullAlbumAjaxManager1, FullAlbumCounter);
               manager1.AjaxSettings.AddAjaxSetting(ListViewPanel1, ListViewPanel1);
               manager1.AjaxSettings.AddAjaxSetting(ListViewPanel1, lvFullControlAlbums);
               manager1.AjaxSettings.AddAjaxSetting(ListViewPanel1, FullAlbumCounter);
               manager1.AjaxSettings.AddAjaxSetting(rdoSortDate, ListViewPanel1);
               manager1.AjaxSettings.AddAjaxSetting(rdoSortDate, lvFullControlAlbums);
               manager1.AjaxSettings.AddAjaxSetting(rdoSortName, ListViewPanel1);
               manager1.AjaxSettings.AddAjaxSetting(rdoSortName, lvFullControlAlbums);
  3. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 21 Oct 2011 Link to this post

    Hi Maurice,

    Please try to remove the RadAjaxManagerProxy form the user control and use only the programmatic settings of the main manager in code behind. Give this a try nd let me know if it makes any difference.

    Regards,
    Maria Ilieva
    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