Tuesday 16 June 2009

AJAX TOOLKIT ERROR: ".... requires a ScriptManager on the page"


Add folowing section, but please keep in mind that BOTH 1.0 and 3.5 assemblies System.Web.Extensions should be in GAC, in other case it will not work.

Add this to the Web.config
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

Monday 15 June 2009

Events and Delegates for UserControls


Heres a nice article on why UserControls require events and delegates and how to implement them in C#/ASP.NET.

http://codebetter.com/blogs/brendan.tompkins/archive/2004/10/06/Easily-Raise-Events-From-ASP.NET-ASCX-User-Controls.aspx

Friday 5 June 2009

When should I use WPF vs. Silverlight?


In my role, I work with a number of large corporations, and this is a question that they ask me regularly: What is the difference between the Windows Presentation Foundation (WPF) and Silverlight, and in what scenarios does it make sense to use each?

Microsoft feels that user experience is important, and invested in multiple technologies to promote better user experience. Both WPF and Silverlight use XAML (Extensible Application Markup Language) under the covers.

Let's look at some of the different characteristics of each technology:



WPF:

* Ships as part of the .NET Framework (version 3.0 and onward)
* Runs as Windows application or as web "browser application" (called XBAP, for "XAML Browser Application"). Note that XBAPs run only in Internet Explorer with .NET 3.0 and in both Internet Explorer and Firefox with .NET 3.5.
* Runs on Windows machines only (Windows XP, Windows Server 2003, Windows Vista, and Windows Server 2008)
* Richest functionality, including 3D graphics

Silverlight:

* Ships independently
* Runs in web browsers only (Internet Explorer, Firefox, Safari)
* Runs on Windows or Mac operating systems (also on Linux via Moonlight, which is an open source implementation of Silverlight based on Mono)
* Functionality is a subset of WPF's feature set



When should you use each? The maddening answer is (of course): it depends!

WPF is a more mature technology and was designed with a richer feature set. It also has the advantage of being able to run in a browser or as an installed Windows-Form-type app.

Silverlight has a broader reach. You can access Silverlight from many operating systems and web browsers.

The most important reason to choose one over the other should be based on the intended audience for the application. For example, if a corporation is designing an application for internal use only and every employee has Windows XP as the company standard OS, then go with WPF to leverage the richer feature set. If a corporation is designing an external-facing website, then Silverlight is the better choice because potential customers can access the website from a variety of different operating systems and browsers.

Wednesday 3 June 2009

.NET WebApps Impersonation


There are many examples on why impersonation is useful... It gives you the ability to impersonate a user to access some sort of resource/utility either on the current system or a networked system.

An example might be that your attempting to retrieve a list of directories from a server in which you do not have access. Getting around this is quite simple.

Open up your web.config and enter the following...

<identity impersonate="true" username="" password="" />