ASP.NET 4.0, Part 6: New Page Directive Attributes

by DanM 22. February 2010 23:30

Welcome to part 6 of my tour through ASP.NET 4.0. Over the next few posts we’ll be looking at some of the changes made to the standard webforms page. For today, we’ll start at the top and look at the new Page directive attributes in this release in anticipation of some future posts.

The default @Page directive added to the top of every new webform generated by Visual Studio 2010 has not changed from that in VS2008. It still has the standard four attributes.

<%@ Page Language="C#" AutoEventWireup="true" 
         CodeFile="Default.aspx.cs" Inherits="_Default" %>

Indeed, all 42 (yes, 42!) attributes from .NET 2.0 have been kept for backwards compatibility as you might expect.  You might be surprised how many there are: some present per-page overrides to the <pages> element in your web.config files, others how the page should operate, and others how the code-behind the page fits into the code hierarchy of your site. A brief explanation of them all can be found here.

ASP.NET 4.0 brings with it six new attributes for the @Page directive, as follows:

  • ClientIDMode sets the method ASP.NET will use to render the IDs for every element on the page. Possible values are AutoID (the default), Predictable, Static and Inherit. We’ll investigate how they each work in a forthcoming post.
  • ClientTarget overrides the automatic browser capabilities detection we saw in part 5 and let’s you specify explicitly what browser capabilities the ASP.NET engine should target when rendering the page.
  • MetaDescription sets the Page’s new MetaDescription property which is then rendered in the HTML <meta> description tag.
  • MetaKeywords sets the Page’s new MetaKeywords property which is then rendered in the HTML <meta> keywords tag.
  • TargetSchema identifies the schema that validates content on the page when being designed. It’s purpose is similar to a property of the same name in .NET 1.1. Note that TargetSchema is for descriptive purposes only; no actual validation is performed, and the attribute is ignored by the parser.
  • ViewStateMode specifies whether the page’s ViewState is controlled by an opt-in or an opt-out (the default) model. As with ClientIDMode, we’ll investigate this further in part 7.

In tomorrow’s post, we’ll look in more depth at the new options for controlling ViewState on a page. Happy coding!

Comments

2/23/2010 8:30:51 AM #

pingback

Pingback from blog.cwa.me.uk

The Morning Brew - Chris Alcock  » The Morning Brew #545

blog.cwa.me.uk

3/5/2010 4:32:20 PM #

trackback

ASP.NET 4.0 Cometh

ASP.NET 4.0 Cometh

Dan Maharry

3/10/2010 1:32:33 AM #

trackback

ASP.NET 4.0 Part 11, Configuring Routing Is Easier

Welcome to part 11 of my tour through ASP.NET 4.0 . In this episode, we're going to take a look at

ASP.NET Web Forms bloggers

5/21/2010 12:39:24 AM #

pingback

Pingback from 315.defutbolazo.com

Columbia Hid Both Firmware, Columbia Bahama Fly Fishing

315.defutbolazo.com

Comments are closed

Powered by BlogEngine.NET 1.6.0.0
Theme by Mads Kristensen, adapted by Dan Maharry

About Dan

Dan Maharry Dan Maharry
Web developer at Co-operative Web and tech writer. More...
Creative Commons License View Dan's bookmarks on Delicious LinkedIn Facebook Facebook Last.fm
Last.fm Twitter Subscribe to Dans RSS Feed Download Dans OPML File Add blog to technorati favorites

RecentComments

Comment RSS