Controls in code
I was working on a vb.net project and I could not find some controls in the code file (*. Vb). I was wondering because I was working in the page_load function, so the controls are not loaded until the page_control event occurs. however I was able to find them with the findcontrol function of the formview target.
source to share
If the controls are declared in aspx, then they are defined in the partial class equivalent for your class. This was introduced with .Net v2.0, so fiddling with the designer wouldn't mess up your code by file (which caused quite a few problems in some cases).
You can access the controls from the Page Load event. Sometimes IntelliSense plays tricks on you and doesn't offer control. Just enter it. It will work. You can close the aspx page and reopen it. Sometimes it fixes it. Or just restart Visual Studio if it annoys you.
However, there are several considerations if you are interested in accessing control data at specific times during the page's life cycle. Server controls have their own life cycle, which is similar to the page life cycle, but the order in which the event is fired for controls is as follows:
-
Init
and theUnload
event for the control is set to before , the event is raised for the container (bottom to top). -
Load
The event for the control occurs after the event is raised for the container (top to bottom).
More detailed description of page lifecycle events on MSDN .
source to share
It is difficult to say exactly what the problem is; it would help if you could post the code here.
I have two guesses / suggestions:
-
If you have the problem that brentkeller describes, what usually fixes this completely for me is deleting the aspx.designer.cs file, then right clicking on the .aspx file and selecting "Convert to Web Application". This recreates constructor file.
-
The control is inside the template as Jason Berkan suggested. For example, if in LoginView you use .FindControl ("controlId") in LoginView.
source to share
I sometimes have problems adding a control to a page and Intellisense does not recognize the control. The compiler also doesn't seem to recognize the control and doesn't allow the project to be compiled. This can be very frustrating and I really didn't understand why.
Sometimes it helps to close the aspx page and its code file, sometimes closing Visual Studio and reopening it. Sometimes none of them work and I'm just trying another way.
I don't know if this is what you are going through, but if it is, it might make you scratch your head and wonder what is going on.
source to share