Solved

How do I call the function when the SSRS page loads.

Posted on 2010-11-19
5
1,805 Views
Last Modified: 2012-05-10
I have written an some embeded function code.

How do I call the function when the SSRS page loads.

Thanks.
0
Comment
Question by:Mr_Shaw
  • 3
  • 2
5 Comments
 
LVL 10

Expert Comment

by:itcouple
ID: 34171452
Hi

You can use functons with expressions like that
=Code.FunctionName()

Let me know if that answers your question.
Regards
Emil
0
 

Author Comment

by:Mr_Shaw
ID: 34171478
I am now getting the following error.

[rsRuntimeErrorInExpression] The Value expression for the textbox ‘textbox1’ contains an error: Object reference not set to an instance of an object.
Preview complete -- 0 errors, 1 warnings

Here is my code

Public Shared Function Test() As String
System.Web.HttpContext.Current.Response.Redirect("www.web.address")
End Function



0
 
LVL 10

Accepted Solution

by:
itcouple earned 500 total points
ID: 34171564
Hi

I have seen and tried to use System.Web.HttpContext. in the past but no luck. I think I have seen it working to center image on SSRS report but this was used by using assemblies and classes and i have tried that to do Javascript injection (and even with injection you still have to preess button on report).

In your case you try to use function which should only return singular value and you try to perform actions and that potentially may be blocked or not have access to it. The way I know this can be used is assemblies with classes alghough I only know examples where only certain parts of the report are manipulated not to redirect.

Where did you find this code? Did it relate to ssrs?

If you really want going this way just build asp.net page and use ReportViewer it was built for this purpose and is much more flexible. If you go this way you can also 'grab' the report and use Javascript I did that (proof-of-concept') to get very nice tooltips :)

Hope that answers your question.
Emil

0
 

Author Comment

by:Mr_Shaw
ID: 34171708
So i take it the following would also not work

Public Shared Function AddJavaScriptFile()
  System.Web.HttpContext.Current.Response.Write("<script type='text/javascript'><!--window.location = 'http://www.google.com/'//--></script>")
 return nothing
 
End Function
0
 
LVL 10

Expert Comment

by:itcouple
ID: 34171951
You would have to do Javascript incjection by default any Javascript code is removed (unless it is used as a hyperlink on the report, the exception I know)

Here is something which helped with incjection
http://blogs.infosupport.com/blogs/bast/archive/2009/09/10/reporting-services-javascript-injection.aspx

You can find my sample code there in comments (as Emil)
Regards
Emil
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

Hi, I have heard from my friends that it’s not possible to create Label Printing report using SSRS. I am amazed after hearing this words not possible in SSRS. I googled lot and found that it is possible to some of people know about the Report Bui…
In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

820 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