Why is my web control invalid?

I have a website in asp.net that uses the main page. On this main page, I have a multiview control with one view that has all the content for content pages and one view that has local content on the main page, where I show error messages from all content pages.

In this error view, I have an asp.net Label control that displays error messages. Normally, the label works fine, but in some cases the label is null, which throws a NullReferenceException. Now I handled this case by checking if the label is null before using it, but still my question is:

Why is this label zero? What are the circumstances that can generate this?

EDIT: On the main page, I have a SetErrorText method that takes a string and sets a label. I call this method from the page_Load method on the content pages, and this usually works fine. In all cases except two (which I have discovered so far), the label is initialized, and nothing separates these two cases from all the working ones.

In addition, all other controls on the main page are initialized, for example, a View control containing a shortcut.

When the Page_Load page of the content page moves, the main page should be full.

+3
source share
4 answers

, . - Content- , Visual Studio , ContentPlaceHolder-control.

Content-control, , ContentPlaceHolder , null.

+4

? , ,

+1

. .NET , . , , ( , "" ). . , :

Visual Studio .designer aspx/ascx?

0

Source: https://habr.com/ru/post/1696691/


All Articles