If you really, really like the new and shiny extensions, you can use them in your WebForms application, too!
Here are the needed steps:
Add references to the following assemblies:
The first three are usually in the GAC.
Copy the Content and Scripts folders from the extensions’ distribution into your project.
The pages which will contain the MVC components will need to inherit System.Web.Mvc.ViewPage. Also, you should mock an MVC environment, like this:
protected class ControllerMock : Controller { public ControllerMock(NameValueCollection queryString) { foreach (string param in queryString.Keys) ValueProvider.Add( new KeyValuePair<string, ValueProviderResult> (param, new ValueProviderResult( queryString.Get(param), null, CultureInfo.CurrentCulture))); } } protected void Page_Init(object sender, EventArgs e) { var contextWrapper = new HttpContextWrapper(HttpContext.Current); var controllerMock = new ControllerMock(Request.QueryString); var routeData = new RouteData(); this.ViewContext = new ViewContext() { Controller = controllerMock, HttpContext = contextWrapper, RequestContext = new RequestContext(contextWrapper, routeData) }; this.InitHelpers(); }
static void RegisterRoutes(System.Web.Routing.RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", "{controller}/{action}/{id}", new { controller = "Home", action = "FirstLook", id = "" }); } void Application_Start(object sender, EventArgs e) { RegisterRoutes(System.Web.Routing.RouteTable.Routes); }
Use the extensions!
And here is a sample project to get it up-and-running in no time:
Guess which Telerik project needs this ;-)