Interesting. You may have hit it on the head.
I just added a control in HTML view (as I always do). I then switched to Design view, and back to HTML view. Then I switched back to codeview, and voila - there it was.
Aaaaahhhhh. What a delight. It is SUCH a pain having to manually define them all in codeview.
Thanks, Justin
Boban,
I've noticed similar happenings. I have an untested theory. Could you sometimes be switching directly from the html view to the codebehind? And other times switching from the html view to the design view and THEN to the codebehind?
My theory is that if you switch from html view to design view the page gets processed and your objects are added to the codebehind.
--
S. Justin Gengo, MCP
Web Developer
Free code library at:
www.aboutfortunate.com
"Out of chaos comes order."
Nietzche
Actually, I type all my controls in HTML View because I don't like to work with the form designer. Yet in spite of that, VS often manages to "see" them and place them into the codebehind.
If you drag the control from the toolbox then it should always put the declaration in the code behind for you, assuming such an action is valid for that control. For instance, if you drag an HTML control instead of a webform and you don't mark it as a server control then the definition will not be in the code behind because it's not valid to be there.
Also, if you type in the control definition into the HTML view of your page (instead of dragging it from the toolbar onto the designer view of your form) then I wouldn't expect VS.NET to automatically put the definition into the code behind for you.
--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net
I create a new webform (I always use codebehind), and I insert some server-side controls into the form (the ASPX)
Later, I switch to codeview, and I notice that some (sometimes all) of the controls I created have been automatically defined for me in the
#Region " Web Form Designer Generated Code "
section
Later, when I add more controls this no longer happens.
First, I'm wondering which of my actions causes it to no longer do this;
and
is there a command I can issue to force it to "review" the ASPX page and re-synchronize the codebehind form?