Dropdownlist without postback when autopostback must set to true (code's included)
<p>I have created one drop down list and a calendar extender w corresponding. Each value of the dropdownlist should affect the style visibility differently based on the selection. As right now, the functionality works; however, for each time I try  select a different listtem, it refreshes the entire page and I do not want to set AutoPostBack="false.
   Please let me know what's the best way to solve this issue.</p>

<p>asp.ascx   </p>

<pre><code>           &lt;asp:DropDownList ID="dropdownlist" runat="server"  OnSelectedIndexChanged="dropdownlist_SelectedIndexChanged" AutoPostBack="True" &gt;
                        &lt;asp:ListItem Value="1"&gt;a&lt;/asp:ListItem&gt;
                        &lt;asp:ListItem Value="2"&gt;b&lt;/asp:ListItem&gt;
                        &lt;asp:ListItem Value="3"&gt;c&lt;/asp:ListItem&gt;
                        &lt;asp:ListItem Value="4"&gt;d&lt;/asp:ListItem&gt;
                        &lt;asp:ListItem Value="5"&gt;e&lt;/asp:ListItem&gt;
                        &lt;asp:ListItem Value="6"&gt;f&lt;/asp:ListItem&gt;
                        &lt;asp:ListItem Value="7"&gt;g&lt;/asp:ListItem&gt;
                    &lt;/asp:DropDownList&gt; &lt;asp:Panel runat="server" ID="StartDate" &gt;
                    &lt;asp:Label ID="lblStartDate"  runat="server" Text="Start Date:"&gt;&lt;/asp:Label&gt;

                    &lt;asp:TextBox ID="txtStartDate" runat="server"&gt;&lt;/asp:TextBox&gt;
                    &lt;asp:CompareValidator ID="CompareValidatorStartDate" runat="server" ErrorMessage="Please enter a validate date" ControlToValidate="txtStartDate" Type="Date" Operator="DataTypeCheck" Display="Static" Font-Italic="False" SetFocusOnError="True"&gt;&lt;/asp:CompareValidator&gt;

            &lt;/asp:Panel&gt;
            &lt;cc1:CalendarExtender ID="CalendarExtenderStartDate" TargetControlID="txtStartDate" runat="server"&gt;&lt;/cc1:CalendarExtender&gt;
            &lt;asp:Panel runat="server" ID="EndDate" &gt;

                    &lt;asp:Label ID="lblEndDate" runat="server" Text="End Date:"&gt;&lt;/asp:Label&gt;

                    &lt;asp:TextBox ID="txtEndDate" runat="server"&gt;&lt;/asp:TextBox&gt;
                    &lt;asp:CompareValidator ID="CompareValidatorEndDate" runat="server" ErrorMessage="Please enter a validate date" ControlToValidate="txtEndDate" Type="Date" Operator="DataTypeCheck" Display="Static" Font-Italic="False" SetFocusOnError="True"&gt;&lt;/asp:CompareValidator&gt;

            &lt;/asp:Panel&gt;
            &lt;cc1:CalendarExtender ID="CalendarExtenderEndDate" TargetControlID="txtEndDate" runat="server"&gt;&lt;/cc1:CalendarExtender&gt;
</code></pre>

<p>Code Behind</p>

<pre><code>if (!IsPostBack)
    {



            SetDateFields();
    }
}


  protected void dropdownlist_SelectedIndexChanged(object sender, EventArgs e)
{
    SetDateFields();
} 
    private void SetDateFields()
{ 
    switch (dropdownlist.SelectedValue)
    {
        case "1":
        case "3":
        case "5":
            EndDate.Visible = false;
            StartDate.Visible = true;
            lblStartDate.Text = "As Of Date:";
            break;
        case "7":
            EndDate.Visible = false;
            StartDate.Visible = false;
            break;
        default:
            EndDate.Visible = true;
            StartDate.Visible = true;
            lblStartDate.Text = "Start Date:";
            lblEndDate.Text = "End Date:";
            break;
    }   
}
</code></pre>
