Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to add html tags in appSettings of web.config file

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 4.35k
    Comment on it

    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 &lt; and for ">" use &gt;
    eg:

    In C#.NET

    web.config:

    <add key="example" value="Hi, &lt;br&gt; &lt;/br&gt; 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, &lt;br&gt; &lt;/br&gt; 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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: