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.getEle mentById("drpFi lterType");
var selectedFilterT ype = drpFilterType
..options[drpFilterType.s electedIndex].value;
if (selectedFilter Type == "MonthFilte r")
{
document.getEle mentById("drpMo nthFilter").sty le.visibility=" visible";
document.getEle mentById("drpYe arFilter").styl e.visibility="v isible";
}
else if (selectedFilter Type == "YearFilter ")
{
document.getEle mentById("drpMo nthFilter").sty le.visibility=" hidden";
document.getEle mentById("drpYe arFilter").styl e.visibility="v isible";
}
else if (selectedFilter Type == "All")
{
document.getEle mentById("drpMo nthFilter").sty le.visibility=" hidden";
document.getEle mentById("drpYe arFilter").styl e.visibility="h idden";
}
}
</script>
-- ASP.NET Page --
Filter Type
<asp:dropdownli st id="drpFilterTy pe" runat="server" CssClass="boxfo rmwh"
onchange="retur n FilterStatus()" >
<asp:ListItem Value="MonthFil ter">Month</asp:ListItem>
<asp:ListItem Value="YearFilt er">Year</asp:ListItem>
<asp:ListItem Value="All">All Data</asp:ListItem>
</asp:dropdownlis t>
<asp:dropdownli st id="drpMonthFil ter" runat="server"
style="visibili ty:visible;" /></td>
<asp:dropdownli st id="drpYearFilt er" runat="server"
style="visibili ty:visible;"/>
<asp:button id="btnFilterDa ta" runat="server" CssClass="Butto n" Text="Filter
Data"></asp:button>