As I prepare a speech for Tech Ed US in Orlando, and a few new articles on the localization front for 2.0, I've noticed a few things you might want to prepare for as you migrate your code samples from Beta 1. Now, there is a site that lists some of the relevant changes from Beta 1 to Beta 2, here:
http://msdn.microsoft.com/asp.net/whidbey/beta2update.aspx
And, I'm duplicating a few of these entries just to provide you with more specifics, and also because I captured this information before I knew about the site :) Here goes...
1. @Page, @Control attribute changes
The CompileWith and ClassName attribute names have changed to CodeFile and Inherits, respectively. So, in your content and master pages you'll change this:
<% @Page Language="C#" MasterPageFile="~/site.master" CompileWith="otherResources.aspx.cs" ClassName="otherResources_aspx" %>
to this:
<% @Page Language="C#" MasterPageFile="~/site.master" CodeFile="otherResources.aspx.cs" Inherits="otherResources_aspx" %>
It looks like there is not a migration tool to automate this process for you, likely because changes between beta releases aren't worthy of a tool. So, deal with it :)
2. <localize> controls require id attribute
The message you get here might be cryptic, if the <localize> element is embedded in existing user controls consumed by one or more pages. Check your <localize> elements and provide an id for them, and magically errors should disappear.
This:
<localize runat="server" meta:resourcekey="LiteralResource1">Culture:</localize>
changes to this:
<localize id="l1" runat="server" meta:resourcekey="LiteralResource1">Culture:</localize>
3. Explicit localization expression syntax change
In previous versions you could specify a default value that would be presented in the absence of supporting .resx files. This would be useful to Web developers, enabling them to design pages without requiring access to resources. It appears the syntax has changed so that any default values specified on explicit localization expressions for shared resources, is not supported. So this:
<%$ Resources:Glossary, BlogTitle, "dasBlonde" %>
<%$ Resources:Glossary, BlogTitle %>
The question is, how should Web developers work with this change? What will they see in the absence of a default, or, is there another way to specify a default? I'm still looking into these details...but I wanted to get these thoughts up here right now lest I forget to blog it! Will update this entry with my findings.
4. Pages and User control class declarations require base class
Previously the partial class generated for the code file of a content page, master page or user control did not specify base class inheritance. Now this is a requirement, and the error messages can be confusing because they refer to the inability to override the base class methods such as GetHashCode() or FrameworkInitialize(). To repair the problem, specify a base class for content pages as System.Web.UI.Page, for master pages as System.Web.UI.MasterPage, and for user controls as System.Web.UI.UserControl. For example this:
public partial class loginMenu_ascx
public partial class loginMenu_ascx : System.Web.UI.UserControl
or, in VB.NET,
Partial Class sidebar_ascx Inherits System.Web.UI.UserControl
5. Localization API changes
If you use the Page level APIs to access local page resources, or shared resources, the new methods for this are GetLocalResourceObject and GetGlobalResourceObject, respectively. For example this:
this.lnkLogin.Text = (string)this.GetPageResourceObject("Login");
this.lnkLogin.Text = (string)this.GetLocalResourceObject("Login");
6. Event handlers must be protected
Previously event handler declarations were private (no accessibility modifer provided on event handlers). Even handlers must be protected to be accessible therefore a modifier is required. For example this declaration:
void dlCountries_DataBinding(object sender, EventArgs e)
now must be:
protected void dlCountries_DataBinding(object sender, EventArgs e)
I'm confused by this requirement, since partial classes are supposed to be "the same class" why should the event handler have to be protected? I need to look into this as well, and post my findings.
That's all for now, hope this helps you migrate more quickly! In a few weeks look for a new article on TheServerSide.NET from yours truly related to globalization. And, don't forget my globalization resource site: http://www.dotnetdashboard.net/sessions/globalization.aspx
Ciao for now!
Remember Me
Designed by NUKEATION STUDIOS