Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

Page URL With Changing Variables

Posted on June 28, 2013October 26, 2015 By David Kittell

Often I’ve had to build a page that didn’t allow the datagrid or listview built in sort options so I came up with this function so that you can keep filters and change the sorting and direction of the page.

public string sPageURLwVariables(string sArrow, string sDir)
	{
		string sOriginalURL = HttpContext.Current.Request.Url.PathAndQuery;
		string sCleanURL = "";

		string[] sURLVariables = sOriginalURL.Split(new char[] { '?', '&' });
		if (sURLVariables.GetLength(0) > 0)
		{
			foreach (string sURLVariable in sURLVariables)
			{
				if (sURLVariable != HttpContext.Current.Request.Url.AbsolutePath)
				{
					if (sURLVariable.IndexOf(sArrow, 0) < 1)
					{
						if (sCleanURL != "")
						{
							sCleanURL += "&";
						}
						sCleanURL += sURLVariable;
						Response.Write(sURLVariable + "<br>");
					}
				}
			}
			if (sCleanURL != "")
			{
				sCleanURL = HttpContext.Current.Request.Url.AbsolutePath + "?" + sCleanURL;
			}
			else
			{
				sCleanURL = HttpContext.Current.Request.Url.AbsolutePath;
			}
			return sCleanURL;
		}
		else
		{
			return HttpContext.Current.Request.Url.AbsolutePath;
		}
	}
Originally Posted on June 28, 2013
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code CSharp

Post navigation

Previous post
Next post

Related Posts

List All Files In Folder

Posted on September 23, 2015

<?PHP function getDirectory( $path = ‘.’, $level = 0 ){ $ignore = array( ‘cgi-bin’, ‘.’, ‘..’ ); // Directories to ignore when listing output. Many hosts // will deny PHP access to the cgi-bin. $dh = @opendir( $path ); // Open the directory to the handle $dh while( false !==…

Read More

VB.NET – Remove Empty Folders

Posted on December 14, 2013December 22, 2019

‘Remove Empty Folders – Start Public Shared Sub RemoveEmptyFolders(ByVal path As String) Dim directory As New DirectoryInfo(path) For Each subDirectory As DirectoryInfo In directory.GetDirectories() If subDirectory.GetFiles().Length = 0 Then Try subDirectory.Delete() Catch ex As Exception End Try End If Next subDirectory End Sub ‘Remove Empty Folders – Stop Originally Posted…

Read More

VS Script – Drive Info

Posted on July 18, 2013September 2, 2019

‘DriveInfo.vbs – Show information for local & network drives. ‘Note: A bug in WScript results in sizes over 2 GB being misreported. ‘© Bill James – billjames.geo@yahoo.com – rev 16 Feb 2000 Option Explicit Dim WshShell,FSO,Drv,Dtype,Dfree,Dtot Dim Dname,Dpct,Dused,Dserial,Dinfo Set WshShell=WScript.CreateObject("WScript.Shell") Set FSO=CreateObject("Scripting.FileSystemObject") For each Drv in FSO.Drives If Drv.DriveType=0 Then…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Open On Screen Keyboard (OSK)
  • SQLite - Auto-Increment / Auto Generate GUID
  • Mac OS X Terminal - Parallels - Reset Windows User Password
  • PowerShell - IPv4 Range

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • Open On Screen Keyboard (OSK)
  • SQLite - Auto-Increment / Auto Generate GUID
  • Mac OS X Terminal - Parallels - Reset Windows User Password
  • PowerShell - IPv4 Range
©2025 David Kittell | WordPress Theme by SuperbThemes