WSV 360 - ASP.NET Tips and Tricks

Scott Guthrie shows off ASP.NET Whidbey Tricks

  • Cross-page posting - In Whidbey, you will be able to post Web Forms to pages other than the page on which the input is entered. Postback target is chosen based on the PostTargetUrl (interim name) attribute of a control that causes a postback. On the target page, you will be able to access all of the controls, viewstate, etc. of the page that caused the web form post. Whidbey hangs a PreviousPage object off the current page to provide access to the controls, etc. of the posting page. Because it's based on postback controls, you can have a page that both posts back to itself, and also posts to another page, depending on which control is clicked.
  • Validation Groups - The new feature validation groups allows you to logically group a set of validation controls, and only validate the fields that are in the group to which belongs the postback control that the user clicks. Uses the ValidationGroup attribute to implement in declarative tags. The key here is that you can have two sets of form fields that aren't typically used together, and implement validation on both sets of fields, without the non-used fields causing the page to fail validation.
  • Wizard UI - New <asp:wizard> control that enables step-by-step wizard UI, for example for gathering multiple pages of input for a single purpose before saving or processing the input. The Wizard control defaults to a Next/Previous UI, but is also templated, so you can customize the UI to your needs. In combination with the Personalization and Membership providers, you can use the Wizard control to very easily create a UI for registering new users for a web site, etc.
  • Image Generation - New feature for generating images in Whidbey. Includes an HttpHandler (.asix) providing a custom handler and base class for image generation, including support for downlevel rendering. Also includes a new DynamicImage control that uses callbacks with the image generation handler to pull down dynamically generated files.
  • .asix files use the @ Image directive and inherit from System.Web.UI.Image.ImageGenerator. Does not require registering your own custom HttpHandler for image generation. Just write the code.
  • The <asp:dynamicimage> control supports databinding. You can bind its imagebytes property to a data column that contains binary image data.
  • URL Rewriting/Mapping - new built-in module for rewriting paths. Allows the use of "vanity" urls, instead of ugly querystrings, and also makes it easy to move content without breaking existing links. Perf tip: - This feature makes it possible to use kernel-level caching in IIS 6 for pages that would otherwise need querystring or form fields to perform the mapping.
  • Site Counters - Provides a service and API for efficient logging and tracking of site visitors. Can also be accessed through attributes (CountClicks, CounterGroup, etc.) on declarative tags, as well as through web.config.
  • Client Script Goodies - Server buttons now have an OnClientClick attribute for client-side handling. Focus mechanisms are now built into the page and controls. A page can also have a default button and a default focused control. All these features emit the appropriate client-side script. There will also be automatic scroll position maintenance in the beta release of Whidbey (not in the PDC bits).
  • Whidbey adds support for custom build providers. ASP.NET allows you to register to receive notification of files needing dynamic compilation. Whidbey uses this feature to support dynamic compilation of .wsdl, .xsd, and .resx files in the /code directory of an ASP.NET application.
  • No-compile Pages - You can configure at the page and folder level whether pages can be compiled after they've been deployed. If compilation is disabled, any change to the page after the page or directory has been locked down will throw an exception.
  • File System Provider - allows Web content (both compiled and non-compiled) to be stored in non-filesystem locations such as databases or CMS, and even use Sql Cache invalidation to output cache stored content, while always getting the updated content if it changes. Pretends to be the filesystem and provides an interface into whatever storage location the content is actually stored in. Cannot store assemblies, but can store just about any other content.
  • Securing non-ASP.NET Content - Requires IIS 6.0, using its ExecuteUrl feature. This allows forms authentication to work with static files like .jpg, .gif, etc.
  • RSS Reader - Combine an XmlDataSource control and a DataList control to read and render any RSS feed.

1 Comment

  • Cross-page posting looks promissing as it keeps a hell to maintain state across page back and forward. That's specially good to me that work in a financial company that have many &quot;wizard&quot; like processes.

    Kudos to Whidbey!



    --Alexandre

Comments have been disabled for this content.