This tutorial will show how to use the Localize control to display static text in Visual Basic.NET. The Localize Control lets you localize any element on an .aspx page. It provides a design time attribute not offered by its base class, the Literal control. Specifically, the Localize control provides design time editing of static content so you can see a default value while working in page design mode.

Setting Up

If you have not done so already, create an empty web site. To do so, open Visual Studio and click File > New > Web Site. Using ‘Visual Basic’ as the template, select ASP.NET Empty Web Site, name the web site LocalizeControl-VB and click OK. Now right click the web site name in solution explorer and click Add New Item. Using ‘Visual Basic’ as the template, select Web Form, leave the form name as Default.aspx and click add.

Step One

In the source view of Default.aspx, place a Localize and Button control in the open div tags. Add “Localize Text” to the Text of the Localize control and change the Text of the Button control to “Change Localize Text”.

Step Two

Switch to design view and double click the “Change Localize Text” Button control to generate a click event in the code behind. Every time the button is clicked, the code inside the Button1_Click event method will execute. This event will use the Localize control to display static text by changing the Text value.

Output

Save and run the web site. You should see a simple “Localize Text” and Button control on the page. When you click the button, the text will change to “Localize Text Changed!”, thus changing and displaying static text.

localize control 1

localize control 2

Thanks for reading and make sure to download the source files to get a better understanding of how the code works.

Download Source Files