I have an UpdatePanel on which there sits a dropdownlist of providers and two labels that show the providers AU and Activity #. When the selectedIndex of the dropdown is zero, I want to hide the labels. I have tried both asp:panel controls with height=0 set in the code behind SelectedIndexChanged event and html div with style.visibility = 'hidden' in a javascript onchange event for the dropdown, and neither does anything. No errors, it just doesn't do anything. Here is my page code.
<asp:UpdatePanel id="UpdatePanel1" runat="server">
<contenttemplate>
<asp:DropDownList id="ddlProviders" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlProviders_SelectedIndexChanged"></asp:DropDownList>
<BR />
<DIV style="WIDTH: 100%; HEIGHT: 100%" id="divProviderDetail" noWrap>
<asp:Label id="Label1" runat="server" Text="AU#: " __designer:wfdid="w20"></asp:Label>
<asp:Label id="lblProviderAU" runat="server" __designer:dtid="844424930132022" __designer:wfdid="w17"></asp:Label> <BR />
<asp:Label id="Label2" runat="server" Text="Activity #: " __designer:wfdid="w21"></asp:Label>
<asp:Label id="lblActivityNumber" runat="server" __designer:dtid="844424930132024" __designer:wfdid="w18"></asp:Label>
</DIV>
<BR />
</contenttemplate>
</asp:UpdatePanel>
Any ideas? Thanks.
Protected Sub ddlProviders_SelectedIndexChanged(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles ddlProviders.SelectedIndexChanged
If (ddlProviders.SelectedIndex = 0)Then
lblProviderAU.Visible =False
lblActivityNumber.Visible =False
Else
lblProviderAU.Visible =True
lblActivityNumber.Visible =True
End If
End Sub
Or you could use a panel and set Visible = False for that.
whats the code you using at ddlProviders_SelectedIndexChanged
coz the aspx looks fine here
When I used a panel, I set height=0 so as to not leave a big blank spot. That didn't do anything, height was still the same.
If you don't want anything to move, then just change their text to "" rather than changing their height or visibility.
Setting an element's display CSS property to 'none' is a good way to hide elements on the client side. It has the advantage of not removing them from the DOM or rendered HTML (as is the case with those other methods), so you can still manipulate them on the client side later if need be.
document.getElementById('lblAU').class = 'none';
gave me an error when VS scanned the .js file at start. What is the correct syntax?
document.getElementById('lblAU').style.display = 'none';
or if you have a css class
.hide {display: none;}
document.getElementById('lblAU').className = 'hide';
No comments:
Post a Comment