Solved

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

Posted on 2010-11-19
5
1,730 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

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…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

895 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now