RadPanelBar, ViewState off and PostBack problem

5 posts, 0 answers
  1. Chen
    Chen avatar
    46 posts
    Member since:
    Oct 2010

    Posted 22 Apr 2011 Link to this post

    Hi
    My app has ViewState disabled.
    I have a panel bar with multiple items. Depending on some server side logic, I may hide some panel items.
    The PanelBar loads fine.
    However, on postback the wrong panel item opens.
    Let's say I have 5 panel items and the server side logic hides the first one.
    If I click Edit on the 4th item, on postback the 3rd item would open.

    In the example below, no panel would be open on postback.
    How can I fix it?

    Thanks
    Chen

    <telerik:RadPanelBar ID="RadPanelBar1" Runat="server">
                <Items>
                    <telerik:RadPanelItem runat="server" Text="Root RadPanelItem1">
                    </telerik:RadPanelItem>
                    <telerik:RadPanelItem runat="server" Text="Root RadPanelItem2" Selected="True">
                    </telerik:RadPanelItem>
                    <telerik:RadPanelItem runat="server" Text="Root RadPanelItem3">
                        <ContentTemplate>
                            <asp:FormView ID="FormView1" runat="server" DataSourceID="LinqDataSourcePayee"
                                DataKeyNames="id">
                                <EditItemTemplate>
                                    firstName:
                                    <asp:TextBox ID="firstNameTextBox" runat="server"
                                        Text='<%# Bind("firstName") %>' />
                                    <br />
                                    lastName:
                                    <asp:TextBox ID="lastNameTextBox" runat="server"
                                        Text='<%# Bind("lastName") %>' />
                                    <br />
                                    <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True"
                                        CommandName="Update" Text="Update" />
                                     <asp:LinkButton ID="UpdateCancelButton" runat="server"
                                        CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                                </EditItemTemplate>
                                 
                                <ItemTemplate>
                                    firstName:
                                    <asp:Label ID="firstNameLabel" runat="server" Text='<%# Bind("firstName") %>' />
                                    <br />
                                    lastName:
                                    <asp:Label ID="lastNameLabel" runat="server" Text='<%# Bind("lastName") %>' />
                                    <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False"
                                        CommandName="Edit" Text="Edit" />
                                </ItemTemplate>
                            </asp:FormView>
                        </ContentTemplate>
                    </telerik:RadPanelItem>
                </Items>
            </telerik:RadPanelBar>

    Code behind:
    protected void Page_Load(object sender, EventArgs e)
    {
           RadPanelBar1.Items[0].Visible = RadPanelBar1.Items[0].Enabled =false;
    }


  2. Chen
    Chen avatar
    46 posts
    Member since:
    Oct 2010

    Posted 28 Apr 2011 Link to this post

    Anyone?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 29 Apr 2011 Link to this post

    Hi Chen,

    We have already responded to your support ticket regarding this issue.

    Greetings,
    Dimitar Terziev
    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.

  5. Spencer
    Spencer avatar
    4 posts
    Member since:
    Aug 2011

    Posted 09 Feb 2012 Link to this post

    Really Telerik? 

    Saying, "we already responded" and not providing a link to your reply doesn't help others who find this page with a similar problem.

    Come on guys, you're better than this.
  6. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 14 Feb 2012 Link to this post

    Hi Spencer,

    Since the response was in a support ticket there is no way that we can provide its url. However, below you can find the answer of the ticket along with a runnable page:

    In general when the ViewState is disabled, it's your responsibility to restore the state of the page after a post-back. You can find the attached example page where the expanded items are saved into a hidden field on the page and when a post-back occur in Page_Load event these items are expanded again manually. This should prevent problems with the wrong expanded items even, if you hide/remove some of them.

    Kind regards,
    Kate
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017