Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
It may be a very easy question to answer.But i am puzzled how to implement.

I have stored a string in database table.

String - "If you have any queries, please visit our support page for more information".

I have to make the words - 'support page' clickable such that it takes me to a link.

I am passing this to a view using viewbag and storing it in a string variable.

Right now am displaying it in a htmlhelper label.

Please ignore if you find its too dumb.Thanks in advance for your response.

What I have tried:

HTML
@if (ViewBag.validateResult == "true")
{
    string message = ViewBag.messageInfo; // string form DB(Table)
    @Html.LabelForModel(message, new { @class = " alert alert-success fade in" })
}
Posted
Updated 20-Jul-16 19:41pm

1 solution

You can add the link's HTML to your string and, display it using the Html.Raw method. Something like:


C#
@{
    string msg1 = "My Text <a href=\"http://www.google.com\">My link</a>.";
    @Html.Raw(msg1)
}
 
Share this answer
 
Comments
Member 1097736 21-Jul-16 3:34am    
Thanks for ur response.
Member 1097736 21-Jul-16 3:37am    
How can i add the bootstrap classes to it??
F-ES Sitecore 21-Jul-16 4:21am    
string msg1 = "My Text <a href=\"http://www.google.com\" class=\"insert class names here\">My link</a>.";

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