asp.net panel control

I want to use 2 panels on 1 page with different information in it.

Now I want Panel 1 to be Visible True and Panel 2 Visible False

How can I best switch between the 2 panels?

Also keep in mind I don't want the page load to be reloaded.

Is this possile?

Please sent me an example on how I can get this to work.
Marc RosemaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPOwnerCommented:
simple as toggling the display properties from visible=true to false and vice versa.. BUT that area has to be reloaded.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Kyle AbrahamsSenior .Net DeveloperCommented:
you might be better off using a tab control and some ajax.  David is correct in that the area around the panel has to be reloaded, but using ajax will cause just that section to be reloaded.

Here's a quick video on how to do it:
https://www.youtube.com/watch?v=dH_d31weLlA
Johny BravoCommented:
See this working sample. Here Panel1 is shown while 2 is not visible and when we show Panel2 , 1 is hidden
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

</head>
<body>
    <form id="form1" runat="server">
        <table>
            <tr>
                <td>
                    <div style="border: 1px solid blue; background-color: #99CCFF; padding: 5px; width: 150px;">
                        <a id="myHeader1" href="javascript:showonlyone('newboxes1');">show this one only</a>

                    </div>
                    <div class="newboxes" id="newboxes1" style="border: 1px solid black; background-color: #CCCCCC; display: block; padding: 5px; width: 150px;">
                        Div #1
                 <asp:Panel ID="panel1" runat="server">
                     <asp:DropDownList ID="DropDownList1" runat="server">
                         <asp:ListItem Text="Panel1.1"></asp:ListItem>
                         <asp:ListItem Text="Panel1.2"></asp:ListItem>
                         <asp:ListItem Text="Panel1.3"></asp:ListItem>
                     </asp:DropDownList>
                 </asp:Panel>
                    </div>
                </td>
                <td>
                    <div style="border: 1px solid blue; background-color: #99CCFF; padding: 5px; width: 150px;">
                        <a id="myHeader2" href="javascript:showonlyone('newboxes2');">show this one only</a>

                    </div>
                    <div class="newboxes" id="newboxes2" style="border: 1px solid black; background-color: #CCCCCC; display: none; padding: 5px; width: 150px;">
                        Div #2
              <asp:Panel ID="panel2" runat="server">
                  <asp:DropDownList ID="DropDownList2" runat="server">
                      <asp:ListItem Text="Panel2.1"></asp:ListItem>
                      <asp:ListItem Text="Panel2.2"></asp:ListItem>
                      <asp:ListItem Text="Panel2.3"></asp:ListItem>
                  </asp:DropDownList>
              </asp:Panel>
                    </div>
                </td>

            </tr>
        </table>
        <script type="text/javascript">
            function showonlyone(thechosenone) {
                $('.newboxes').each(function (index) {
                    if ($(this).attr("id") == thechosenone) {
                        $(this).show(200);
                    }
                    else {
                        $(this).hide(600);
                    }
                });
            }
        </script>
    </form>

</body>
</html>

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.