[英]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. 这里“pujanme”正在从正确出现的数据库中提取,其次我想包含“购物车”文本,这是超链接到其他页面,但我正在发送错误。如果有人指导我,我会很高兴。 Thankyou
谢谢
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> ";
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> ";
你只需要在url的内部"
和\\
之前"
。
lblmsg.Text = "Success: You have added " + pujaname + " <a href=\"ShoppingCart.aspx\"> to your shopping cart </a> ";
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: 如果它的vb那么你可以像下面这样简单地写它:只要它们在双引号之间就可以内联:
lblmsg.Text = "Success: You have added " + pujaname + " your shopping cart lblmsg.Text =“成功:你已经添加了”+ pujaname +“ 你的购物车
" “
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.