Dynamically Disable an ASP.NET Control Client-Side

I wrote a control today to dynamically disable an ASP.NET control from the client - with NO POSTBACKS. It's actually pretty slick. All you do is drop the control on your form, and run ONE line in your if (!IsPostBack) section (oh, and for now, a simple JS function in your ascx/aspx - though you could just as easily inject that directly on the page too with a literal control).

I'll post it soon - faster if someone asks for it. :)

VS2005 + UserControl + Son of Smartpart - what doesn't work

So, I've been plowing through a project like a hot knife through butter... well sorta. You see I hadn't actually tested my theory - but here was my plan:

  • Build an ASP.NET 2.0 UserControl.
  • Build several ASP.NET 2.0 UserControls that the parent control dynamically kicks in & out
  • Deploy the assembly along with all of the ASCX's via SoS directly to WSS / SP2

Unfortunately, I ran into a few problems. First, VS2005 doesn't compile a web-project to an assembly when you debug it. Second, there is no "Release" build option. Third, VS2005 only creates assemblies (and I mean about 4-5 - with dynamically generated names) when you "Publish" the web project (Build | Publish Web). WTF? When did all of this happen? How did I miss it? Click on over to see Scott Guthrie's conversation about it on his blog (Scott's the ASP.NET PM @ Microsoft - and so is directly responsible). I haven't finished reading it yet.. but intend to (hey, it's a long post).

From my google-search earlier today - apparently this is all a side-effect of partial classes (and removing the solution & project files). I'm not sure why the decisions were made (most likely the above article explains it) but there appears to be a work around: the Web Deployment Project. This handy project type supposedly allows you to compile the project in ANY WAY YOU WANT... and will even create a handy build script that you can modify directly... and then RUN outside of VS (as both merely make calls to MSBUILD). Normally, I would say - how cool is that? Except I shouldn't have had to jump through hoops to compile to a single assembly. It was the default in VS2003 - and I never heard anyone say that it had changed.

Now, onto Son of SmartPart (http://www.smartpart.info/). When I first copied the default 4-5 assemblies, and ~20 controls after "publishing" my website (which by default is to a separate directory - \My Documents\Visual Studio 2005\Projects\ProjectX\precompiled-website\ProjectX\*) I immediately had a problem. From what I can tell - Son of SmartPart isn't all that smart. If I added the primary controls (that calls all the other controls)... it fails to load. Near as I've been able to determine - it's because SoS only loads the current controls referenced class (and hence only one of the numerous assemblies that the default Web Publish action creates). The fix? Load each and every control in a separate page so that they are available (ie. all assemblies have been loaded) to be instantiated on the page. Of course, if I VS had just compiled to a single assembly I wouldn't have wasted a few hours figuring all of this out. Sigh....

«March»
SunMonTueWedThuFriSat
2627281234
567891011
12131415161718
19202122232425
2627282930311
2345678