我手头没有 Visual Studio,但你可以试试:
Private Sub displayData(title As String, cost As String, asin As String)
cdCheckList.Items.Add("<a href=\"SearchDisplay.aspx\">" + title + "/" + cost + "/" + asin + "</a>")
End Sub
或使用String.Format
看起来更好,更容易阅读:
Private Sub displayData(title As String, cost As String, asin As String)
cdCheckList.Items.Add(String.Format("<a href=\"SearchDisplay.aspx\">{0}/{1}/{2}</a>", title, cost, asin))
End Sub
更新以回答 OP 重新措辞的问题:
Private Sub displayData(title As String, cost As String, asin As String)
cdCheckList.Items.Add(String.Format("<a href=\"SearchDisplay.aspx?title={1}&cost={2}&asin={2}\">{0}/{1}/{2}</a>", HttpUtility.UrlEncode(title), HttpUtility.UrlEncode(cost), HttpUtility.UrlEncode(asin)))
End Sub
您应该始终对 URL 查询字符串参数进行编码。您应该考虑使用 Microsoft 的 AntiXss 库而不是 HttpUtility 类。您可以在此处找到有关 AntiXss 库的更多信息。