0

I added a div to the user control. But when I am trying to access the div in page_load method in code behind, I am getting NullReferenceException.

<div id="divCOVIDQuestion" runat="server"></div>

and in page_load method

divCOVIDQuestion.Visible = Client == "FI";
DeepakTheGeek
  • 123
  • 3
  • 15
  • 1
    Does this answer your question? [What is a NullReferenceException, and how do I fix it?](https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – Dmitry Apr 25 '20 at 14:53
  • No. I understand the NullReferenceException, but I don't understand why the div is getting null. – DeepakTheGeek Apr 25 '20 at 14:56
  • I am not familiar with C# browser bindings, but perhaps you need to use something like JS would? `Document.GetElementById( "divCOVIDQuestion" ).Visible` – Peri Apr 30 '20 at 01:58

0 Answers0