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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Response.Write in Module

Status
Not open for further replies.

schwarem

Programmer
Apr 18, 2002
159
0
0
US
I have a section of Response.Write code used to open files that I want to put in a module, so I can use it in multiple pages. When I put it in the module, it tells me "Response is not declared." Is there a library or something that I can include to allow Response to be placed in the module?
 
Response.Write can only be used on an actual page (and it should only be used in testing anyway).


____________________________________________________________

Need help finding an answer?

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

 
Are you wanting this permanently in the solution? Or just for testing?
Did you try using a msgbox?
Or maybe this redirect to another page
Code:
response.redirect “Mypage.asp?Value1=xxxx&Value2=yyyy”

Then in Maypage.asp use this
Code:
SomeValue1 = Request.QueryString("Value1")
SomeValue2 = Request.QueryString("Value2")
Response.Write SomeValue1
Response.Write SomeValue2

Another thought...
you can have an .asp page that has all the code in your module and then call it with response.redirect as above and the .asp page will allow you to use Response.Write.


DougP, MCP, A+
 
Try this

System.Web.HttpContext.Current.Response.write

Rich
 
I can't see what the need for Response.Write would be in a module (as it should only be used for testing a page) so it should always be available.

You shouldn't ever have the need to test a function in a module this way as the function should simply return the variable (Response.Write could always be used on the page to test the contents of the variable).


____________________________________________________________

Need help finding an answer?

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

 
Since everyone is asking, here is the code I am using. I am using it to output the file off the server.

Public Function RedirectFile(ByVal File As System.IO.FileInfo)
If File.Exists Then 'set appropriate headers
System.Web.HttpContext.Current.Response.Clear()
System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" & File.Name)
System.Web.HttpContext.Current.Response.AddHeader("Content-Length", File.Length.ToString())
System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream"
System.Web.HttpContext.Current.Response.WriteFile(File.FullName)
System.Web.HttpContext.Current.Response.End() 'if file does not exist
End If
End Function
 
Oh, so you are actually using Response.WriteFile and not Response.Write?


____________________________________________________________

Need help finding an answer?

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

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top