Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mysterious VS.NET gremlins

Status
Not open for further replies.

kylemcna

Programmer
Joined
Dec 23, 2004
Messages
15
Location
US
Hi,

I had an issue where all of a sudden, text that was being written successfully by the code-behind to the aspx file would stop showing up at all, with no error.

I never, /ever/, use the designer.

I started comparing the code generated by "#region Web Form Designer" in a test.aspx file that I had working, with the code of the files not working and I saw that somehow "this.Load += new System.EventHandler(this.Page_Load);" was removed from the "private void InitializeComponent()" event.

Putting that back in fixes the issue.

I certainly do not personally remove it and no one is working on this workstation except me and it continues to happen at seemingly random intervals after rebuilding (Alt B, R).

It says right in that block: "Required method for Designer support - do not modify the contents of this method with the code editor." I /never/ use design mode and anyway I never modify that block, so I don't care about design mode, but by the same token, I can't have VS taking out code from that block willy-nilly with no way of knowing why or when.

Anyone know why that could be happening?

Thank you,

Kyle
 
Yes, this is a bug in VS, or rather a side-effect of the fragility of the code-behind model. When you make changes to the .aspx file (adding or removing server controls), the code-behind file needs to be updated - the control is added to the class's members and the handler-additions need to be added to the InitializeComponent method. VS usually does a good job at keeping the two files in sync, but sometimes if you switch between the views too quickly it doesn't happen. Get into the habit of saving whenever you make a change to the aspx page file and watch and make sure that the asterisk goes away in the code-behind file too (indicating that the save is completed). Sometimes it takes an extra second. I haven't had the problem since I started doing this.



[pipe]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top