views:

42

answers:

3

Is it possible to mix the concept of Unobtrusive JavaScript with the event model of ASP.Net?

+2  A: 

ASP.NET makes it very difficult, as every server side control requires a postback via the __doPostback javascript function.

You can make sure you are not using any server side controls, but this means you loose most of the benefits of ASP.NET.

Another option is to override the OnRender event and output different controls/javascript, but this is also quite a lot of work and defeats the purpose of ASP.NET.

You have much greater control when using ASP.NET-MVC.

Oded
A: 

yes, to a point. discounting standard controls and how they are built, there's not much stopping your from offloading all your own javascript to a separate file. the big hangup that comes to mind is referencing myControl.ClientID to render an element id in the middle of a script block. with a little planning, you can still minimize the amount of script you have to render in the page to work around this.

lincolnk
A: 
Justin