So I have a .Net website with a master page and some page contents ... I am using vb.net with framework 4.0 and jquery 1.6. I am trying to show a panel that is present in master page and invisible by default. I am trying to do this from my content page in client side using javascript.
Below is my panel in Master.aspx
<asp:Panel ID="PanelMsg" runat="server" CssClass="SMSMSG" Visible="false">
<asp:Label ID="labMsg" runat="server">test test </asp:Label>
<input id="AnimationDiv" type="checkbox" onclick="addTotargetGroup(this);" />
<label class="AnimationDiv" for="AnimationDiv">
An SMS has been sent to Insured.</label>
</asp:Panel>
Javascript in my_page.aspx:
var PanelMsg = document.getElementById('<%=CType(Me.Master.FindControl("PanelMsg"), Panel).ClientID %>');
alert(PanelMsg);
In this case PanelMsg is null, BUT if I change visibility of panel to true, then PanelMsg is [object HTMLDivElement]. So the main problem is that I am trying to get the panelMsg and show it here, and change the label value, but it is returned as null when it is invisible. So how can I solve this problem?
What I have tried:
I have tried to get the label value when panel is visible and I succeed:
var labMsg = document.getElementById('<%=CType(Me.Master.FindControl("labMsg"), Label).ClientID %>');
alert(labMsg.innerHTML);
But when I run the same code with invisible pan I got an error: cannot read property innerHTML of null.