views:

87

answers:

3

Hi,

I'm just getting into ASP.NET Been avoiding it for years as I'm a desktop application advocate.

Anyway, I was wondering if there's a way to stop the generated html being so cluttered with javascript. Is there a way to make the generated script go into a referenced js file rather that inline with the page.

+4  A: 

Look into ASP.NET MVC - it is an alternative to WebForms and tends to have less clutter.

Andrew Hare
+1  A: 

Are you sure you're using code-behind?

When you add a new page, make sure you check "Place code in a separate file", otherwise all your server-side code will be on the page (even tough it won't show up for the end-user)

If you're using code-behind but it still has a lot of javascript code in the page (maybe you're using ajax?) I'd suggest you don't use the .NET ajax controls, just do all the ajax by hand, using jQuery or Prototype. It's fast and it'll be as lightweight as it can be.

Luciano
A: 

Check out ClientScriptManager.RegisterClientScriptInclude.

Phaedrus