Solved

How to redirect an SQL query to another page?

Posted on 2007-11-20
5
718 Views
Last Modified: 2008-02-01
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?
0
Comment
Question by:RuralInstitute
5 Comments
 
LVL 4

Expert Comment

by:DavidTMoore
ID: 20322301
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
 
LVL 3

Expert Comment

by:john_steed
ID: 20322325
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
 
LVL 9

Accepted Solution

by:
CCongdon earned 500 total points
ID: 20322354
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
 
LVL 9

Expert Comment

by:CCongdon
ID: 20322376
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
 

Author Comment

by:RuralInstitute
ID: 20323869
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article discusses how to create an extensible mechanism for linked drop downs.
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now