Sometime we require a condition where we need to add html tags in <appSettings> value.
If we directly add html tags in value then it gives the syntax error. To resolve this we need to add html tags in encoded form.
Here, below is the example of this:
1. Use encoded html - for "<" use < and for ">" use >
eg:
In C#.NET
web.config:
<add key="example" value="Hi, <br> </br> This is a C# example. " />
.cs file
string s= Convert.ToString(ConfigurationManager.AppSettings("example"));
then s will return as
Hi,
This is a C# example.
In VB.NET
web.config:
<add key="example" value="Hi, <br> </br> This is a VB example. " />
.vb file
Dim s As String
s=Convert.ToString(ConfigurationManager.AppSettings("example"))
then s will return as
Hi,
This is a VB example.
Hope this code will help you. Thanks
0 Comment(s)