最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - Asp.net adding parameter to url string - Stack Overflow

programmeradmin1浏览0评论

I'm displaying a list of filtered items in a page, and now I have to limit the displaying by paginating the results.

So if I have url parameters like these:

example/?category=pizza&period=today

where both category and period can also not being showed:

example/?period=today

example/

how can I add a "Next page" in the end that keeps any previous parameter and adds

&pagenum=5 

or if there are no parameters:

?pagenum=5

Tnx in advance!

I'm displaying a list of filtered items in a page, and now I have to limit the displaying by paginating the results.

So if I have url parameters like these:

example.com/?category=pizza&period=today

where both category and period can also not being showed:

example.com/?period=today

example.com/

how can I add a "Next page" in the end that keeps any previous parameter and adds

&pagenum=5 

or if there are no parameters:

?pagenum=5

Tnx in advance!

Share Improve this question edited Mar 20, 2014 at 5:53 jdphenix 15.4k4 gold badges44 silver badges74 bronze badges asked Sep 16, 2011 at 13:36 AttilaAttila 7121 gold badge13 silver badges34 bronze badges 1
  • 2 Are you wanting to do this client or server side? – Tim B James Commented Sep 16, 2011 at 13:45
Add a comment  | 

2 Answers 2

Reset to default 15

For serverside

string url = Request.Url.GetLeftPart(UriPartial.Path);
url += (Request.QueryString.ToString() == "" ) ? "?pagenum=1" : "?" + Request.QueryString.ToString() + "&pagenum=1";

You can pass in the page number depending on how you are handling this.

For ASP.Net use the following:

string temp = Request.QueryString["yourParamName"];

Fissh

发布评论

评论列表(0)

  1. 暂无评论