ASP.NET horrors

From: Ally 7 Jan 2009 15:28
To: ALL1 of 7
Right, so. I've started at mah new job, and finally had the chance to look through the code the runs the site. It's ASP.NET, but written like Classic ASP (no codebehinds, lots of <% %>ing)... we're all working through rewriting it to be, you know, good- but that takes time. I have a more urgent issue. Some preamble!

Going along with the "like Classic ASP" motif, there are a lot of include files used. One of which uses Response.Write to dump a load of javascript into the page, which sit above the DOCTYPE- i.e. it's rendering in Quirks Mode and making my life not worth living.

My actual question! Can I have two Page_Load voids? I assume not- that one would over-write the other or it'd just error out, but this include is used all over the place- I need to find a way of tying it into the page loading chain without overwriting anything.
From: THERE IS NO GOD BUT (RENDLE) 7 Jan 2009 15:58
To: Ally 2 of 7
Can you rewrite the included file to dump the Javascript into the ClientScriptManager instead of writing it to Response.Write?
From: Ally 7 Jan 2009 16:45
To: THERE IS NO GOD BUT (RENDLE) 3 of 7

Well, yes and no. The include is being processed before any Page object exists, so any attempt at registering anything fails miserably. However, I've ended up putting a Literal into the include, and then running the code on the Literal's OnLoad, so the Page object actually exists and all that.

 

Utterly hackish, but it'll work until we get the time to redo the whole bloody thing.

From: Ally 7 Jan 2009 16:46
To: THERE IS NO GOD BUT (RENDLE) 4 of 7

Oh, but I have another question.

 

Right now I'm having to build my solution every time I want to test anything in the codebehind- I've never had to do that before, just changing the .cs file is enough. Having to recompile every time is a pain- is there some setting change I need to do, or am I screwed?

From: THERE IS NO GOD BUT (RENDLE) 7 Jan 2009 17:40
To: Ally 5 of 7
If you change "codebehind" to "codefile" it'll run from the cs instead of the DLL. It caused me a lot of shit, though; I ended up going back to codebehind.
From: THERE IS NO GOD BUT (RENDLE) 7 Jan 2009 17:41
To: Ally 6 of 7
Or, write the code in stand-alone testable units, like you ought to be anyway.
From: Ally 7 Jan 2009 21:24
To: THERE IS NO GOD BUT (RENDLE) 7 of 7
There are many things that ought to be done, sadly. Cheers, though!