Solved

Response.Write from within a class module

Posted on 2008-10-23
6
293 Views
Last Modified: 2012-05-05
I've build an VB class module that gathers data for a report, creates a PDF image of the finished report, and then attempts to issue a Response.Write statement to open the PDF report as follows:
        Response.Write("<script>window.open('" & HttpPath & "',target='_blank');</script>")
This causes 'Name Reponse is not Declared' to display and the project will not compile.

Looking at article I found here on Expert Exchange, I attempted the following code:
        Dim app As HttpApplication
        app.Context.Response.Write("<script>window.open('" & HttpPath & "',target='_blank');</script>")
This statement fails saying that app is a null reference.
I just can't seem to win here!

Can someone please tell me how to accomplish, what seems like should be, this simple task.

Thank you, Herb



0
Comment
Question by:stullhe104
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 17

Expert Comment

by:Daniel Reynolds
ID: 22788644
You will need to pass the application response object to the class from the calling web page.

By doing this, you get the current context of the response object.
0
 

Author Comment

by:stullhe104
ID: 22788716
That sounds easy enough. Can you give me an idea of what the code would look like to call the class?
I should think that the function I am calling within the class would look something like this:
    Public Shared Sub generateTechEvalReport(ByVal app As HttpApplication)

But what does the code look like to call this?
   generateTechEvalReport(?)

0
 
LVL 17

Expert Comment

by:Daniel Reynolds
ID: 22788787
You can even just pass the response object.
My example is in C#, but this should give you an idea

ombbt is a class that needs to use the response object

        ombbt.GenerateReport(Response);

        public void GenerateReport(HttpResponse parentResponse)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

Accepted Solution

by:
Daniel Reynolds earned 250 total points
ID: 22788803
generateTechEvalReport(Response)  ' should do it
or
generateTechEvalReport(Application)  ?  typing from memory here
0
 

Author Closing Comment

by:stullhe104
ID: 31509315
Hot dam... you don't know how long I've been trying to figure this out. It's been frustrating.

Thanks for coming through. This will help me a lot!

One quick follow up question... I noticed that when I do the response.write to open a new window and display the report that the webpage in the existing window of my application gets distorted by way of the images and text being larger.
Any idea why that happens?

Thanks again.. Herb
0
 
LVL 17

Expert Comment

by:Daniel Reynolds
ID: 22788902
sorry, not sure why the distortion.

Glad that helped.
Dan
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

729 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