locked
Ajax with multiple panels RRS feed

  • Question

  • User899592849 posted

     Hello:

    For example: I have a Students.aspx page using Ajax with 3 different panels like below and each panel contains different code. I have a main page that have links to Students.aspx page and I have set the property Visible=True to panel 1. My question is How do I make so that when clicked on Student 1 from the Main.aspx, it will call panel1 and when clicked on Student 2 from the Main.aspx, it will call panel2...etc...Thank you.

    Students.aspx

    <ajax:Update Panel ID="studentUpdatePanel" runat="server" UpdateMode="Conditional">  

    <ContentTemplate>

          <asp:Panel ID="panel1" runat="server" Visible="true">Code for student 1</asp:panel>    

         <asp:Panel ID="panel2" runat="server" Visible="false">Code for student 2</asp:panel>    

         <asp:Panel ID="panel3" runat="server" Visible="false">Code for student 3</asp:panel>

     </ContentTemplate>

    </ajax:UpdatePanel>

    --------------------------------------------------------------

    Main.aspx

    <a href="Students.aspx">Student 1</a>

    <a href="Students.aspx">Student 2</a>

    <a href="Students.aspx">Student 3</a>

    Wednesday, February 4, 2015 1:19 PM

Answers

  • User-37275327 posted

    I think you can simply use query string.

    <a href="Students.aspx?Id=1">Student 1</a>
    <a href="Students.aspxId=2">Student 2</a>
    <a href="Students.aspxId=3">Student 3</a>

    Set all panels to visible false. on the code behind of Student.aspx, inside the page load event

    if (Request.QueryString["id"] != null) {
    
      string id=Request.QueryString["id"];
    
      if (id=="1")
      {
        panel1.visible=true;
      }
      else if (id=="2")
      {
         panel2.visible=true;
      }
      else if(id=="3")
      {
        panel3.visible=true;
       }
    
    
    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 5, 2015 6:06 AM

All replies

  • User-37275327 posted

    I think you can simply use query string.

    <a href="Students.aspx?Id=1">Student 1</a>
    <a href="Students.aspxId=2">Student 2</a>
    <a href="Students.aspxId=3">Student 3</a>

    Set all panels to visible false. on the code behind of Student.aspx, inside the page load event

    if (Request.QueryString["id"] != null) {
    
      string id=Request.QueryString["id"];
    
      if (id=="1")
      {
        panel1.visible=true;
      }
      else if (id=="2")
      {
         panel2.visible=true;
      }
      else if(id=="3")
      {
        panel3.visible=true;
       }
    
    
    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 5, 2015 6:06 AM
  • User1711366110 posted

    Hi sn002,
      As per our case, You can find the panel1,panel2,panel3 Ids through view source in browser.
    Then you can try like below :
    <a href="Students.aspx#ViewSourcePanelId1">Student 1</a>

    <a href="Students.aspx#ViewSourcePanelId2">Student 2</a>

    <a href="Students.aspx#ViewSourcePanelId3">Student 3</a>

    --
    with regards,
    Edwin

    Thursday, February 5, 2015 6:32 AM
  • User899592849 posted

    This worked perfectly.  Thank you! Laughing

    Friday, February 6, 2015 2:43 PM