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

RadPanelBar, ViewState off and PostBack problem

4 Answers 148 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Chen
Top achievements
Rank 1
Chen asked on 22 Apr 2011, 05:56 PM
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;
}


4 Answers, 1 is accepted

Sort by
0
Chen
Top achievements
Rank 1
answered on 28 Apr 2011, 10:21 AM
Anyone?
0
Dimitar Terziev
Telerik team
answered on 29 Apr 2011, 12:00 PM
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.

0
Spencer
Top achievements
Rank 1
answered on 10 Feb 2012, 02:22 AM
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.
0
Kate
Telerik team
answered on 14 Feb 2012, 09:55 AM
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 >>
Tags
PanelBar
Asked by
Chen
Top achievements
Rank 1
Answers by
Chen
Top achievements
Rank 1
Dimitar Terziev
Telerik team
Spencer
Top achievements
Rank 1
Kate
Telerik team
Share this question
or