This is a migrated thread and some comments may be shown as answers.

UserControl disapears after the second postback (ajax request)

4 Answers 101 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Stephane
Top achievements
Rank 1
Stephane asked on 02 Aug 2011, 05:35 PM
Hi,
I build an aspx page which contains only one RadTabStrip and its RadMultiPage.

In the page_load event (in the behind code), I build dynamically the RadTabStrip and the RadMultiPage
protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string[] arguments = Session[SessionParameterName.LISTDOCTOVISU] as string[];
            for (int i = 0; i < arguments.Length; i++)
            {
                AddTab(arguments[i]);
                AddPageView(RadTabStripDocView.Tabs[i]);
            }
        }      
    }

For each value the named Session field, i create a RadTab and a PageView, like in the live demo example.
I also implemented the function AddTab and AddPageView
private void AddTab(string codeDoc)
    {
        RadTab tab = new RadTab();
        tab.Text = codeDoc;
        tab.Attributes.Add("CodeDoc", codeDoc);
        tab.Value = codeDoc;
        RadTabStripDocView.Tabs.Add(tab);
    }
 
    private void AddPageView(RadTab tab)
    {
        RadPageView pageView = new RadPageView();
        pageView.ID = "PageView_ID_" + tab.Value;
        pageView.Attributes.Add("CodeDoc", tab.Value);
        RadMultiPageDocView.PageViews.Add(pageView);
        tab.PageViewID = pageView.ID;
    }

and the event PageViewCreate on the RadMultiPage
protected void RadMultiPage1_PageViewCreated(object sender, RadMultiPageEventArgs e)
    {
        string codeDoc = e.PageView.Attributes["CodeDoc"];
        if (!string.IsNullOrEmpty(codeDoc))
        {
            string userControlName = "usercontrol/ViewerDocument.ascx";
            ViewerDocument userControl = Page.LoadControl(userControlName) as ViewerDocument;
            userControl.ID = e.PageView.ID + "_ViewerDocument";
            userControl.CodeDoc = e.PageView.Attributes["CodeDoc"];
            e.PageView.Controls.Add(userControl);
        }
    }


My user control content:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ViewerDocument.ascx.cs"
    Inherits="Class_iWebAsp.usercontrol.ViewerDocument" %>
<telerik:RadCodeBlock runat="server" ID="PreviewDocumentForMultiDocCodeBlock">
    <script type="text/javascript">       
    </script>
</telerik:RadCodeBlock>
<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadToolBarPaging">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadSplitter1" LoadingPanelID="RadAjaxLoadingPanel1"  />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManagerProxy>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default">
</telerik:RadAjaxLoadingPanel>
<telerik:RadSplitter ID="RadSplitter1" runat="server" Width="100%" Height="100%"
    Orientation="Horizontal">
    <telerik:RadPane ID="RadPaneToolBarPaging" runat="server" Scrolling="None" Height="35px"
        Width="100%">
        <telerik:RadToolBar ID="RadToolBarPaging" runat="server" AutoPostBack="true" OnButtonClick="RadToolBarPaging_buttonClick"
            Width="100%">
            <Items>
                <telerik:RadToolBarButton ImageUrl="../images_toolbar/arrow_first.gif" Value="first">
                </telerik:RadToolBarButton>
                <telerik:RadToolBarButton ImageUrl="../images_toolbar/arrow_prev.gif" Value="prev">
                </telerik:RadToolBarButton>
                <telerik:RadToolBarButton IsSeparator="true">
                </telerik:RadToolBarButton>
                <telerik:RadToolBarButton PostBack="false" Value="info">
                    <ItemTemplate>
                        <asp:Label ID="LabelInfo" runat="server" Text="Page 1/1"></asp:Label>
                    </ItemTemplate>
                </telerik:RadToolBarButton>
                <telerik:RadToolBarButton IsSeparator="true">
                </telerik:RadToolBarButton>
                <telerik:RadToolBarButton ImageUrl="../images_toolbar/arrow_next.gif" Value="next">
                </telerik:RadToolBarButton>
                <telerik:RadToolBarButton ImageUrl="../images_toolbar/arrow_last.gif" Value="last">
                </telerik:RadToolBarButton>
                <telerik:RadToolBarButton IsSeparator="true" />
                <telerik:RadToolBarButton ImageUrl="../images_toolbar/zoom_arriere_16x.png" Value="zoommois"
                    PostBack="false">
                </telerik:RadToolBarButton>
                <telerik:RadToolBarButton ImageUrl="../images_toolbar/zoom_avant_16x.png" Value="zoomplus"
                    PostBack="false">
                </telerik:RadToolBarButton>
                <telerik:RadToolBarButton IsSeparator="true">
                </telerik:RadToolBarButton>
                <telerik:RadToolBarButton ImageUrl="../Icons/pdf.jpg" Value="saveas" Target="_blank"
                    PostBack="false" ToolTip="Télécharger(version PDF)">
                </telerik:RadToolBarButton>
                <telerik:RadToolBarButton ImageUrl="../Images/saveas.gif" Value="saveasOri" Target="_blank"
                    PostBack="false" ToolTip="Télécharger(vesion original)">
                </telerik:RadToolBarButton>
                <telerik:RadToolBarButton ImageUrl="../Images/print.gif" Value="print" PostBack="false"
                    Visible="false" ToolTip="Imprimer">
                </telerik:RadToolBarButton>
            </Items>
        </telerik:RadToolBar>
    </telerik:RadPane>
    <telerik:RadPane ID="RadPanePreviewDoc" runat="server">
        qsfhklqjfqklsfqklfjqlfjqlkf
    </telerik:RadPane>
</telerik:RadSplitter>
<asp:HiddenField ID="HiddenFieldPageNumber" runat="server" Value="1" />
<asp:HiddenField ID="HiddenFieldPageTotal" runat="server" Value="1" />

So When I click on the RadToolBarButton the ajax Postback is well fired, the second times is a not an ajax postback it's a simple postback, the RadAjaxManager is not on ajaxrequest, and my usercontrols disappear.

Could you help me?

4 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 05 Aug 2011, 11:31 AM
Hello Stephane,

Please revise the following help topic and online example which elaborate on Loading UserControls with Ajax. I hope this information will be useful for you.

All the best,
Pavlina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Stephane
Top achievements
Rank 1
answered on 05 Aug 2011, 12:33 PM
Ok I will try your issue.
Thanks.

Best regards,
Stéphane.
0
Bruno
Top achievements
Rank 1
answered on 08 Aug 2011, 05:42 PM
Hi Stephane, 

I am dealing with the same issue. Any luck on the links?

Regards, Tks
Bruno
0
Pavlina
Telerik team
answered on 08 Aug 2011, 09:51 PM
Hello Bruno,

Could you please open a formal support ticket and send us a sample project, illustrating the issue you are facing? We will debug it locally and turn back to you with a solution.

Best wishes,
Pavlina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Ajax
Asked by
Stephane
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Stephane
Top achievements
Rank 1
Bruno
Top achievements
Rank 1
Share this question
or