How to Use the Localize Control in Visual Basic.NET
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.
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”.
<asp:Localize ID="Localize1" runat="server" Text="Localize Text"></asp:Localize>
<asp:Button ID="Button1" runat="server" Text="Change Localize Text" />
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.
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Localize1.Text = "Localize Text Changed!"
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.
Thanks for reading and make sure to download the source files to get a better understanding of how the code works.