Solved

How to redirect an SQL query to another page?

Posted on 2007-11-20
5
714 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

707 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

19 Experts available now in Live!

Get 1:1 Help Now