title: ASP.NET - Show and hide multiple divs
body: <p>I was wondering if the method I am currently using is a best practice or if I'm possibly using more resources than necessary. With my current site I show and hide divs depending on what the user needs to do or has access to. </p>
  
  <p>Currently I declare my divs like this:</p>
  
  <pre><code>&lt;div id="NormalView" runat="server" visible="false"&gt;
  </code></pre>
  
  <p>I show and hide my divs with this function:</p>
  
  <pre><code>Private Sub DivSelection(ByVal Selection As String)
      NormalView.Visible = False
      FieldRepView.Visible = False
      TestDiv.Visible = False
      Ordering.Visible = False
  
      If Selection.Equals("NormalView") Then
          GVlowstock.DataBind()
          NormalView.Visible = True
      ElseIf Selection.Equals("FieldRepView") Then
          FieldRepView.Visible = True
      ElseIf Selection.Equals("PasswordChange") Then
          TestDiv.Visible = True
      ElseIf Selection.Equals("Ordering") Then
          Ordering.Visible = True
      End If
  End Sub
  </code></pre>
  
  <p>I'm going to be adding more divs to my webpage so I'm afraid that my current method is going to balloon out of control and be more of a hassle than it is useful. </p>
  
  <p>I'm wondering if there is a way to condense this down to fewer lines and be more efficient at the same time. Possibly something like </p>
  
  <pre><code>Private Sub DivSelection(divID)
      alldivs.visible = False
  
      divID.visible = True
  
  End Sub
  </code></pre>