Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Hide or Show Div

Hide or Show Div

Scheduled Pinned Locked Moved ASP.NET
7 Posts 4 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NET India
    wrote on last edited by
    #1

    Hello Friends, I've four div's and four link if i click on Link1 then first Div1 is displayed or opened and if i click on Link2 then Div2 is displayed and so on.. But i want if i click on Link2 and Div1 is already opened then it must display Div2 and Hide Div1 I mean only one Div must be displayed at a time as i click on the link respectively.

    L S 2 Replies Last reply
    0
    • N NET India

      Hello Friends, I've four div's and four link if i click on Link1 then first Div1 is displayed or opened and if i click on Link2 then Div2 is displayed and so on.. But i want if i click on Link2 and Div1 is already opened then it must display Div2 and Hide Div1 I mean only one Div must be displayed at a time as i click on the link respectively.

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Sounds reasonable to me. Good job. Keep in mind though that the primary use of these forums is for asking questions, not reporting status. For more details read the first message in the forum titled "How to get an answer to your question".

      led mike

      R 1 Reply Last reply
      0
      • N NET India

        Hello Friends, I've four div's and four link if i click on Link1 then first Div1 is displayed or opened and if i click on Link2 then Div2 is displayed and so on.. But i want if i click on Link2 and Div1 is already opened then it must display Div2 and Hide Div1 I mean only one Div must be displayed at a time as i click on the link respectively.

        S Offline
        S Offline
        Sandilian
        wrote on last edited by
        #3

        Hai fried This code works fine. do you want like this ?. <div id="div1" visible="false" runat="server"> hai </div> <div id="div2" visible="false" runat="server"> hai2 </div> <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">LinkButton</asp:LinkButton> <asp:LinkButton ID="LinkButton2" runat="server" OnClick="LinkButton2_Click">LinkButton</asp:LinkButton> protected void LinkButton1_Click(object sender, EventArgs e) { div2.Visible = false; div1.Visible = true; } protected void LinkButton2_Click(object sender, EventArgs e) { div2.Visible = true; div1.Visible = false; } check this code.

        R 1 Reply Last reply
        0
        • L led mike

          Sounds reasonable to me. Good job. Keep in mind though that the primary use of these forums is for asking questions, not reporting status. For more details read the first message in the forum titled "How to get an answer to your question".

          led mike

          R Offline
          R Offline
          raushan_9
          wrote on last edited by
          #4

          Dear friend if u cannt give me the right answer dont teach me the rules. Just utilize ur precious time in doing something dont give me such a stupid answer..............

          L 1 Reply Last reply
          0
          • S Sandilian

            Hai fried This code works fine. do you want like this ?. <div id="div1" visible="false" runat="server"> hai </div> <div id="div2" visible="false" runat="server"> hai2 </div> <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">LinkButton</asp:LinkButton> <asp:LinkButton ID="LinkButton2" runat="server" OnClick="LinkButton2_Click">LinkButton</asp:LinkButton> protected void LinkButton1_Click(object sender, EventArgs e) { div2.Visible = false; div1.Visible = true; } protected void LinkButton2_Click(object sender, EventArgs e) { div2.Visible = true; div1.Visible = false; } check this code.

            R Offline
            R Offline
            raushan_9
            wrote on last edited by
            #5

            Thnx friend for ur answer. But i'm implementing this in javascript not on server side because of postback........

            S 1 Reply Last reply
            0
            • R raushan_9

              Thnx friend for ur answer. But i'm implementing this in javascript not on server side because of postback........

              S Offline
              S Offline
              Sandilian
              wrote on last edited by
              #6

              Hai Here is the code try to use it. <script language="jscript" type="text/javascript"> function ShowDiv1(div1,div2) { document.getElementById(div2).style.visibility="hidden"; document.getElementById(div1).style.visibility="visible"; } function ShowDiv2(div1,div2) { document.getElementById(div2).style.visibility="visible"; document.getElementById(div1).style.visibility="hidden"; } </script> <div id="div1"> <asp:TextBox ID="txt1" Text="Hai" runat="server" ></asp:TextBox> </div> <div id="div2"> <asp:TextBox ID="TextBox4" Text="Good Noon" runat="server" ></asp:TextBox> <br /> <br /> </div> <asp:LinkButton ID="LinkButton1" OnClientClick="ShowDiv1('div1','div2'); return false;" runat="server" >LinkButton</asp:LinkButton> <asp:LinkButton ID="LinkButton2" OnClientClick="ShowDiv2('div1','div2'); return false;" runat="server" >LinkButton</asp:LinkButton>

              modified on Wednesday, April 9, 2008 6:21 AM

              1 Reply Last reply
              0
              • R raushan_9

                Dear friend if u cannt give me the right answer dont teach me the rules. Just utilize ur precious time in doing something dont give me such a stupid answer..............

                L Offline
                L Offline
                led mike
                wrote on last edited by
                #7

                raushan_9 wrote:

                if u cannt give me the right answer dont teach me the rules.

                Fuck off asshole you didn't ask a question you fucking idiot.

                led mike

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups