Creating an asp:Localize snippet for Visual Studio

In one of our projects we currently working on localization, in which we migrate the static texts from ASPX pages to resx files. We use asp:Localize controls to display the texts from the resource files. The Localize is essentially a Literal control, it derives from Literal without adding any new functionality to it, beside the fact that its name makes its usage more obvious in the markup.

Creating Localize controls are quite tedious, therefore after a while I created a code snippet, so now I can quickly insert the tag with TAB-TAB, and all I have to type is the name of the resource key. Here is the code, just paste it into .snippet file and then copy the file to the C:\Program Files (x86)\Microsoft Visual Studio 10.0\Web\Snippets\HTML\1033\ASP.NET folder, Visual Studio will recognize it:

<CodeSnippet Format="1.1.0" 
    <Author>Balássy György</Author>
      <Shortcut Value="localize">asp:localize</Shortcut>
      Markup snippet for a control that contains localized text
    <Code Language="html">
      <![CDATA[<asp:localize runat="server" meta:resourcekey="$key$" />$end$]]>

Creating a snippet like this takes only 5 minutes, but makes your life much easier.


Technorati-címkék: ,

2 thoughts on “Creating an asp:Localize snippet for Visual Studio

  1. Terry J

    Thanks for the article and for the code. It’s forward thinking programmers and coders like you that we rely on to make our sites better. Very insightful.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s