2016-03-21 77 views
0

我剛剛學習..任何人都可以請告訴我如何添加變量p = 1時請設置此PayPal參數字符串。這是它在mo上的工作狀況。我只需要添加p = 1,但是我仍然認爲語法錯誤。謝謝。添加另一個變量到PayPal URL查詢字符串

paypalParameterString.Append("return=http://examplesite.com/accounts.aspx?page=" & Request.QueryString("page") & "&") 

回答

0

如果你想更多的參數添加到您需要的參數之間增加一個符號(&)的URL。例如

http://examplesite.com/accounts.aspx?parameter1=foo&parameter2=bar 

所以,如果你想添加參數p與值1到你這上面提到的網址應該是這樣的

paypalParameterString.Append("return=http://examplesite.com/accounts.aspx?page=" & Request.QueryString("page") & "&p=1") 

如果你不想硬編碼值1

paypalParameterString.Append("return=http://examplesite.com/accounts.aspx?page=" & Request.QueryString("page") & "&p=" & value) 
+0

試過這個,但它從PayPal返回到只是http://www.examplesite.com/accounts.aspx?page=3 – Eggybread

0

您將需要encode您的網址,因爲它是參數的一部分。

將您的網址字符串變量

url = "http://examplesite.com/accounts.aspx?page=" & Request.QueryString("page") & "&p=1" 

然後通過確保編碼它

paypalParameterString.Append("return=" & Server.UrlEncode(url)) 

其添加爲參數,這將(例如)轉換&爲%26

注意:如果您需要,您可以將所有內容放在同一行上

paypalParameterString.Append(Server.UrlEncode("return=http://examplesite.com/accounts.aspx?page=" & Request.QueryString("page") & "&p=1")) 
+0

試過這個,但得到:字符是無效的錯誤:-( – Eggybread

+0

我要deffo需要使用「url」?我將它更改爲「myurl」,因爲我的「url」進一步下降並導致問題? – Eggybread

+0

@Eggybread這只是一個示例變量,你可以將它命名爲你想要的名稱,或者將整個url直接放在UrlEncode中 –

相關問題