gpt4 book ai didi

c# - 如何在代码中设置指向文本框的超链接。 - 与其他 HTML 标签

转载 作者:行者123 更新时间:2023-11-28 00:31:11 25 4
gpt4 key购买 nike

我想在文本框中显示我的代码

<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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com