title: Show hide div using codebehind
body: <p>I have a <code>DropDownList</code> for which I am trying to show a <code>div</code> <code>OnSelectedIndexChanged</code> but it says <code>OBJECT REQUIRED</code>.</p>
  
  <p>I am binding the <code>DataList</code> in that div:</p>
  
  <p><em>aspx</em>:</p>
  
  <pre><code>&lt;asp:DropDownList runat="server" ID="lstFilePrefix1" AutoPostBack="True" 
                    OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" &gt;
    &lt;asp:ListItem Text="Prefix1" Value="Prefix1" /&gt;
    &lt;asp:ListItem Text="Prefix2" Value="Prefix2" /&gt;
    &lt;asp:ListItem Text="Prefix3" Value="Prefix3" /&gt;
    &lt;asp:ListItem Text="Prefix1 and Prefix2" Value="Prefix1 and Prefix2" /&gt;
    &lt;asp:ListItem Text="Prefix2 and Prefix3" Value="Prefix2 and Prefix3" /&gt;
  &lt;/asp:DropDownList&gt;
  
  &lt;asp:DataList ID="DataList1" runat="server" RepeatColumns="4"  
                CssClass="datalist1"  OnItemDataBound="SOMENAMEItemBound"
                CellSpacing="6" onselectedindexchanged="DataList1_SelectedIndexChanged" 
                HorizontalAlign="Center" Width="500px"&gt;
  </code></pre>
  
  <p><em>code behind</em>:</p>
  
  <pre><code>protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
  {
      if (lstFilePrefix1.SelectedItem.Text=="Prefix2")
      {
          int TotalRows = this.BindList(1);
          this.Prepare_Pager(TotalRows);
          Page.ClientScript.RegisterClientScriptBlock(GetType(), "JScript1", "ShowDiv('data');", true);
      }
  }
  </code></pre>
  
  <p><em>javascript</em>:</p>
  
  <pre><code>function ShowDiv(obj)
  {
       var dataDiv = document.getElementById(obj);
       dataDiv.style.display = "block";
  }
  </code></pre>
  
  <p>What am I doing wrong?</p>