2013-03-13 65 views
0

在下面的href中,當ItemID參數是一個字符串,它包含「/」正斜槓時,它會導致當前頁面ViewQuickQuote.aspx重新加載,而不是轉到SelectedItem.aspx頁面。我知道其他一切都正常工作,因爲這隻有在ID中帶有正斜槓的ItemID時纔會發生。aspx參數中的正斜槓導致錯誤

<li><a href="SelectedItem.aspx?itemID=<%=ItemID %>">View Inventory and Pricing</a></li> 

<a href="SelectedItem.aspx?itemID=HON.TH6320WF1005/U" class="ui-link-inherit">View Inventory and Pricing</a> 
+0

請問HTML是什麼樣子時,'ItemID'有一個「/」的呢? (最好在瀏覽器中加載並點擊'查看源代碼') – 2013-03-13 20:31:31

+0

View Inventory and Pricing 2013-03-13 20:38:21

回答

2

您需要進行urlencode的項目ID:

<a href="SelectedItem.aspx?itemID=<%=HttpUtility.UrlEncode(ItemID) %>">View Inventory and Pricing</a> 

這個位於System.Web命名空間。

而對於未編碼使用的方法HttpUtility.UrlDecode()

+0

好吧,我會盡快嘗試,看看我得到了什麼。 – 2013-03-13 20:41:22

+0

沒有運氣,但可能是因爲我做錯了什麼。我在aspx文件中添加了HttpServerUtility.UrlEncode(ItemID),但它只是出錯。 – 2013-03-13 20:50:43

+0

嘗試<%= HttpServerUtility.UrlEncode(ItemID.ToString())%> – 2013-03-13 21:31:52