Solved

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

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

A recent question popped up and the discussion heated up regarding updating a COMMENTS (TXT) field in a table using SSRS. http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/MS-SQL_Reporting/Q_27475269.html?cid=1572#a37227028 (htt…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…

739 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