<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>moopoo.net &#187; business objects</title>
	<atom:link href="http://moopoo.net/tag/business-objects/feed/" rel="self" type="application/rss+xml" />
	<link>http://moopoo.net</link>
	<description>Fishing, technology and anything else</description>
	<lastBuildDate>Wed, 09 Jun 2010 11:34:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Displaying Crystal Reports in a Web Browser</title>
		<link>http://moopoo.net/web-development/displaying-crystal-reports-in-a-web-browser/</link>
		<comments>http://moopoo.net/web-development/displaying-crystal-reports-in-a-web-browser/#comments</comments>
		<pubDate>Tue, 23 Oct 2007 08:07:26 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[business objects]]></category>
		<category><![CDATA[crystal reports]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://moopoo.net/blog/2007/10/23/displaying-crystal-reports-in-a-web-browser/</guid>
		<description><![CDATA[Having tried for a while to find the right information for displaying Crystal Reports properly inside a web page using Crystal Report Viewer I finally managed to pull the information together into a solution that works; well for me anyway.
It&#8217;s worth mentioning that I don&#8217;t use the Crystal Reports extensions for Visual Studio, I have [...]]]></description>
			<content:encoded><![CDATA[<p>Having tried for a while to find the right information for displaying Crystal Reports properly inside a web page using Crystal Report Viewer I finally managed to pull the information together into a solution that works; well for me anyway.</p>
<p>It&#8217;s worth mentioning that I don&#8217;t use the Crystal Reports extensions for Visual Studio, I have Crystal Server running on the box. I can&#8217;t see how this method wouldn&#8217;t work through the Visual Studio extensions.</p>
<h3>Code Infront</h3>
<p>Register the assembly in the top of your aspx page</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&lt;%</span>@ Register TagPrefix<span style="color: #008000;">=</span><span style="color: #666666;">&quot;cr&quot;</span> <span style="color: #0600FF;">Namespace</span><span style="color: #008000;">=</span><span style="color: #666666;">&quot;CrystalDecisions.Web&quot;</span> 
Assembly<span style="color: #008000;">=</span><span style="color: #666666;">&quot;CrystalDecisions.Web, Version=11.0.3300.0, Culture=neutral, PublicKeyToken=692fbea5521e1304&quot;</span> <span style="color: #008000;">%&gt;</span></pre></div></div>

<p>Place the control where you want it to appear in the page.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&lt;</span>cr<span style="color: #008000;">:</span>crystalreportviewer id<span style="color: #008000;">=</span><span style="color: #666666;">&quot;crReport1&quot;</span> runat<span style="color: #008000;">=</span><span style="color: #666666;">&quot;server&quot;</span> hasviewlist<span style="color: #008000;">=</span><span style="color: #666666;">&quot;False&quot;</span>
    hastogglegrouptreebutton<span style="color: #008000;">=</span><span style="color: #666666;">&quot;False&quot;</span> hassearchbutton<span style="color: #008000;">=</span><span style="color: #666666;">&quot;False&quot;</span>
    hasgotopagebutton<span style="color: #008000;">=</span><span style="color: #666666;">&quot;False&quot;</span> hasdrillupbutton<span style="color: #008000;">=</span><span style="color: #666666;">&quot;False&quot;</span> hascrystallogo<span style="color: #008000;">=</span><span style="color: #666666;">&quot;False&quot;</span>
    autodatabind<span style="color: #008000;">=</span><span style="color: #666666;">&quot;true&quot;</span> width<span style="color: #008000;">=</span><span style="color: #666666;">&quot;350px&quot;</span> displaygrouptree<span style="color: #008000;">=</span><span style="color: #666666;">&quot;False&quot;</span>
    height<span style="color: #008000;">=</span><span style="color: #666666;">&quot;50px&quot;</span> hyperlinktarget<span style="color: #008000;">=</span><span style="color: #666666;">&quot;_blank&quot;</span><span style="color: #008000;">&gt;</span></pre></div></div>

<h3>Code Behind</h3>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">// declare the variables</span>
<span style="color: #0600FF;">protected</span> CrystalReportViewer crReport1<span style="color: #008000;">;</span>
<span style="color: #0600FF;">private</span> ReportDocument document1 <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> ReportDocument<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">private</span> TableLogOnInfos infos1 <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> TableLogOnInfos<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">private</span> TableLogOnInfo info2 <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> TableLogOnInfo<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">private</span> ConnectionInfo info1 <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> ConnectionInfo<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">// load the report</span>
document1.<span style="color: #0000FF;">Load</span><span style="color: #000000;">&#40;</span>Request.<span style="color: #0000FF;">PhysicalApplicationPath</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;myReport.rpt&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">// Add the parameters</span>
document1.<span style="color: #0000FF;">SetParameterValue</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;param1&quot;</span>, <span style="color: #666666;">&quot;value1&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
document1.<span style="color: #0000FF;">SetParameterValue</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;param2&quot;</span>, <span style="color: #666666;">&quot;value2&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">//Set the login info for the database</span>
info1.<span style="color: #0000FF;">ServerName</span> <span style="color: #008000;">=</span> ConfigurationSettings.<span style="color: #0000FF;">AppSettings</span><span style="color: #000000;">&#91;</span><span style="color: #666666;">&quot;server_name&quot;</span><span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span>
info1.<span style="color: #0000FF;">DatabaseName</span> <span style="color: #008000;">=</span> ConfigurationSettings.<span style="color: #0000FF;">AppSettings</span><span style="color: #000000;">&#91;</span><span style="color: #666666;">&quot;database_name&quot;</span><span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span>
info1.<span style="color: #0000FF;">UserID</span> <span style="color: #008000;">=</span> ConfigurationSettings.<span style="color: #0000FF;">AppSettings</span><span style="color: #000000;">&#91;</span><span style="color: #666666;">&quot;user_id&quot;</span><span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span>
info1.<span style="color: #0000FF;">Password</span> <span style="color: #008000;">=</span> ConfigurationSettings.<span style="color: #0000FF;">AppSettings</span><span style="color: #000000;">&#91;</span><span style="color: #666666;">&quot;password&quot;</span><span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span>
Tables tables1 <span style="color: #008000;">=</span> document1.<span style="color: #0000FF;">Database</span>.<span style="color: #0000FF;">Tables</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">//Apply login info to the report</span>
<span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span>CrystalDecisions.<span style="color: #0000FF;">CrystalReports</span>.<span style="color: #0000FF;">Engine</span>.<span style="color: #0000FF;">Table</span> table1 <span style="color: #0600FF;">in</span> tables1<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    info2 <span style="color: #008000;">=</span> table1.<span style="color: #0000FF;">LogOnInfo</span><span style="color: #008000;">;</span>
    info2.<span style="color: #0000FF;">ConnectionInfo</span> <span style="color: #008000;">=</span> info1<span style="color: #008000;">;</span>
    table1.<span style="color: #0000FF;">ApplyLogOnInfo</span><span style="color: #000000;">&#40;</span>info2<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">// Bind the report</span>
crReport1.<span style="color: #0000FF;">ReportSource</span> <span style="color: #008000;">=</span> document1<span style="color: #008000;">;</span>
crReport1.<span style="color: #0000FF;">DataBind</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

<p>You also need to remember to close the document after it has been rendered to free up memory. This should ideally be done in the Page_Unload method. See <a href="http://msdn2.microsoft.com/en-us/library/ms225490(VS.80).aspx" title="MSDN post on where to close a report (Opens in a new window)" target="_blank">this post</a> on MSDN for more information on why it should be placed in Page_Unload.</p>
]]></content:encoded>
			<wfw:commentRss>http://moopoo.net/web-development/displaying-crystal-reports-in-a-web-browser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
