How to redirect an SQL query to another page?

I have a page that lists an inventory.  We have created another page that is printer friendly (fancy stuff stripped out) and want to put a link on the original page that includes the current search results which will redirect the query to the printer friendly page.

So, in short, how do I grab the current SQL query statement in the URL, strip out the page reference, add in my own page URL so the user will get the same results on the new page?  Confused yet?

Example:

This is what is on my results page URL

http://mysite.com/loanItems.aspx?search=yes&transaction=All&text=&program=All&category=All

I am adding a button to that page that will redirect the user to a printer friendly page:

http://mysite.com/printer_friendly_loanItems.aspx?search=yes&transaction=All&text=&program=All&category=All

So, how can I grab the current URL and/or search query and direct it to my printer_friendly page?
RuralInstituteAsked:
Who is Participating?
 
CCongdonCommented:
Here's how dreamweaver appends the current query string to a redirect


  ' append the query string to the redirect URL
    Dim MM_editRedirectUrl
    MM_editRedirectUrl = "YOURPAGENAMEHERE.asp"
    If (Request.QueryString <> "") Then
      If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
        MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
      Else
        MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
      End If
    End If
    Response.Redirect(MM_editRedirectUrl)

Open in new window

0
 
DavidTMooreCommented:
One thing you could do is store the dataset in a session variable, then when you open the new page bind it with that dataset.  Another option would be to use a print stylesheet (within your css reference tag include 'media="print"  I tend to favor the second option as it removes the need for the user to go to another page just to print.

hope this helps.

cheers
~David
0
 
john_steedCommented:
Hi,

You can grab the url parameters like this
HttpContext.Current.Request.QueryString
add a new page before it and do a redirect.

A print css is always the best solution, i wouldn't recommend storing the dataset
0
 
CCongdonCommented:
Forgot to mention, the dreamweaver approach may look a little ugly, but one advantage that it offers is that the MM_editRedirectURL can be set to a page name OR a page name that already contains a query string (ie: YOURPAGENAMEHERE.asp?Print=True)
0
 
RuralInstituteAuthor Commented:
I like CCongdon's approach; I am VERY dumb when it comes to this stuff.  

Isn't ignorance bliss?....NOT

Here is the page code in its entirety, I believe I can make the edit here and not in the .cs file:
<%@ Reference Page="~/search.aspx" %>
<%@ Register TagPrefix="cc1" Namespace="skmMenu" Assembly="skmMenu" %>
<%@ Register TagPrefix="igtbl" Namespace="Infragistics.WebUI.UltraWebGrid" Assembly="Infragistics.WebUI.UltraWebGrid.v4.3, Version=4.3.20043.1142, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" %>
<%@ Register TagPrefix="igtbl1" Namespace="Infragistics.WebUI.UltraWebGrid" Assembly="Infragistics.WebUI.UltraWebGrid.v4.3, Version=4.3.20043.1142, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" %>
<%@ Page language="c#" Inherits="MTDB.loanItems" debug="True" CodeFile="loanItems.aspx.cs" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<HTML>
	<HEAD>
		<title>Loan Items</title>
		<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
		<meta content="C#" name="CODE_LANGUAGE">
		<meta content="JavaScript" name="vs_defaultClientScript">
		<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
		<LINK href="mtdb.css" type="text/css" rel="stylesheet">
	</HEAD>
	<body>
		<form id="Form1" method="post" runat="server">
			<div id="container">
				<div id="logo"></div>
				<div id="mainBanner">
					<p><cc1:menu id="mnuTop" runat="server" Font-Size="13pt" Font-Bold="True" width="500px" Layout="Horizontal"
							Cursor="Pointer" Font-Weight="bold" Font-Names="Georgia"></cc1:menu></p>
				</div>
				<div id="menuSpacer"></div>
				<div id="leftMenu">
					<ul>
						<li>
							<cc1:menu id="mnuMain" runat="server" Cursor="Pointer" Font-Names="Georgia" Width="198px"
								BackColor="#6B85AA" ItemPadding="5" ItemSpacing="0"></cc1:menu>
							<p align="center"><IMG src="images/imgSeperate.gif" align="middle"></p>
							<cc1:menu id="mnuOptions" runat="server" width="198px" Cursor="Pointer" Font-Names="Georgia"
								BackColor="#6B85AA" ItemPadding="5" ItemSpacing="0"></cc1:menu><br>
							<br>
							<div id="reservedItems"><igtbl1:ultrawebgrid id="Reserved" runat="server" Width="198px" OnInitializeRow="Reserved_InitializeRow">
									<DisplayLayout JavaScriptFileName="gridScripts/ig_WebGrid.js" JavaScriptFileNameCommon="gridScripts/ig_csom.js"
										RowHeightDefault="20px" Version="4.00" BorderCollapseDefault="Separate" Name="Reserved">
										<AddNewBox>
											<Style BorderWidth="1px" BorderStyle="Solid" BackColor="LightGray">
 
<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px" ColorLeft="White">
</BorderDetails>
 
											</Style>
										</AddNewBox>
										<Pager>
											<Style BorderWidth="1px" BorderStyle="Solid" BackColor="LightGray">
 
<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px" ColorLeft="White">
</BorderDetails>
 
											</Style>
										</Pager>
										<HeaderStyleDefault BorderStyle="Solid" BackColor="LightGray">
											<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px" ColorLeft="White"></BorderDetails>
										</HeaderStyleDefault>
										<FrameStyle Width="198px" BorderWidth="1px" Font-Size="8pt" Font-Names="Verdana" BorderStyle="Solid"></FrameStyle>
										<FooterStyleDefault BorderWidth="1px" BorderStyle="Solid" BackColor="LightGray">
											<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px" ColorLeft="White"></BorderDetails>
										</FooterStyleDefault>
										<EditCellStyleDefault BorderWidth="0px" BorderStyle="None"></EditCellStyleDefault>
										<RowStyleDefault BorderWidth="1px" BorderColor="Gray" BorderStyle="Solid">
											<Padding Left="3px"></Padding>
											<BorderDetails WidthLeft="0px" WidthTop="0px"></BorderDetails>
										</RowStyleDefault>
									</DisplayLayout>
									<Bands>
										<igtbl1:UltraGridBand></igtbl1:UltraGridBand>
									</Bands>
								</igtbl1:ultrawebgrid></div>
						</li>
					</ul>
				</div>
				<div id="content">
					<div id="itemList"><igtbl1:ultrawebgrid id="exchangeList" runat="server" Width="540px" UseAccessibleHeader="True">
							<DisplayLayout JavaScriptFileName="gridScripts/ig_WebGrid.js" JavaScriptFileNameCommon="gridScripts/ig_csom.js"
								RowHeightDefault="20px" Version="4.00" BorderCollapseDefault="Separate" Name="exchangeList">
								<AddNewBox>
									<Style BorderWidth="1px" BorderStyle="Solid" BackColor="LightGray">
 
<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px" ColorLeft="White">
</BorderDetails>
 
									</Style>
								</AddNewBox>
								<Pager>
									<Style BorderWidth="1px" BorderStyle="Solid" BackColor="LightGray">
 
<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px" ColorLeft="White">
</BorderDetails>
 
									</Style>
								</Pager>
								<HeaderStyleDefault BorderStyle="Solid" BackColor="LightGray">
									<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px" ColorLeft="White"></BorderDetails>
								</HeaderStyleDefault>
								<FrameStyle Width="540px" BorderWidth="1px" Font-Size="8pt" Font-Names="Verdana" BorderStyle="Solid"></FrameStyle>
								<FooterStyleDefault BorderWidth="1px" BorderStyle="Solid" BackColor="LightGray">
									<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px" ColorLeft="White"></BorderDetails>
								</FooterStyleDefault>
								<EditCellStyleDefault BorderWidth="0px" BorderStyle="None"></EditCellStyleDefault>
								<RowStyleDefault BorderWidth="1px" BorderColor="Gray" BorderStyle="Solid">
									<Padding Left="3px"></Padding>
									<BorderDetails WidthLeft="0px" WidthTop="0px"></BorderDetails>
								</RowStyleDefault>
							</DisplayLayout>
							<Bands>
								<igtbl:UltraGridBand></igtbl:UltraGridBand>
							</Bands>
						</igtbl1:ultrawebgrid></div>
				</div>
				<div id="footer"><IMG src="images/footer.gif"></div>
			</div>
		</form>
	</body>
</HTML>

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.