Search code examples
c#asp.netajaxaccordionmultiview

MultiView with ajax accordion and updatepanel


I have a question as I am using Ajax accordion how and the item inside this accordion i am using Link Button and it did not accept value to connect it with view could you please help with this case you can know more what I mean by watching this YouTube url

enter link description here

<asp:Accordion ID="Accordion1" CssClass="accordion" HeaderCssClass="accordionHeader"
            HeaderSelectedCssClass="accordionHeaderSelected" ContentCssClass="accordionContent"
            runat="server" Width="198px">
            <Panes>
                <asp:AccordionPane ID="AccordionPane1" runat="server">
                    <Header>
                        My Info</Header>
                    <Content>

                            <img src="iconsimg/pinfo.png" alt="Services" /><asp:LinkButton ID="LinkButton2" runat="server">&nbsp;My Info</asp:LinkButton><br />


                      <img src="iconsimg/mail.png" alt="Services" /><asp:LinkButton ID="LinkButton1" runat="server">&nbsp;Mail</asp:LinkButton><br />



                    </Content>
                </asp:AccordionPane>
                <asp:AccordionPane ID="AccordionPane2" runat="server">
                    <Header>
                        Tools</Header>
                    <Content>
                   <img src="iconsimg/addads2.png" alt="Services" /><asp:LinkButton ID="LinkButton3" runat="server">&nbsp;Add Ads</asp:LinkButton><br />


                      <img src="iconsimg/viewads.png" alt="Services" /><asp:LinkButton ID="LinkButton4" runat="server">&nbsp;My Ads</asp:LinkButton><br />

                      <img src="iconsimg/comments.png" alt="Services" /><asp:LinkButton ID="LinkButton5" runat="server">&nbsp;Comments</asp:LinkButton><br />

                    </Content>
                </asp:AccordionPane>
                <asp:AccordionPane ID="AccordionPane3" runat="server">
                    <Header>
                        Pane 3</Header>
                    <Content>
                    <img src="iconsimg/FAVOL.png" alt="favourite" /><asp:LinkButton ID="LinkButton6" runat="server">&nbsp;Favourite</asp:LinkButton><br />
                    </Content>
                </asp:AccordionPane>
            </Panes>
        </asp:Accordion>

And this is the MultiView

<asp:MultiView ID="usradnmultiview" runat="server" ActiveViewIndex="0">

            <asp:View ID="View1" runat="server">

                <p>hbibi</p>

            </asp:View>
            <asp:View ID="View2" runat="server">
            <h1>bibibonmojm</h1>
            </asp:View>
            <asp:View ID="View3" runat="server">
            </asp:View>
            <asp:View ID="View4" runat="server">
            </asp:View>
            <asp:View ID="View5" runat="server">
            </asp:View>
            <asp:View ID="View6" runat="server">
            </asp:View>

        </asp:MultiView>

Solution

  • I did not see in your code where you are setting the active view of the multi view.In your link button click event set your active view by wiring each of your link button to this event.

    protected void SetActiveView_Click(object sender, EventArgs e)
    {   
       Button activeButton= (Button) sender;
          switch (activeButton.ID)
    {
          Case "LinkButton2" :
    usradnmultiview.ActiveViewIndex = 0;
            break;
          Case "LinkButon3" :
         usradnmultiview.ActiveViewIndex = 1;
            break;
            default:
            return "Invalid";
    
          }
    
     }
    

    And in your mark up sandwich an iframe in your multiview first view.

        <asp:View ID="View1" runat="server" >
    
                <iframe id="myiframe" height="200" width="600"    src="http://www.youtube.com/embed/tY8iY-QkRBk" >
    
                </iframe>
            </asp:View>
    

    Notice how the video is embedded.Just putting the raw url of the video in the src tag would give you the error: ' Refused to display ..your link in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.