Reputation: 360
I have a function that looks like this:
Private Sub displayData(title As String, cost As String, asin As String)
cdCheckList.Items.Add(title + "/" + cost + "/" + asin)
End Sub
I want to make the entire string (title + "/" + cost + "/" + asin) a hyperlink to another page called SearchDisplay.aspx
.
EDIT: I need to send the the values of title
, cost
, and asin
to the other page as well.
Not totally sure how this can be done. Can someone help me out?
Upvotes: 0
Views: 898
Reputation: 5596
I don't have Visual Studio to hand but could you try:
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
or using String.Format
would look nicer and easier to read:
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
Updated to answer OP's re-phrased question:
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
You should always encode URL query string parameters. You should look at using Microsoft's AntiXss library instead of the HttpUtility class. You can find out more information on the AntiXss library here.
Upvotes: 2