Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi i wanted to add html code in app settings which is like below
Thank you for purchasing you can add new one <a href="/KB/answers/NewItem.aspx">Get new Item</a>

i added this one as below in web.config
C#
<appSettings>
 <key="Success" value="Thank you for purchasing you can add new one &lt;a href='NewItem.aspx'&gt;Get new Item &lt;/a&gt;">
</appSettings>

and called in page load as
C#
lblSuccess.Text=Server.HtmlEncode(ConfigurationManager.AppSettings["Success"].ToString()).ToString()

My aspx look like below
C#
<div>
<asp:Label Id="lblSuccess" runat="Server" />
</div>

I want the text to be in html format not in text format it is comming as text either i used HtmlEncode or HtmlDecode.
Posted
Updated 18-Sep-13 22:56pm
v2

Instead of Label Use LiteralControl
it might help (not sure)

By the way, why to pick a message from web.cofig? Why not you manage a .cs class for such tasks ?

I will recommend to have a [Static] class named CommonMethods with Method named GetGreetingsMessage().

and you may pick it up via

C#
CommonMethods.GetGreetingsMessage()
 
Share this answer
 
Comments
Dholakiya Ankit 19-Sep-13 5:43am    
agree zubair
Hi,

Instead of shoowing the result in a Label show it in a TextBox like
ASP.NET
<div>
<asp:textbox id="txtSuccess" runat="Server" style="border:none;" readonly="true" xmlns:asp="#unknown" />
</div>
C#
txtSuccess.Text=Server.HtmlEncode(ConfigurationManager.AppSettings["Success"].ToString()).ToString()

you may add some css for the textbox to look like a label in this case;
Best of luck!
 
Share this answer
 
Do the Following Changes
---------------------------
XML
<appsettings>
 <key value="Thank you for purchasing you can add new one <a href='NewItem.aspx'>New Item</a>">
</key></appsettings>


Create a DIV to show the Message.

XML
<div runat="server" id="divSuccess">

</div>


Bind the Data From the Application Setting to Div Created.

C#
divSuccess.InnerHTML=ConfigurationManager.AppSettings["Success"].ToString();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900