Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

controlling the back button in Internet Explorer

Status
Not open for further replies.

OhioSteve

MIS
Joined
Mar 12, 2002
Messages
1,352
Location
US
This is my situation:
1. I have an asp.net webapplication with a webform with a button.
2. When the user clicks the button, he is response.redirected to a different web page in a different application.
3. When the second web page loads, it runs a program that generates a pdf. Then the user is response.redirected to the .pdf. They never even see the second page.
4. When the .pdf appears, the browser's back button is grey. Moreover, the pdf takes up the whole browser window. So the user cannot return to their original web page.
5. This frustrates the user.

How do I remind the browser where it started? I know how to cache variables. But I do not know how to tell the browser to use a cached variable as the value for the back button. Remember that the .pdf takes up the whole screen. So I cannot add a normal button.
 
just open the pdf in another window..

this is how I open a pdf from a crystal report

you never want to mess with the back button in IE..

Dim strRedirect As String

strRedirect = "YourForm.aspx"
Response.Write("<script language='javascript'>" & vbCrLf)
Response.Write("wndcht=window.open('" + strRedirect + "','_new', 'toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes,left=0,top=0');")
Response.Write("<" & "/" & "script" & ">" & vbCrLf)


 
Rather than redirecting the user why not send the PDF file in the Response stream? The user can then decide whether to open or save the file.

Alternatively, you could use the method suggested above but, if you do, use the RegisterClientScriptBlock method to write out any javascript rather than Response.Write


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
ca8msm,
when is the correct time to use response.write? Only for troubleshooting? I know client side scripting is by far the way to go but I am still trying to learn java. I am trying to use the below code but am getting an error.

it does not like stringbuilder. I got this example from the net. Can you tell me what I am missing here.

Dim strScript As StringBuilder = New StringBuilder
strScript.Append("<script language=JavaScript>")
strScript.Append("window.open('" + strRedirect + "', """",""height=100,width=400,left=0,top=0,toolbar=no,menubar=no"");")
strScript.Append("</script>")
RegisterClientScriptBlock("subscribescript", strScript.ToString)

Thanks for your help

 
when is the correct time to use response.write? Only for troubleshooting?
Yes, I would say so. There are very few occasions when Response.Write is actually useful in a production environment.

it does not like stringbuilder
What do you mean by this? Have you imported System.Text?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
After reading your answers, I experimented with[reportdocument].exportToHTTPResponse. It was a great learning experience, but I could not get it to work in the way I wanted.

r.ExportToHttpResponse(ExportFormatType.PortableDocFormat, System.Web.HttpContext.Current.Response, False, "")

That caused the pdf to appear, but the address bar still showed my aspx page. Also, the back button was still grey.

Changing the boolean property to true caused it to appear as a download. That will confuse the users.

Perhaps I need to split this into two tasks. First I will make the pdf. Then I will display it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top