Hello All:
I hava a ASP.NET Web Page where I want to change the visibility of a
Dropdown, I want to avoid using Postback
since the selection of the Dropdown choices is always the same. The Code
below is just a date filter selection.
The Code works fine but on page postback I want to reload the Js script so
the Dropdown visibility selection remains.
--- JS ---
<script>
function FilterStatus()
{
var drpFilterType = document.getElementById("drpFilterType");
var selectedFilterType = drpFilterType
..options[drpFilterType.selectedIndex].value;
if (selectedFilterType == "MonthFilter")
{
document.getElementById("drpMonthFilter").style.vi sibility="visible";
document.getElementById("drpYearFilter").style.vis ibility="visible";
}
else if (selectedFilterType == "YearFilter")
{
document.getElementById("drpMonthFilter").style.vi sibility="hidden";
document.getElementById("drpYearFilter").style.vis ibility="visible";
}
else if (selectedFilterType == "All")
{
document.getElementById("drpMonthFilter").style.vi sibility="hidden";
document.getElementById("drpYearFilter").style.vis ibility="hidden";
}
}
</script>
-- ASP.NET Page --
Filter Type
<asp:dropdownlist id="drpFilterType" runat="server" CssClass="boxformwh"
onchange="return FilterStatus()" >
<asp:ListItem Value="MonthFilter">Month</asp:ListItem>
<asp:ListItem Value="YearFilter">Year</asp:ListItem>
<asp:ListItem Value="All">All Data</asp:ListItem>
</asp:dropdownlist>
<asp:dropdownlist id="drpMonthFilter" runat="server"
style="visibility:visible;" /></td>
<asp:dropdownlist id="drpYearFilter" runat="server"
style="visibility:visible;"/>
<asp:button id="btnFilterData" runat="server" CssClass="Button" Text="Filter
Data"></asp:button>