Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0DNN Pager Control: Adding additional Querystring parameters?DNN Pager Control: Adding additional Querystring parameters?
Previous
 
Next
New Post
1/14/2009 3:17 PM
 

Based on Antonio Chagoury's article:

http://www.cto20.com/Home/tabid/647/EntryId/46/DNN-Best-Kept-Secrets-Part-1-DNN-Paging-Control.aspx

I'm trying to use the DNN Pager Control in a project but I need to add additional Querystring parameter to it, like a "keyword" querystring with a value of "foo".

Can anyone provide me with some guidance as to how I would do this?  Many thanks!

 
New Post
1/14/2009 4:51 PM
 

You need to set them in the QuerystringParams property of the Pager Control.  Here's how we do it:

   1:          /// <summary>
   2:          /// Generates a list of QueryString parameters for the given list of <paramref name="queryStringKeys"/>.
   3:          /// </summary>
   4:          /// <param name="request">The current request.</param>
   5:          /// <param name="queryStringKeys">The keys for which to generate parameters.</param>
   6:          /// <returns>
   7:          /// A list of QueryString parameters for the given list of <paramref name="queryStringKeys"/>
   8:          /// </returns>
   9:          protected static string GenerateQueryStringParameters(HttpRequest request, params string[] queryStringKeys)
  10:          {
  11:              StringBuilder queryString = new StringBuilder(64);
  12:              foreach (string key in queryStringKeys)
  13:              {
  14:                  if (Engage.Utility.HasValue(request.QueryString[key]))
  15:                  {
  16:                      if (queryString.Length > 0)
  17:                      {
  18:                          queryString.Append("&");
  19:                      }
  20:   
  21:                      queryString.Append(key).Append("=").Append(request.QueryString[key]);
  22:                  }
  23:              }
  24:   
  25:              return queryString.ToString();
  26:          }
  27:   
  28:          /// <summary>
  29:          /// Sets up a DNN <see cref="PagingControl"/>.
  30:          /// </summary>
  31:          /// <param name="pagingControl">The pager control.</param>
  32:          /// <param name="totalRecords">The total records.</param>
  33:          /// <param name="queryStringKeys">The QueryString keys which should be persisted when the paging links are clicked.</param>
  34:          protected void SetupPagingControl(PagingControl pagingControl, int totalRecords, params string[] queryStringKeys)
  35:          {
  36:              pagingControl.Visible = totalRecords != 0;
  37:              pagingControl.TotalRecords = totalRecords;
  38:              pagingControl.CurrentPage = this.CurrentPageIndex;
  39:              pagingControl.TabID = this.TabId;
  40:              pagingControl.QuerystringParams = GenerateQueryStringParameters(this.Request, queryStringKeys);
  41:          }

Hope it helps,


Brian Dukes
Engage Software
St. Louis, MO
866-907-4002
DNN partner specializing in custom, enterprise DNN development.
 
New Post
1/30/2009 10:33 AM
 

Brian, this was very helpful - thank you for sharing this code!

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0DNN Pager Control: Adding additional Querystring parameters?DNN Pager Control: Adding additional Querystring parameters?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out