all groups > visual studio .net ide > february 2006 >
You're in the

visual studio .net ide

group:

Visual Studio 2003 'Loses' code


Visual Studio 2003 'Loses' code Phillip N Rounds
2/24/2006 4:27:49 PM
visual studio .net ide:
I have had a recurring problem with my VS2003

1: It keeps loosing certain types of code, specifically

MyButton.Attributes.Add("onclick", "myJavaScriptFunction();");

I add this in the
private void InitializeComponent() method, after all the appropriate C#
event handlers are added.

Am I adding it in the wrong place?

I also occasionally lose JavaScript in the HTML. I've had instances where
all the JavaScript has been wiped out after re-compiling and debugging a
solution.
I've smartened up ( a bit ), and put all my JavaScript in separate files,
but I would like to know if this is a recurrent problem out there and if
there are any fixes.

Thanks

Phil

Re: Visual Studio 2003 'Loses' code Michael A. Covington
2/26/2006 9:36:12 AM
Are you putting it in something that is rewritten by the designer?


Re: Visual Studio 2003 'Loses' code Phill W.
2/28/2006 1:36:15 PM

[quoted text, click to view]

IMO, Yes.
The Designer has some *really* bad habits, including trying to
"make sense" of any code like this that it finds in "its" region and,
presumably, just trashing anything it /can't/ make sense of.

The only line of code I put into Designer Generated code is a call to
A.N.Other method that does all this sort of thing, but safely /well away/
from the machinations of the Designer... :-)

[quoted text, click to view]
Apparently, this has been *massively* improved in VS'2005 (i.e.
it actually works correctly!) but, sadly, it's just something that
VS'2003 does.

Personally, I /like/ the way I put my HTML together, so I try to
/avoid/ the Designer as far as physically possible (even editing the
HTML source in something less "meddlesome" and just letting
'Studio reload it every time I do.

Regards,
Phill W.

Re: Visual Studio 2003 'Loses' code David
4/23/2006 12:00:00 AM
[quoted text, click to view]
I've seen this happen to my own codes as well. If you remember the name
of the code, simply go into the property of the object, click on the
little button with the lightning on it and change it back(usually code
like my_button_click_0 would change to something like
Re: Visual Studio 2003 'Loses' code Velvet
5/11/2006 1:17:43 PM
I found that annoying behavior with anything added to the "Code Generated"
parts of the code. I usually create a SetDefaults() method and add it to
the first line of my Page_Load() method. The only time I found that it
doesn't work is for dynamically creating the DataGrid columns. In that
case, the method has to be run before the Init happens. In that case I add
the method above the following comment:

When it is added there, I don't see it disappear.
//

// CODEGEN: This call is required by the ASP.NET Web Form Designer.

//



[quoted text, click to view]

AddThis Social Bookmark Button