Problem with ASP.NET ReportViewer

C

Chris Cap

We are currently using client reports (.rdlc) to serve up some reports for
our clients. We are trying to make it so that when a user clicks on category
data (ie - order number), it will navigate to a new page that shows the order
details with the order id in the querystring. I tried clicking on the data
point and then chosing action and setting the radio button to "Jump to URL",
but it only works with an absolute path (http://www.google.com) it won't work
with relative links (/orderHistory.aspx).

Does anyone know how I can get this to work. I tried using
Globals!ReportServerUrl to get the absolute path, but that doesn't render
anything in a local report apparently. I was thinking of adding a reference
to a custom assembly that pulled a value from my web.config, however,
references don't seem to work unless the assembly is in the GAC which is not
an option.

I would really prefer not to hardcode the absolute path. I need to be able
to change what server this is hosted on and what domain name it uses very
easily. I don't think the control exposes a Hyperlink_NAvigate event like
the winforms version of this control does. Any help is appreciated.
 
S

Steven Cheng[MSFT]

Hello Chris,

Based on your description, you have an RDLC client report which want to
programmaticaly construct a url string(full qualified one such as
Http://servername/appname/page...) and use it in your reportitem
expression, correct?

I think your current idea about put the main url part in application's
config file and read it through custom assembly's code is a good idea. And
I have another idea which also rely on custom code/assembly. You can use
the HttpContext.Request.Url to get the absolute url information e.g.

the following class/method can help return the url to the current
application's virtual dir

=========================
namespace ReportLib
{
public class ReportUtil
{
public static string GetUrl()
{
string url =
System.Web.HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority)
;
url += System.Web.HttpContext.Current.Request.ApplicationPath;


return url;
}
}
}
==================


For the custom assembly, of course you do not have to put it in GAC. A
simple private assembly in ASP.NET application's "bin" dir is necessary.
The problem you met may be caused by the custom assembly or any other
assembly you used is not trusted, to make any custom assembly you use in
your local report(RDLC) trusted, you can use the following like code in
page's load event.

===========
protected void Page_Load(object sender, EventArgs e)
{

this.ReportViewer1.LocalReport.AddTrustedCodeModuleInCurrentAppDomain("Repor
tLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");


}
=============

"ReportLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" is the
assembly name of my custom assembly. Here is a good blog article describe
the detailed on how to use custom code/assembly in RDLC local report.


#Adding custom code to Local Reports in Visual Studio.NET 2005 (Problems &
Solutions)
http://blogs.msdn.com/mohamed_sharafs_blog/archive/2005/12/20/LocalReportCus
tomCode.aspx

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.
 
C

Chris Cap

Thanks Steven. I will give that at try

Steven Cheng said:
Hello Chris,

Based on your description, you have an RDLC client report which want to
programmaticaly construct a url string(full qualified one such as
Http://servername/appname/page...) and use it in your reportitem
expression, correct?

I think your current idea about put the main url part in application's
config file and read it through custom assembly's code is a good idea. And
I have another idea which also rely on custom code/assembly. You can use
the HttpContext.Request.Url to get the absolute url information e.g.

the following class/method can help return the url to the current
application's virtual dir

=========================
namespace ReportLib
{
public class ReportUtil
{
public static string GetUrl()
{
string url =
System.Web.HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority)
;
url += System.Web.HttpContext.Current.Request.ApplicationPath;


return url;
}
}
}
==================


For the custom assembly, of course you do not have to put it in GAC. A
simple private assembly in ASP.NET application's "bin" dir is necessary.
The problem you met may be caused by the custom assembly or any other
assembly you used is not trusted, to make any custom assembly you use in
your local report(RDLC) trusted, you can use the following like code in
page's load event.

===========
protected void Page_Load(object sender, EventArgs e)
{

this.ReportViewer1.LocalReport.AddTrustedCodeModuleInCurrentAppDomain("Repor
tLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");


}
=============

"ReportLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" is the
assembly name of my custom assembly. Here is a good blog article describe
the detailed on how to use custom code/assembly in RDLC local report.


#Adding custom code to Local Reports in Visual Studio.NET 2005 (Problems &
Solutions)
http://blogs.msdn.com/mohamed_sharafs_blog/archive/2005/12/20/LocalReportCus
tomCode.aspx

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

Steven Cheng[MSFT]

Thanks for the reply Chris,

Please feel free to let me know if you have got any progress or there is
anything else we can help.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top