Showing posts with label Resource. Show all posts
Showing posts with label Resource. Show all posts

Tuesday, June 4, 2019

How to embedded HTML code in the asp.net MVC resource file?

currently i am building an web application to support both English and French users.

we have a some words that already under registered trade mark My Trade Mark®. unfortuately the registered in not show in superscript.

we have to use the following HTML code to show registered trade mark in superscript.

<sup>&reg;</sup> 

since <> have been used for open and close tag

we have use the following code to embedded HTML code in the resource file.

 <data name="MyTradeMark" xml:space="preserve">
    <value>My Trade Mark<![CDATA[<sup>&reg;</sup>]]></value>
  </data>


in the MVC page we can use the code below to localize the text.

@Html.Raw(MVCPage_ascx.MyTradeMark)


in ASP.NET page. we just need to put this code in aspx page

<%=@MVCPage_ascx.MyTradeMark%>

Wednesday, January 16, 2019

how to use the resource file from other page in ASP.Net web application

we can localize the web application with the resource file from Visual studio. Visual studio automaticaly generate the resource file under this folder.

c:\projectfolder\App_LocalResources

in the page level we can use the key in the resource to reference the content.

<asp:Literal runat="server" Text="<%$ Resources:MyKey %>" />

if we want to use this content in other pages.

we can simply follow the steps below

1. add the reference to the resource namespace, you can find the namespace from the design.cs file.

<%@ Import Namespace="Resources.UserControls" %>



2. add the following line to your page which have a reference to the resource file and key.

<%=MyOtherPage_ascx.MyOtherKey %>