user3247426
user3247426

Reputation: 127

adding hyperlink between the label in asp.net

I want to display message within the label by code behind.My code do look like as below.

lblmsg.Text = "Success: You have added " + pujaname + "  <a href="ShoppingCart.aspx"> to your shopping cart </a> ";

Here "pujanme" is extracting from database which is coming correctly and secondly I want to inlcude "shopping cart" text which is hyperlink to other page but I am geting error.I will be pleased if somebody guides me. Thankyou

Upvotes: 3

Views: 7668

Answers (4)

Jesse Mwangi
Jesse Mwangi

Reputation: 155

If its vb then you can just write it simple like below: Html can be put inline as long as they are in between double quotes:

lblmsg.Text = "Success: You have added " + pujaname + " your shopping cart
"

Upvotes: 0

Wasif Hossain
Wasif Hossain

Reputation: 3950

You just have to precede the inner " of url with \.

 lblmsg.Text = "Success: You have added " + pujaname + "  <a href=\"ShoppingCart.aspx\"> to your shopping cart </a> ";

Upvotes: 1

Illaya
Illaya

Reputation: 666

You can try this. It is working for me.

lblmsg.Text = "Success: You have added " + pujaname +" <a href=\"ShoppingCart.aspx\"> to your shopping cart </a> ";

Upvotes: 5

M4N
M4N

Reputation: 96571

You have to escape the double quotes in your link (by adding a backslash in front of them):

lblmsg.Text = "Success: You have added " + pujaname +
            + "  <a href=\"ShoppingCart.aspx\"> to your shopping cart </a> ";

Upvotes: 1

Related Questions