Solved

How to redirect an SQL query to another page?

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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CSS: How to get responsive tables to not be so spread out on desktop 5 35
CSS: Making responsive table look nicer 7 27
Javascript Form Change 5 23
Jquery 2 13
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

823 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