Wanted to know if there's a way to change a form field's visibility within a ModalPopup (from ModalPopupExtender) based upon a DropDownList's change in value. This page's technique doesn't seem to work: Change visibility of ASP.NET label with JavaScript.
Javascript:
<script type="text/javascript">
function ShowHide() {
if(document.getElementById('<%=DdlASVisibilityTest.ClientID%>') == "Show") {
document.getElementById('<%=LblASBillingName.ClientID%>').style.display = 'inherit';
document.getElementById('<%=TxtASBillingName.ClientID%>').style.display = 'inherit';
}
if(document.getElementById('<%=DdlASVisibilityTest.ClientID%>') == "Hide") {
document.getElementById('<%=LblASBillingName.ClientID%>').style.display = 'none';
document.getElementById('<%=TxtASBillingName.ClientID%>').style.display = 'none';
}
{
</script>
asp.net:
<asp:ModalPopupExtender OKControlID="BtnASOkay" CancelControlID="BtnASCancel" BackgroundCssClass="modalBackground" DropShadow="True" ID="BtnAddSupplier_ModalPopupExtender" runat="server" DynamicServicePath="" Enabled="True" TargetControlID="BtnAddSupplier" PopupControlID="PnlAddSupplier">
<Animations>
<OnShown>
<FadeIn Duration="0.25" Fps="40" />
</OnShown>
<OnHiding>
<FadeOut Duration="0.25" Fps="40" />
</OnHiding>
</Animations>
</asp:ModalPopupExtender>
<asp:RoundedCornersExtender ID="RCE" runat="server" TargetControlID="PnlAddSupplier" Radius="6" Corners="All" />
<asp:Button ID="BtnAddSupplier" runat="server" CssClass="buttonsmall" Text="Add Suplier" />
<asp:Panel ID="PnlAddSupplier" CssClass ="panel" runat="server">
<div class="ASHeader">
<asp:Label ID="LblASHeader" runat="server" Text="Add Supplier" CssClass="bodytxt" Font-Bold="True"></asp:Label>
</div>
<div class="ASInputs">
<asp:Table runat="server">
<asp:TableRow ID="TRASVisibilityTest" runat="server">
<asp:TableCell ID="TCLblASVisibilityTest" runat="server"><asp:Label ID="LblASVisibilityTest" runat="server" Text="Test Visibility" CssClass="bodytxt" Font-Bold="False"></asp:Label></asp:TableCell>
<asp:TableCell ID="TCDdlASVisibilityTest" runat="server"><asp:DropDownList ID="DdlASVisibilityTest" runat="server" onchange="ShowHide()">
<asp:ListItem>Show</asp:ListItem>
<asp:ListItem>Hide</asp:ListItem>
</asp:DropDownList></asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="TRASBillingName" runat="server">
<asp:TableCell ID="TCLblASBillingName" runat="server"><asp:Label ID="LblASBillingName" runat="server" Text="Supplier's Billing Name" CssClass="bodytxt" Font-Bold="False" style="display: none;"></asp:Label></asp:TableCell>
<asp:TableCell ID="TCTxtASBillingName" runat="server"><asp:TextBox ID="TxtASBillingName" CssClass="bodytxt" runat="server" style="display: none;"></asp:TextBox></asp:TableCell>
</asp:TableRow>
</asp:Table>
</div>
<div class="DivASControls" align="center">
<asp:Button ID="BtnASOkay" runat="server" CssClass="buttonsmall" Text="Add Supplier" style="display: none;" />
<asp:Button ID="BtnASCancel" runat="server" CssClass="buttonsmall" Text="Cancel" />
</div>
</asp:Panel>
Thanks a lot in advance!