作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想在文本框中显示我的代码
<a href="http://www.erate.co.za/CompanyProfile.aspx?ID=112">
<img src="http://www.erate.co.za/CompanyAdd.bmp" alt="Go rate us on www.eRate.co.za"
border="0" style="width: 136px; height: 88px" /></a>
但我从这样的读者那里得到了 ID
reader.Item("ID").ToString
现在我想将 txtCode.text 设置为此,但它不起作用
txtCode.Text = "<a href="http://www.erate.co.za/CompanyProfile.aspx?ID=" +
reader.Item("ID").ToString + ">
<img src="http://www.erate.co.za/CompanyAdd.bmp" alt="Go rate us on www.eRate.co.za"
border="0" style="width: 136px; height: 88px" /></a>"
我该怎么做?
艾蒂安
最佳答案
在 VB 中,引号字符用另一个引号转义:
txtCode.Text = "<a href=""http://www.erate.co.za/CompanyProfile.aspx?ID=" & reader.Item("ID").ToString() & ">"
txtCode.Text &= "<img src=""http://www.erate.co.za/CompanyAdd.bmp"" alt=""Go rate us on www.eRate.co.za"" border=""0"" style=""width: 136px; height: 88px"" /></a>"
我怎么知道它是 VB 而不是 C#?
因为这条线适合你:
reader.Item("ID").ToString
在 C# 中,它必须是:
reader.Item["ID"].ToString()
关于c# - 如何在代码中设置指向文本框的超链接。 - 与其他 HTML 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/698212/
我是一名优秀的程序员,十分优秀!