Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 566075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:56:22+00:00 2026-05-13T12:56:22+00:00

I have 2 sections of my website I am developing, a reference box that

  • 0

I have 2 sections of my website I am developing, a reference box that has a fixed width and a working box that has the same height as the content. I am trying to make it so the user can swap the content between the two boxes. I have the following type of setup in the aspx page:

<asp:panel id="pnlReference" runat="server" CssClass="referencePanel" >
    <asp:panel id="pnlsection1" runat="server" >
        Content....
    </asp:panel>
</asp:panel>

<asp:linkbutton id="lbtSwapPanels" runat="server" />

<asp:panel id="pnlWorking" runat="server" CssClass="workingPanel" >
    <asp:panel id="pnlSection2" runat="server" >
       Content....
    </asp:panel>
</asp:panel>

What I am trying to have occur is when I press the lbtSwapPanels linkbutton, it moves pnlSection1 into pnlWorking and pnlSection2 into pnlReference. The code I used to do this in the OnClick method was:

    Control pane1, pane2;

    pane1 = pnlWorking.Controls[0];
    pane2 = pnlReference.Controls[0];

    // Remove them from their respective panels
    pnlWorking.Controls.Remove(pane1);
    pnlReference.Controls.Remove(pane2);

    // Add them to the opposite pane
    pnlWorking.Controls.Add(pane2);
    pnlReference.Controls.Add(pane1);

Unfortunately, this does not work. When I click the linkbutton, nothing happens. If I then do something to perform another postback the reference and working panels become empty. I assume this has to do with the change not being saved into Viewstate but I don’t know how to get around that.

Does anyone have any ideas on how to do this?

Update: It seems that moving objects around with Jquery is causing issues with asp.net postbacks as well as making my asp.net ajax tabcontainer completely fail to function. After 2 swaps and postbacks, further postbacks cease to function at all. Here’s the new code

<div id="referencePane">
  <asp:panel id="pnlsection1" runat="server" >
    Content with tab container
  </asp:panel
</div>
<a href="#" onclick="SwapPanes()">Swap Panes</a>
<div id="workingPane">
  <asp:panel id="pnlsection2" runat="server" >
    Content
  </asp:panel>
</div>

Here’s the javascript:

function SwapPanes() {
    var pane1, pane2;    

    pane1 = $("#workingPane").html();
    pane2 = $("#referencePane").html();
    $("#workingPane").empty();
    $("#referencePane").empty();

    // Add them to the opposite pane
    $("#workingPane").prepend(pane2);
    $("#referencePane").prepend(pane1);
}

First postback causes the tabcontainer to fail (javascript exceptions claiming it’s trying to create a tab container with teh same ID (only one exists in the original aspx page). Postbacks then proceed to do wierd stuff.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T12:56:22+00:00Added an answer on May 13, 2026 at 12:56 pm

    Have you thought about keeping the controls in the panel but just swapping the position of the panels? You can do this pretty easily in JQuery although you’ll be using DIVS instead of ASP.NET panels. This is, again, quite easy since Panels just translate to DIVS in the end. I did this recently for a wizard-style questionnaire (moving from panels to divs) and I was surprised how easy it was.

    Update: Note that, when you swap the div positions, you can change the style as well (again, easy in JQuery) so that the user won’t have a jarring “why did these two things change position” experience.

    The bottom line, really, is that I think you are trying to use a hammer to drive a screw. JQuery is the screwdriver you are looking for and learning it is very much worth your while!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.