Solved

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 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

20 Experts available now in Live!

Get 1:1 Help Now