Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.13 KB | None | 0 0
  1. if (results != null)
  2. {
  3.     // Use NVC to build a Query String using internal HttpValueCollection
  4.     NameValueCollection queryString = System.Web.HttpUtility.ParseQueryString(string.Empty);
  5.  
  6.     if (!string.IsNullOrEmpty(SearchBySolicitor.Text)) {
  7.         queryString["firm"] = Server.UrlEncode(SearchBySolicitor.Text);
  8.     }
  9.  
  10.     if (!string.IsNullOrEmpty(AreaOfLaw.Text)) {
  11.         queryString["area"] = Server.UrlEncode(AreaOfLaw.Text);
  12.     }
  13.  
  14.     if (!string.IsNullOrEmpty(Location.Text)) {
  15.         queryString["location"] = Server.UrlEncode(Location.Text);
  16.     }
  17.  
  18.     queryString.MyExtension("postcode", Postcode.Text);
  19.    
  20.     string URL = Sitecore.Links.LinkManager.GetItemUrl(results) + "?" + queryString.ToString();
  21.  
  22.     // Send user off to results
  23.     Response.Redirect(URL);
  24. }
  25. else
  26. {
  27.     // Unable to find results error
  28.     litTest.Text = "Error! Unable to find results page";
  29. }
  30.  
  31. public static class MyExtension
  32. {
  33.     public void MyExtension(SomeType this queryString, string stringName, string text)
  34.     {
  35.         if (!string.IsNullOrEmpty(text))
  36.         {
  37.             queryString[stringName] = Server.UrlEncode(queryString, );
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement