Reputation: 157
I have the following aspx code:
<div id="IsAccountingOk" class="modalDialog">
<div>
<a href="#close" title="Luk" class="close">X</a><br />
<asp:Label ID="lblIsAccountingOkHeader" runat="server" Text="Kassekladde:" Font-Size="Large"></asp:Label><br /><br />
<asp:Label ID="lblMessage" runat="server" Text="Der skal først vælges regnskabsår!"></asp:Label><br />
<br />
<asp:Button ID="btnIsAccountingOK" runat="server" Text="Ok" OnClick="btnIsAccountingOK_Click"/>
</div>
</div>
but how can I access 'IsAccountingOk' and get it via document.getElementByID? I have also tried the following with no success :-(
$(document).ready(function () {
var session = '<%=Session["AccountYearID"] == null%>';
if (session.toLowerCase() == 'true') {
document.getElementById('<%= this.FindControl("IsAccountingOk").ClientID %>').style.display = 'block';
}
});
The following error has occurred:
System.NullReferenceException: 'Objektreferencen er ikke indstillet til en forekomst af et objekt.' (The error message is in danish - but I got a null value from FindControl)
Any ideas?
Thanks in advance.
Regards Michael
Upvotes: 0
Views: 162
Reputation: 590
The div
you're targeting isn't a server-side control, so you just use id
directly:
document.getElementById('IsAccountingOk').style.display = 'block';
Upvotes: 2