2016-03-21 76 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中 –

相关问题