<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3650981984408352034</id><updated>2024-09-06T06:53:26.259+05:30</updated><category term="ASP.NET"/><category term="C#"/><category term="HTML"/><category term="HTTPHandler"/><category term="SSRS"/><category term="Sql Server Reporting"/><category term="C# Pre Processor Directives"/><category term="Control Communication"/><category term="FavIcon"/><category term="HTTP 404"/><category term="ReportViewer"/><category term="ReportViewer Export PDF"/><category term="UserControl"/><category term="VIEWSTATE"/><title type='text'>&amp;lt;coolStuff&amp;gt; By Paresh Jagatia &amp;lt;/coolStuff&amp;gt;</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://pareshjagatia.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3650981984408352034/posts/default'/><link rel='alternate' type='text/html' href='http://pareshjagatia.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Paresh Jagatiya</name><uri>http://www.blogger.com/profile/10850885900014367688</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhn1FUQljdtVC15hVkjmGn9ujrgRQ-ckIUNjzH7NMOXeTfqZK89Ka9wRd5e6PFnu7uEydLZV_H9xkSYlsqN91pWZ9_-2z_fZYfcYX1LrGrS4pb7bIs_1QMYhkugUrjbL4U/s220/parth.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>12</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3650981984408352034.post-939636913305055612</id><published>2008-06-11T14:36:00.002+05:30</published><updated>2008-06-11T14:45:54.857+05:30</updated><title type='text'>Safer Email Address-2</title><content type='html'>&lt;span style=&quot;font-family:verdana;&quot;&gt;In our previous article &lt;a href=&quot;http://pareshjagatia.blogspot.com/2008/05/safer-email-address.html&quot;&gt; Safer Email Addresses&lt;/a&gt; we discussed how encoded email addresses are good against the email capture programs. Here we will see how to achieve this in ASP.NET.&lt;br /&gt;Create a class called BasePage and inherit the System.Web.UI.Page and then inherit all your webpages from this BasePage.&lt;br /&gt;Put following code in your BasePage.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;protected&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;override&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; Render(HtmlTextWriter writer)&lt;br /&gt;     {&lt;br /&gt;         StringWriter stringWriter &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; StringWriter();&lt;br /&gt;         HtmlTextWriter interceptedHtmlWriter &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; HtmlTextWriter(stringWriter, &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;);&lt;br /&gt;         &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;base&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;.Render(interceptedHtmlWriter);&lt;br /&gt;         &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; interceptedHtml &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; stringWriter.ToString();&lt;br /&gt;         interceptedHtml &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; ReplaceEmailAddresses(interceptedHtml);&lt;br /&gt;         writer.Write(interceptedHtml);&lt;br /&gt;     }&lt;br /&gt;     &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; ReplaceEmailAddresses(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; content) {&lt;br /&gt;         Regex emailMatcher &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; Regex(&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;([0-9a-zA-Z]+[-._+&amp;amp;amp;])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;);&lt;br /&gt;         MatchCollection matchesFound &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; emailMatcher.Matches(content);&lt;br /&gt;         &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;foreach&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; (Match m &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; matchesFound) {&lt;br /&gt;             content &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; Regex.Replace(content, m.Value, EncodeEmail(m.Value));&lt;br /&gt;         }&lt;br /&gt;         &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; content;&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; EncodeEmail(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; p)&lt;br /&gt;     {&lt;br /&gt;         &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; encoded &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;.Empty;&lt;br /&gt;         &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;foreach&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;char&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; c &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; p) {&lt;br /&gt;             encoded &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;+=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;&amp;amp;#&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; Convert.ToInt32(c).ToString()&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;;&lt;br /&gt;         }&lt;br /&gt;         &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; encoded;&lt;br /&gt;     }&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;Hope this helps....&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://pareshjagatia.blogspot.com/feeds/939636913305055612/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3650981984408352034/939636913305055612' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3650981984408352034/posts/default/939636913305055612'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3650981984408352034/posts/default/939636913305055612'/><link rel='alternate' type='text/html' href='http://pareshjagatia.blogspot.com/2008/06/safer-email-address-2.html' title='Safer Email Address-2'/><author><name>Paresh Jagatiya</name><uri>http://www.blogger.com/profile/10850885900014367688</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhn1FUQljdtVC15hVkjmGn9ujrgRQ-ckIUNjzH7NMOXeTfqZK89Ka9wRd5e6PFnu7uEydLZV_H9xkSYlsqN91pWZ9_-2z_fZYfcYX1LrGrS4pb7bIs_1QMYhkugUrjbL4U/s220/parth.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3650981984408352034.post-6017840760084637342</id><published>2008-06-03T16:15:00.001+05:30</published><updated>2008-06-03T16:16:33.067+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET"/><category scheme="http://www.blogger.com/atom/ns#" term="Control Communication"/><category scheme="http://www.blogger.com/atom/ns#" term="UserControl"/><title type='text'>UserControl communication explained !</title><content type='html'>&lt;p&gt;&lt;span style=&quot;font-family: Verdana; font-size: small;&quot;&gt;Sometime we need that all our user controls should communicate to each other when they are on a page. The functionality can be achieved by putting a delegate instance on the user control and on the other user control create a target as following (suppose you have a UserControl AddEditUser.ascx and the page on which you put this user control has user listing and you want that whenever a user is added the Grid must be refreshed. So let&#39;s do it using aforesaid approach. Below is the code in the UserControl for the AddEditUser.ascx)&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;delegate&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; UserAction(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;object&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; sender,EventArgs e); &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;event&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; UserAction OnUserSaved;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;protected&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; btnUserSave_Click(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;object&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; sender,EventArgs e){&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;(OnUserSaved &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;!=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OnUserSaved(sender,e); &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;span style=&quot;font-family: Verdana; font-size: small;&quot;&gt;And in the aspx page you write following code&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;AddEditUser1.OnUserSaved &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; UserAction(UserAdded_PageTrigger); &lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt; OR this short hand..  &lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt; AddEditUser1.OnUserSaved = UserAdded_PageTrigger;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;protected&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; UserAdded_PageTrigger(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;object&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; sender, EventArgs e)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt; Time to refresh the Users&#39; List.&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-family: Verdana; font-size: small;&quot;&gt;But let&#39;s think broader. I want this UserControl can talk about this recently added user to other UserControls on the page (like a small dashboard showing total users we have or kind of). There is a popular content management solution that call this UserControl a Module. And this functionality is addressed there ( is called Intra module communication) using the Interfaces. A interface is one that a developer has to implement (all methods) so it needs a guideline for a new developer to how to implmenet the interfaces so that his/her module can participate in the module communication.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-family: Verdana; font-size: small;&quot;&gt;I tried this using BaseClasses ( BaseClass is not something special but still famous among developers with this name. It is a class that inherits System.Web.UI.Page and this class is then inherited by all the pages in the application so that if, later on there is something to be applied on all the pages of the system this class can help us.). Let&#39;s look at the classes first.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt; BasePage.cs ( base class for all pages)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; BasePage : System.Web.UI.Page{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; List&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;BaseUserControl&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; _participants; &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; Register(BaseUserControl me)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; (_participants &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;)_participants &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; List&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;BaseUserControl&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp;&amp;nbsp; _participants.Add(me);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&amp;nbsp; internal&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; BroadCastToRegistrants(&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; BaseUserControl triggeringControl,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ControlBroadCastEventArgs e&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp; )&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; (_participants &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;!=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;foreach&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; (BaseUserControl _control &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; _participants)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; (_control &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;!=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; triggeringControl) _control.SomethingHappened(triggeringControl, e);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt; BaseUserControl.cs ( base class for all user controls)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; BaseUserControl : System.Web.UI.UserControl&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;delegate&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; BroadCastEvent(&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp; BaseUserControl fromControl, ControlBroadCastEventArgs e);&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;event&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; BroadCastEvent OnBroadCastDetected;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&amp;nbsp;protected&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;override&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; OnLoad(EventArgs e){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;base&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;.OnLoad(e);&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp; RegisterToPage();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;protected&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;virtual&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; RegisterToPage(){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ((BasePage)&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;.Page).Register(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; SomethingHappened(&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; BaseUserControl triggeringControl,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp;&amp;nbsp; ControlBroadCastEventArgs e) &lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp; { &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; (OnBroadCastDetected &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;!=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;) &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OnBroadCastDetected(triggeringControl, e);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp; } &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;virtual&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; BroadCast(ControlBroadCastEventArgs e){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp;&amp;nbsp; ((BasePage)&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;.Page).BroadCastToRegistrants(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;,e); &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; ControlBroadCastEventArgs : EventArgs&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&amp;nbsp; private&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; _message &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;.Empty; &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&amp;nbsp; private&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; _sender &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;.Empty;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&amp;nbsp; private&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;object&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; _object &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; Message { &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; _message;}&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;{                _message &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; value;}}&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; Sender{&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; _sender;}&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;{_sender &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; value;}}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;object&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; Value{&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; _object;}&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;{_object &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; value;}} &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; ControlBroadCastEventArgs(){}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;span style=&quot;font-family: Verdana; font-size: small;&quot;&gt;A very simple approach&lt;br /&gt;&amp;nbsp;to use but some questions might arise. like&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Verdana;&quot;&gt;&lt;strong&gt;Q : Why ControlBroadCastEventArgs ?&lt;/strong&gt; &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Verdana;&quot;&gt;&lt;strong&gt;A :&lt;/strong&gt;&amp;nbsp; This is the broadcast message. You can extend this message like you can add a DateTime type property that holds the timestamp when the broadcast occured. &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Verdana;&quot;&gt;&lt;strong&gt;Q : Why virtual methods ?&lt;/strong&gt; &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Verdana;&quot;&gt;&lt;strong&gt;A : &lt;/strong&gt; Nothing special but in case you want your user control must inherit the above BaseUserControl but should not participate in broadcasting or receiving broadcasts then just override this the Register method and write nothing inside. Or same way like if you want that your control only should listen to the outer broadcasts but should not broadcast anything then override the broadcast and put nothing inside.&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style=&quot;font-family: Verdana;&quot;&gt;Now let&#39;s take a look what will be inside your user control that you will inherit from the above BaseUserControl&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Verdana;&quot;&gt;To listen to a broadcast &lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;protected&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; Page_Load(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;object&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; sender, EventArgs e) {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;.OnBroadCastDetected &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;+=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; BroadCastEvent(ThisControl_OnBroadCastDetected);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; ThisControl_OnBroadCastDetected (&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; BaseUserControl fromControl, ControlBroadCastEventArgs e)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; (e.Sender &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;Broadcaster&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;){&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt; process the broadcasted message (e);&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;// to broadcast use following method&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;protected&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; BroadcastButton_Click(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;object&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; sender, EventArgs e)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp;ControlBroadCastEventArgs ev &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; ControlBroadCastEventArgs();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp;ev.Message &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;New date selected&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp;ev.Sender &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;CalendarControl&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;nbsp;ev.Value &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; Calendar1.SelectedDate;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;BroadCast(ev);&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;span style=&quot;font-family: Verdana; font-size: small;&quot;&gt;Using the above approach any control can broadcast anytime (means from any event) and other controls can listen to it. Any number of controls can be participants to listen to above broadcast.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://pareshjagatia.blogspot.com/feeds/6017840760084637342/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3650981984408352034/6017840760084637342' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3650981984408352034/posts/default/6017840760084637342'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3650981984408352034/posts/default/6017840760084637342'/><link rel='alternate' type='text/html' href='http://pareshjagatia.blogspot.com/2008/06/usercontrol-communication-explained.html' title='UserControl communication explained !'/><author><name>Paresh Jagatiya</name><uri>http://www.blogger.com/profile/10850885900014367688</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhn1FUQljdtVC15hVkjmGn9ujrgRQ-ckIUNjzH7NMOXeTfqZK89Ka9wRd5e6PFnu7uEydLZV_H9xkSYlsqN91pWZ9_-2z_fZYfcYX1LrGrS4pb7bIs_1QMYhkugUrjbL4U/s220/parth.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3650981984408352034.post-7351103358045802955</id><published>2008-05-22T09:19:00.006+05:30</published><updated>2008-05-31T20:20:39.167+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><title type='text'>The Constant Fact : Const Vs Static ReadOnly field</title><content type='html'>&lt;span style=&quot;;font-family:verdana;font-size:100%;&quot;&gt;One fact about constant, that we all know, is it&#39;s value can never be changed.&lt;br /&gt;Here goes another one.... The constant field is statically replaced by the compiler at the compile time wherever it is found.&lt;br /&gt;&lt;br /&gt;Means,&lt;br /&gt;&lt;div  style=&quot;font-family:courier new;&quot;&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&lt;br /&gt;double&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; circleArea &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; System.Math.PI &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 128);&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; r;&lt;/span&gt;&lt;/div&gt;compiled to&lt;br /&gt;&lt;/span&gt;&lt;div  style=&quot;font-family:courier new;&quot;&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:100%;&quot; &gt;double&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:100%;&quot; &gt; circleArea &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:100%;&quot; &gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:100%;&quot; &gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 128);font-size:100%;&quot; &gt;6.28318&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:100%;&quot; &gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:100%;&quot; &gt;*&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:100%;&quot; &gt; r;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;;font-family:verdana;font-size:100%;&quot;  &gt;&lt;br /&gt;Said that, suppose you have following expression in your one assembly &quot;Lib&quot;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div  style=&quot;font-family:courier new;&quot;&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:100%;&quot; &gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:100%;&quot; &gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:100%;&quot; &gt;const&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:100%;&quot; &gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:100%;&quot; &gt;int&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:100%;&quot; &gt; DataGridPageSize &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:100%;&quot; &gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:100%;&quot; &gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 128);font-size:100%;&quot; &gt;50&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:100%;&quot; &gt;;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;;font-family:verdana;font-size:100%;&quot;  &gt;&lt;span style=&quot;font-size:100%;&quot;&gt;And you are referring this assembly in your application &quot;App&quot;. Now if you compile the solution the DataGridPageSize will be replaced by 50 in your application. But, if you change the DataGridPageSize value to 100 and compile only the assembly &quot;Lib&quot; and forgot to compile the application &quot;App&quot; then your application still has the old value 50 and not the 100 unless you recompile the &quot;App&quot; application.&lt;br /&gt;&lt;br /&gt;But if you have used readonly static field you are safe in above scenario as it is not statically replaced at compile time as the constants are.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://pareshjagatia.blogspot.com/feeds/7351103358045802955/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3650981984408352034/7351103358045802955' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3650981984408352034/posts/default/7351103358045802955'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3650981984408352034/posts/default/7351103358045802955'/><link rel='alternate' type='text/html' href='http://pareshjagatia.blogspot.com/2008/05/constant-fact-const-vs-static-readonly.html' title='The Constant Fact : Const Vs Static ReadOnly field'/><author><name>Paresh Jagatiya</name><uri>http://www.blogger.com/profile/10850885900014367688</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhn1FUQljdtVC15hVkjmGn9ujrgRQ-ckIUNjzH7NMOXeTfqZK89Ka9wRd5e6PFnu7uEydLZV_H9xkSYlsqN91pWZ9_-2z_fZYfcYX1LrGrS4pb7bIs_1QMYhkugUrjbL4U/s220/parth.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3650981984408352034.post-5922168548000216928</id><published>2008-05-17T14:35:00.011+05:30</published><updated>2008-06-01T11:28:31.600+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="HTTPHandler"/><title type='text'>How To Embed Resource And Use It With WebResource Handler</title><content type='html'>&lt;span style=&quot;font-family:verdana;&quot;&gt;Before you go deeper into this please look into my previous post &lt;a href=&quot;http://pareshjagatia.blogspot.com/2008/05/using-webresources.html&quot;&gt;Why WebResources&lt;/a&gt; for good reasons for using WebResources.&lt;br /&gt;&lt;br /&gt;Three simple steps for this&lt;/span&gt;.&lt;br /&gt;&lt;span style=&quot;font-weight: bold;font-family:verdana;&quot; &gt;Embed a resource in the assembly&lt;/span&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt; : Select your resource (javascript or image or any other) and goto properties and select &quot;Embedded Resource&quot; as Build Action.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXZ8V72QQdVuxIZ5q73cz4i6L_WhfWJKmj0t_YK80sxEvPVpVNhy1S1qm8RHNjk8OgMjwekqzC_EedD8kw3wWwVUfo-Mh8Xc2KOsxHKLkxlcOWeG9d1nsCx93dhM_A4hbiHl5AsZOaQfIK/s1600-h/embedded_resource.JPG&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5201272739727932178&quot; style=&quot;margin: 0px auto 10px; display: block; cursor: pointer; text-align: center;&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXZ8V72QQdVuxIZ5q73cz4i6L_WhfWJKmj0t_YK80sxEvPVpVNhy1S1qm8RHNjk8OgMjwekqzC_EedD8kw3wWwVUfo-Mh8Xc2KOsxHKLkxlcOWeG9d1nsCx93dhM_A4hbiHl5AsZOaQfIK/s320/embedded_resource.JPG&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;Mention in your AssemblyInfo.cs file : &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;Mention above this resource in the AssemblyInfo file with the following syntax.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;[assembly: &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;WebResource&lt;/span&gt;(&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;&quot;TestWeb.JavaScripts.common.js&quot;&lt;/span&gt;, &lt;span style=&quot;color: rgb(153, 51, 0);&quot;&gt;&quot;text/javascript&quot;&lt;/span&gt;,PerformSubstitution=&lt;span style=&quot;color: rgb(51, 102, 255);&quot;&gt;true&lt;/span&gt;)]&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;Here the first parameter is the path as fully qualified name from the root namespace, like TestWeb is the root namespace and JavaScripts is the directory and then common.js is the filename. Second parameter is the MIME type for the resource being called. Third parameter tells .net that this resource contains some expression that need to be parsed and replaced with real values. We will discuss this third parameter at the end of the topic.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-weight: bold;font-family:verdana;&quot; &gt;Call the GetWebResourceUrl()&lt;/span&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt; :&lt;/span&gt; &lt;span style=&quot;font-family:verdana;&quot;&gt;To get the URL that can be used to call the embedded resource.&lt;/span&gt; &lt;span style=&quot;font-family:verdana;&quot;&gt;The Url will be in the format&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 51);&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;/PathFromRoot/WebResource.axd?d=P6z37LRwQoHAo_Le8MfO3Q2&amp;amp;t=63338169731478&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;Where &lt;/span&gt;&lt;span style=&quot;font-weight: bold;font-family:verdana;&quot; &gt;d &lt;/span&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;specify the assembly key and &lt;/span&gt;&lt;span style=&quot;font-weight: bold;font-family:verdana;&quot; &gt;t&lt;/span&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt; specify the last time the assembly is written (compiled).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;syntax of GetWebResourceUrl method is&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;GetWebResourceUrl(Type type, &lt;/span&gt;&lt;span style=&quot;color: rgb(51, 102, 255);font-family:courier new;&quot; &gt;string &lt;/span&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;resourceName);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;I have used the following syntax to register the WebResource given javascript :&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 102, 255);font-family:courier new;&quot; &gt;string &lt;/span&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;scriptUrl = ClientScript.GetWebResourceUrl(&lt;/span&gt;&lt;span style=&quot;color: rgb(51, 102, 255);font-family:courier new;&quot; &gt;typeof&lt;/span&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;(_Default), &lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);font-family:courier new;&quot; &gt;&quot;TestWeb.JavaScripts.common.js&quot;&lt;/span&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;ClientScript.RegisterClientScriptInclude(&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);font-family:courier new;&quot; &gt;&quot;Common&quot;&lt;/span&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;, scriptUrl);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;So we are done with how to use WebResource handler.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;Now let&#39;s examine the third parameter of the WebResource attribute we have used above.&lt;br /&gt;Imagine that we want to use another resource (an image) within the JavaScript file we are calling using the WebResource handler. Suppose the javascript is setting &quot;src&quot; of an image and that image is again a WebResource. So we will write something like following in our javascript file&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;document.getElementById(&#39;logo&#39;) = &amp;lt;%= WebResource(&#39;logo.gif&#39;)%&amp;gt;; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;code style=&quot;font-family: courier new;&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;Now if you have mentioned PerformSubstitution=true for the javascript resource then all expressions like above one in your javascript will be replaced by the WebResource handler given url when your javascript will be served like&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;document.getElementById(&#39;logo&#39;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt; = &quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(51, 51, 51);&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;/PathFromRoot/WebResource.axd?d=P6z37LRwQoHAo_Le8MfO3Q2&amp;amp;t=63338169731478&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://pareshjagatia.blogspot.com/feeds/5922168548000216928/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3650981984408352034/5922168548000216928' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3650981984408352034/posts/default/5922168548000216928'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3650981984408352034/posts/default/5922168548000216928'/><link rel='alternate' type='text/html' href='http://pareshjagatia.blogspot.com/2008/05/how-to-embed-resource-and-use-it-with.html' title='How To Embed Resource And Use It With WebResource Handler'/><author><name>Paresh Jagatiya</name><uri>http://www.blogger.com/profile/10850885900014367688</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhn1FUQljdtVC15hVkjmGn9ujrgRQ-ckIUNjzH7NMOXeTfqZK89Ka9wRd5e6PFnu7uEydLZV_H9xkSYlsqN91pWZ9_-2z_fZYfcYX1LrGrS4pb7bIs_1QMYhkugUrjbL4U/s220/parth.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXZ8V72QQdVuxIZ5q73cz4i6L_WhfWJKmj0t_YK80sxEvPVpVNhy1S1qm8RHNjk8OgMjwekqzC_EedD8kw3wWwVUfo-Mh8Xc2KOsxHKLkxlcOWeG9d1nsCx93dhM_A4hbiHl5AsZOaQfIK/s72-c/embedded_resource.JPG" height="72" width="72"/><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3650981984408352034.post-861473003776912125</id><published>2008-05-13T12:05:00.008+05:30</published><updated>2008-09-14T12:58:16.786+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="HTTPHandler"/><title type='text'>Why WebResources</title><content type='html'>&lt;p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;Before we digg into &quot;HOW TO&quot;s about this topic let&#39;s think of &quot;WHY WebResources?&quot; .&lt;/span&gt;&lt;/p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;Have you ever developed a control that uses some JavaScript? or image?. If not then let&#39;s exmine a case where you need to have a TextBox (web custom control) that only accepts digits means you are looking for developing one numeric text box. The quickest thing you will do is you write a class that inherits System.Web.UI.WebControl.TextBox and in that control&#39;s life cycle event you will add an HTML attribute to your control like this.Attributes.Add(&quot;onkeypress&quot;,&quot;javascript : return NumericValidationFunction()&quot;) (think that you are developing this control not only for a single web application you are working with but to provide to others if anyone needs or to sell).&lt;br /&gt;&lt;/span&gt;&lt;p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;Now the JavaScript function mentioned above will be written and stored in a string variable and then registered as a javascript in the PreRender method as&lt;/span&gt;&lt;/p&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;protected&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;override&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt; OnPreRender(EventArgs e) {     &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;   string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt; numericValidationJs &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&amp;lt;script type=&#39;text/javascript&#39;&amp;gt;function NumericValidationFunction() { your custom logic ...}&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;;      &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;.Page.ClientScript.RegisterClientScriptBlock(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;.GetType(), &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;NumericValidationJs&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;, numericValidationJs ,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;); &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;} &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;One disadvantage (not to just supporting this topic but it really is) is that it will be rendered as part of your HTML, embedded in the page HTML itself. It increases your page size (HTML that is being rendered to the browser) and also is HeadAche for search engine spiders. Also if you have set of controls within a single library you, for maintainance purpose, need to have a single place to write this JavaScript instead of writing within each control.&lt;br /&gt;&lt;/span&gt;&lt;p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;Now, based on above reasons you decided to write a &quot;.js&quot; file. The question is to ship this file along with your control library. And if you might have used any image file, for indication that the user has not entered a number, you might also have thought of shipping that image file along with the &quot;.js&quot; file with this assembly.&lt;/span&gt;&lt;/p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;ASP.NET 2.0 provides a very good way to achieve this and it&#39;s recognised as &quot;WebResource handler&quot;. Where you can have your resources (like javascript and image and other resources) embedded within your assembly and then use a URL that calls a file with &quot;.axd&quot; extension which is being served by an HTTPHander that respond you with the resource within the assembly. So you need to ship just one &quot;.dll&quot; file that contains your resources within as embedded resource.&lt;br /&gt;&lt;/span&gt;&lt;p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;Good enough discussion on &quot;WHY&quot; now let&#39;s take a look into &lt;/span&gt;&lt;a href=&quot;http://pareshjagatia.blogspot.com/2008/05/how-to-embed-resource-and-use-it-with.html&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;HOW TO EMBED RESOURCE AND USE IT WITH WEBRESOURCE HANDLER&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;.&lt;/span&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://pareshjagatia.blogspot.com/feeds/861473003776912125/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3650981984408352034/861473003776912125' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3650981984408352034/posts/default/861473003776912125'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3650981984408352034/posts/default/861473003776912125'/><link rel='alternate' type='text/html' href='http://pareshjagatia.blogspot.com/2008/05/using-webresources.html' title='Why WebResources'/><author><name>Paresh Jagatiya</name><uri>http://www.blogger.com/profile/10850885900014367688</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhn1FUQljdtVC15hVkjmGn9ujrgRQ-ckIUNjzH7NMOXeTfqZK89Ka9wRd5e6PFnu7uEydLZV_H9xkSYlsqN91pWZ9_-2z_fZYfcYX1LrGrS4pb7bIs_1QMYhkugUrjbL4U/s220/parth.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3650981984408352034.post-3847753025427216396</id><published>2008-05-12T11:20:00.007+05:30</published><updated>2008-09-14T12:59:22.213+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET"/><category scheme="http://www.blogger.com/atom/ns#" term="HTML"/><title type='text'>ASP.NET HTML Optimization..</title><content type='html'>&lt;p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;Addition to the &lt;/span&gt;&lt;a title=&quot;ViewState Optimization&quot; href=&quot;http://pareshjagatia.blogspot.com/2008/04/viewstate-serialization.html&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;ViewState Optimization&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt; that we already discussed, our further target could be the extra spaces within the HTML that is being rendered for an aspx page.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;No, do not even think of removing all the spaces as that will make the page content unreadablelikethislastwordandthatwedonotwant. But the spaces between the two successive HTML tags (when one ends and another starts) like &amp;lt;/div&amp;gt; &amp;lt;div&amp;gt; can be safely removed and also the \n and \r characters are not useful for the browser.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;We can take care of this spaces while designing the .aspx page itself but if we remove the spaces at design time then further modification to the page will be a nightmare.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;Rather, trap the HTML before it is being sent to the browser and remove those unwanted stuff, and as you might have caught it is the Render method that can be overridden.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;The following code can be used to achieve the above desire...&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;protected&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;override&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt; Render(HtmlTextWriter writer) { &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;StringWriter stringWriter &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt; StringWriter(); &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;HtmlTextWriter interceptedHtmlWriter &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt; HtmlTextWriter(stringWriter, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#800000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#800000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#800000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;); &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;base&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;.Render(interceptedHtmlWriter);&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt; interceptedHtml &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt; stringWriter.ToString(); &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#808080;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;///&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#008000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;/ Remove the newline and tab characters to decrease the filesize&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#808080;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;interceptedHtml &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt; interceptedHtml.Replace(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#800000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#800000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;\n&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#800000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#800000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;).Replace(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#800000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#800000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;\t&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#800000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#800000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;).Replace(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#800000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#800000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;\r&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#800000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#800000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;); &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#808080;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;///&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#008000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;/ removing spaces will result in deformatted text on the page so &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#808080;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;///&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#008000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;/ only remove the spaces between the HTML tags like &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#808080;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&amp;lt;a&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#008000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#808080;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#008000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt; which is fine.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#808080;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;interceptedHtml &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt; Regex.Replace(interceptedHtml, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#800000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#800000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&amp;gt;\\s+&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#800000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#800000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#800000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#800000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;); &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;writer.Write(interceptedHtml); &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;Put the above method in a class (say BasePage) that inherit the System.Web.UI.Page and then inherit your all other pages from this BasePage&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt; &lt;/span&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;IMPORTANT : Make sure your page do not contain embedded javascript with single&lt;br /&gt;line comment. As after removing new line character the following lines to the&lt;br /&gt;line having single line commnent will all be considered as commented lines.&lt;/span&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;Enjoy........&lt;/span&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://pareshjagatia.blogspot.com/feeds/3847753025427216396/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3650981984408352034/3847753025427216396' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3650981984408352034/posts/default/3847753025427216396'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3650981984408352034/posts/default/3847753025427216396'/><link rel='alternate' type='text/html' href='http://pareshjagatia.blogspot.com/2008/05/aspnet-html-optimization.html' title='ASP.NET HTML Optimization..'/><author><name>Paresh Jagatiya</name><uri>http://www.blogger.com/profile/10850885900014367688</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhn1FUQljdtVC15hVkjmGn9ujrgRQ-ckIUNjzH7NMOXeTfqZK89Ka9wRd5e6PFnu7uEydLZV_H9xkSYlsqN91pWZ9_-2z_fZYfcYX1LrGrS4pb7bIs_1QMYhkugUrjbL4U/s220/parth.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3650981984408352034.post-5535363768816338929</id><published>2008-05-10T14:26:00.010+05:30</published><updated>2008-09-14T13:01:48.534+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Sql Server Reporting"/><category scheme="http://www.blogger.com/atom/ns#" term="SSRS"/><title type='text'>Using Custom Assembly in Sql Server Reporting Services (SSRS).</title><content type='html'>&lt;p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;There are times when one needs to have something that is not already available in Sql Server Reporting Services.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;I too had one requirement to have custom Localization implementation for the static labels in a report. I had to fetch Localized data based on the UserID parameter (which is MUST for every report I had as all the reports were User specific.).&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;Let&#39;s look into details how I did that.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;color: rgb(0, 0, 128);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;Give it a thought First !!&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;I did the same, I knew I had to use &lt;/span&gt;&lt;strong&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;expression &lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;so I assumed I would use something like&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;=Code.RptUtils.GetValue(&quot;LabelKey&quot;,Parameters!UserID.Value,&quot;DefaultText&quot;).&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;WHERE&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;Code = Globally defined member through which Instance methods from our assembly are available. (We would not have used this keyword if we had written static methods.)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;RptUtils = Instance of the class in our assembly.(This one also is there because we had not written static method).&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;GetValue = method about which I mentioned above. ( Additional to it, this function returns a string)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;LabelKey = Database field value. My database contains a Key, CountryID, LanguageID, Value pattern to have multilingual values.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;Parameters!UserID.Value = UserID from the Report parameter.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;DefaultText = If the value is not found in database then show this value.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;color: rgb(0, 0, 128);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;Let&#39;s Start : &lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;Create a class library project and name it as you desire. I named it ReportUtilities. And add a class that is going to help us getting multilingual values that is MLHelper.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;Create a method that looks like following.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color:gray;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;/// &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;This method is used to fetch the Resource value from the database.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:gray;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;/// &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;The method will be used by the SSRS report.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:gray;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;/// &amp;lt;param name=&quot;key&quot;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Key of the resource&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:gray;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;param name=&quot;userId&quot;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;specific UserID to fetch the resource&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span style=&quot;color:gray;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;/// &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;value for.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:gray;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;returns&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Resource value as string if found, Key enclosed&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span style=&quot;color:gray;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;/// &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;in square brackets otherwise.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:gray;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;lt;/returns&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;PermissionSet&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;SecurityAction&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;.Assert, Unrestricted = &lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;)]&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;public string &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;GetValue(&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;string &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;key, &lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;string &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;userId, &lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt; defaultText)&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;// Set initial value for the resource .&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;string &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;returnValue = defaultText;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;try&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;using &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;SqlConnection &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;_con = &lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;new &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;SqlConnection&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;(&lt;br /&gt;                         &lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;DatabaseHelper&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;.ConnectionString&lt;br /&gt;                        )&lt;br /&gt;)&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;/&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;/ DatabaseHelper is a class containing the constant string that holds the Sql connection string.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;using &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;(&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;SqlCommand &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;_cmd = &lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;new &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;SqlCommand&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;(&lt;br /&gt;                    &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&quot;[Internationalization].[GetResourceValue]&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;,&lt;br /&gt;                    _con)&lt;br /&gt;)&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;SqlParameter&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;[] _params = &lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;new &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;SqlParameter&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;[2];&lt;br /&gt;_params[0] = &lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;new &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;SqlParameter&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;();&lt;br /&gt;_params[0].ParameterName = &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&quot;@Key&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;if &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;(!&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;.IsNullOrEmpty(key))&lt;br /&gt;{&lt;br /&gt;_params[0].Value = key;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;else&lt;br /&gt;throw new &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Exception&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&quot;The Key must not be blank.&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;);&lt;br /&gt;_params[1] = &lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;new &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;SqlParameter&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;();&lt;br /&gt;_params[1].ParameterName = &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&quot;@UserID&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;if &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;(!&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;.IsNullOrEmpty(userId))&lt;br /&gt;{&lt;br /&gt;_params[1].Value = System.Data.SqlTypes.&lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;SqlGuid&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;.Parse(userId);&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;else&lt;br /&gt;throw new &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Exception&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&quot;The UserID must not be blank.&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;);&lt;br /&gt;_cmd.Parameters.Add(_params[0]);&lt;br /&gt;_cmd.Parameters.Add(_params[1]);&lt;br /&gt;_con.Open();&lt;/span&gt;&lt;/pre&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color:green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;// I have a stored proc to get multilingual value from the database&lt;br /&gt;// based on the UserID and the Key passed to it.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;_cmd.CommandType = System.Data.&lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;CommandType&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;.StoredProcedure;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;object &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;objResourceValue = _cmd.ExecuteScalar();&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;if &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;(objResourceValue != &lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;)&lt;br /&gt;{&lt;br /&gt;returnValue = objResourceValue.ToString();&lt;br /&gt;}&lt;br /&gt;_con.Close();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;catch&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;// if anything goes wrong....the default text will be set on the label.&lt;br /&gt;// Or you may want to handle it differently.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;return &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;returnValue;&lt;br /&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;Compile it to an assembly and it is ready to be hosted.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;color: rgb(0, 64, 128);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;Host It&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;Hosting is just copy the DLL from your class library&#39;s Bin to&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies ( for the developement machine on which you are designing and testing the report).&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;For SSRS 2005 (Reporting Host machine), the default is C:\Program Files\Microsoft SQL Server\MSSQL.n\Reporting Services\ReportServer\bin.&lt;/span&gt;&lt;/li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/ul&gt;&lt;strong&gt;&lt;span style=&quot;color: rgb(0, 64, 128);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;Use It&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;Goto ReportProperties &amp;gt;&amp;gt; References and select the assembly&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://lh4.ggpht.com/paresh.m.jagatia/SCV_cyNT8bI/AAAAAAAAACQ/1FL7S4alPHQ/rpt1%5B19%5D.jpg&quot;&gt;&lt;img style=&quot;border: 0px none ;&quot; alt=&quot;rpt1&quot; src=&quot;http://lh6.ggpht.com/paresh.m.jagatia/SCV_gSNT8cI/AAAAAAAAACY/ukK6HOAku9c/rpt1_thumb%5B15%5D.jpg&quot; border=&quot;0&quot; height=&quot;401&quot; width=&quot;452&quot; /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;After the assembly is added we can use it in two ways depending upon the type of member we are using.&lt;/span&gt;&lt;/p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;If we are using static member (if our method GetValue is static) we can directly access it using the full qualified member name from the root namespace like&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;=ReportUtilities.MLHelper.GetValue(.....)&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;For the Instance (non static) members we need to alias the class. For this look at the classes section in above image. Mention the fully qualified class name into the Class name section and alias it in the InstanceName section. And then it can be used as&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;blockquote&gt;&lt;p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;=Code.RptUtils.GetValue(.....)&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;As we have Instance method &quot;GetValue&quot; we will follow the later one from above.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;Right click the label you want to write expression for and put the following text&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;=Code.RptUtils.GetValue(&quot;LabelKeyYouHaveDefined&quot;,Parameters!UserID.Value,&quot;First Name&quot;)&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;color: rgb(0, 0, 128);&quot;&gt;D&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;oes it really work ??&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;Yes, when you run the report in the Visual Studio&#39;s Reporting project ( means in the design environment).&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;No, on the report server when you host the assembly in the&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;C:\Program Files\Microsoft SQL Server\MSSQL.n\Reporting Services\ReportServer\bin. and it gives &quot;#Error&quot; instead of what you wanted.&lt;/span&gt;&lt;/ul&gt;&lt;p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;Why?? Because of the security. When you run the report within the report designer (Visual Studio), the Visual Studio runs under the logged in user&#39;s context and as the logged in user has the rights it runs properly.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;On the Reporting server the report is running under the ASP.NET&#39;s account so it requires the permission.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;If the custom assembly needs permissions in addition to the Execution permission we need to mention it in the ReportServer&#39;s rssrvpolicy.config file located at C:\Program Files\Microsoft SQL Server\MSSQL.4\Reporting Services\ReportServer\. Open the file and put the following CodeGroup stuff&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;CodeGroup &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;=&quot;UnionCodeGroup&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;br /&gt;version&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;=&quot;1&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;br /&gt;PermissionSetName&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;=&quot;FullTrust&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;br /&gt;Name&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;=&quot;YourCustomCodeGroup&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;br /&gt;Description&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;=&quot;For the Custom assembly of Demo&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;IMembershipCondition&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;=&quot;UrlMembershipCondition&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;br /&gt;version&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;=&quot;1&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;br /&gt;Url&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;=&quot;C:\Program Files\Microsoft SQL Server\MSSQL.4\Reporting Services\ReportServer\bin\ReportUtilities.dll&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;CodeGroup&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;Now you are ready to go...!! Congratulations you have done it....!!!&lt;br /&gt;Find more on SSRS on &lt;/span&gt;&lt;a href=&quot;http://patelnirav.blogspot.com/&quot; rel=&quot;nofollow&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;Nirav Patel&#39;s Weblog&lt;/span&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://pareshjagatia.blogspot.com/feeds/5535363768816338929/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3650981984408352034/5535363768816338929' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3650981984408352034/posts/default/5535363768816338929'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3650981984408352034/posts/default/5535363768816338929'/><link rel='alternate' type='text/html' href='http://pareshjagatia.blogspot.com/2008/05/using-custom-assembly-in-sql-server.html' title='Using Custom Assembly in Sql Server Reporting Services (SSRS).'/><author><name>Paresh Jagatiya</name><uri>http://www.blogger.com/profile/10850885900014367688</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhn1FUQljdtVC15hVkjmGn9ujrgRQ-ckIUNjzH7NMOXeTfqZK89Ka9wRd5e6PFnu7uEydLZV_H9xkSYlsqN91pWZ9_-2z_fZYfcYX1LrGrS4pb7bIs_1QMYhkugUrjbL4U/s220/parth.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh6.ggpht.com/paresh.m.jagatia/SCV_gSNT8cI/AAAAAAAAACY/ukK6HOAku9c/s72-c/rpt1_thumb%5B15%5D.jpg" height="72" width="72"/><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3650981984408352034.post-2714870957581168528</id><published>2008-05-03T14:09:00.008+05:30</published><updated>2008-09-14T13:03:40.125+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="ReportViewer"/><category scheme="http://www.blogger.com/atom/ns#" term="ReportViewer Export PDF"/><category scheme="http://www.blogger.com/atom/ns#" term="Sql Server Reporting"/><category scheme="http://www.blogger.com/atom/ns#" term="SSRS"/><title type='text'>Export ReportViewer Report to PDF, Excel, HTML</title><content type='html'>&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;The following code helps exporting the Report into PDF and Excel formats using the Render method of the ServerReport. Use below code after the report is loaded (refresh() is called on the reportviewer control).&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div  style=&quot;font-family:courier new;&quot;&gt;&lt;span style=&quot;color: rgb(0, 128, 128);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;1&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt; mimeType;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 128);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt; encoding;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 128);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;3&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt; fileNameExtension;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 128);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;4&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;  Warning[] warnings;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 128);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;5&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;[] streamids;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 128);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;6&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;byte&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;[] exportBytes &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt; reportViewer.ServerReport.Render(&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&quot;&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;PDF&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;out&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt; mimeType, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;out&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt; encoding, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;out&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt; fileNameExtension, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;out&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt; streamids, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;out&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt; warnings);&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 128);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;7&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;  HttpContext.Current.Response.Buffer &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 128);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;8&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;  HttpContext.Current.Response.Clear();&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 128);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;9&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;  HttpContext.Current.Response.ContentType &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt; mimeType;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 128);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;10&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;  HttpContext.Current.Response.AddHeader(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;content-disposition&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;attachment; filename=ExportedReport.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt; fileNameExtension);&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 128);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;11&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;  HttpContext.Current.Response.BinaryWrite(exportBytes);&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 128);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;12&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;  HttpContext.Current.Response.Flush();&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 128);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;13&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;  HttpContext.Current.Response.End();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div  style=&quot;color: rgb(0, 0, 0);font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;To get Excel file use &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&quot;&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;Excel&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&quot; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;as the parameter in the Render method.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div face=&quot;verdana&quot; style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;Sometimes you might need to send the Report content into email. To Achieve this you can use the above code where you need to pass &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&quot;&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;HTML4.0&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&quot; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;as the first parameter to the Render method. After you get the byte array from the Render method you can convert it to string as below&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div  style=&quot;font-family:courier new;&quot;&gt;&lt;span style=&quot;color: rgb(0, 128, 128);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;1&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt; mimeType;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 128);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt; encoding;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 128);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;3&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;  Warning[] warnings;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 128);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;4&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;[] streamids;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 128);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;5&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt; fileNameExtension;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 128);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;6&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;byte&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;[] htmlBytes &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt; MyReportViewer.ServerReport.Render(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;HTML4.0&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;out&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt; mimeType, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;out&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt; encoding, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;out&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt; fileNameExtension, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;out&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt; streamids, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;out&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt; warnings);&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 128);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;7&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt; reportHtml &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt; System.Text.Encoding.UTF8.GetString(htmlBytes);&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 128);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;8&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt; reportHtml;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:100%;&quot;&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;Enjoy......&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://pareshjagatia.blogspot.com/feeds/2714870957581168528/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3650981984408352034/2714870957581168528' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3650981984408352034/posts/default/2714870957581168528'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3650981984408352034/posts/default/2714870957581168528'/><link rel='alternate' type='text/html' href='http://pareshjagatia.blogspot.com/2008/05/export-reportviewer-report-to-pdf-excel.html' title='Export ReportViewer Report to PDF, Excel, HTML'/><author><name>Paresh Jagatiya</name><uri>http://www.blogger.com/profile/10850885900014367688</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhn1FUQljdtVC15hVkjmGn9ujrgRQ-ckIUNjzH7NMOXeTfqZK89Ka9wRd5e6PFnu7uEydLZV_H9xkSYlsqN91pWZ9_-2z_fZYfcYX1LrGrS4pb7bIs_1QMYhkugUrjbL4U/s220/parth.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3650981984408352034.post-8877645182699289988</id><published>2008-05-01T19:09:00.008+05:30</published><updated>2008-05-31T20:37:50.356+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="FavIcon"/><category scheme="http://www.blogger.com/atom/ns#" term="HTTP 404"/><title type='text'>Save HTTP 404</title><content type='html'>&lt;span style=&quot;font-family:verdana;&quot;&gt;Once I had a call from my boss saying &quot;Can you tell me if we have used any Favicon file in our website in any page or somewhere? As if we have used it, the file is not in place. Look at this IIS log it is full of 404s for the same file.&quot;. And I was absolutely blank about this name. I opened the project and fired &quot;Find in solution&quot; but did not get any FavIcon reference.&lt;br /&gt;&lt;br /&gt;Huh, a file that is not referenced anywhere in your website and still your IIS has 404 enteries? Later on I came to know that this is the file that is being shown into the address bar and in the favourites list in most browsers. More information about FavIcon can be found &lt;/span&gt;&lt;a href=&quot;http://www.favicon.com/&quot; rel=&quot;nofollow&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;here&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;. And be sure to keep the Favicon file small in size to avoid high bandwidth usage, check this out on &lt;a href=&quot;http://www.hanselman.com/blog/FavIconicoCanBeABandwidthHog.aspx&quot; rel=&quot;nofollow&quot;&gt;Scott&#39;s Blog&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;But keep this file atleast to save 404 in your IIS log. One other file is &lt;/span&gt;&lt;a href=&quot;http://www.robotstxt.org/&quot; rel=&quot;nofollow&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;Robots.txt&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt; that, I am not pretty sure, puts 404 in your IIS log when not found by the crawlers. You can check it out.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://pareshjagatia.blogspot.com/feeds/8877645182699289988/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3650981984408352034/8877645182699289988' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3650981984408352034/posts/default/8877645182699289988'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3650981984408352034/posts/default/8877645182699289988'/><link rel='alternate' type='text/html' href='http://pareshjagatia.blogspot.com/2008/05/save-http-404.html' title='Save HTTP 404'/><author><name>Paresh Jagatiya</name><uri>http://www.blogger.com/profile/10850885900014367688</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhn1FUQljdtVC15hVkjmGn9ujrgRQ-ckIUNjzH7NMOXeTfqZK89Ka9wRd5e6PFnu7uEydLZV_H9xkSYlsqN91pWZ9_-2z_fZYfcYX1LrGrS4pb7bIs_1QMYhkugUrjbL4U/s220/parth.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3650981984408352034.post-4558542132369073807</id><published>2008-05-01T18:21:00.007+05:30</published><updated>2008-05-31T20:39:11.693+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="HTML"/><title type='text'>Safer Email Address</title><content type='html'>&lt;span style=&quot;font-family:verdana;&quot;&gt;Direct email addresses used in the website are supposed to be caught by the mail bots that capture the email addresses from the website. But as the browsers support ascii display (&amp;amp;#ASCII CODE) we can use them so if the mail capturing program captures this encoded address (which is also difficult for them as they try to find mailto: which they won&#39;t get) it will not be useful to them unless they decode it. There are mail capture programs that know this alternative but most of them are not written considering this case.&lt;br /&gt;To see how ascii character display is supported just paste the following code to any html or aspx page and browse it &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&amp;lt;a href=&quot;&amp;amp;#109&amp;amp;#97&amp;amp;#105&amp;amp;#108&amp;amp;#116&amp;amp;#111&amp;amp;#58&amp;amp;#97&amp;amp;#98&amp;amp;#99&lt;br /&gt;&amp;amp;#64&amp;amp;#97&amp;amp;#98&amp;amp;#99&amp;amp;#46&amp;amp;#99&amp;amp;#111&amp;amp;#109&quot;&amp;gt; &amp;amp;#97&amp;amp;#98&amp;amp;#99&amp;amp;#64&amp;amp;#97&amp;amp;#98&amp;amp;#99&amp;amp;#46&amp;amp;#99&amp;amp;#111&amp;amp;#109&amp;lt; /a&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;you can even try to click the link to send email it will get the correct email address to the mail client. And also view the page source for double check the email address is ascii encoded.&lt;br /&gt;So this conversion code (just loop through the characters in email address and build a string consisting of [&quot;&amp;amp;#&quot; + ascii code of character] that is &quot;&amp;amp;#97&quot; = &quot;a&quot; of email address.) can also be put in the overridden method PreRender to secure the emails in the page if it has any.&lt;br /&gt;&lt;br /&gt;This is for the text emails otherwise the image emails are good and there are lot of online tools that makes the image email addresses for you.&lt;br /&gt;&lt;br /&gt;Happy Programming...!!!&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://pareshjagatia.blogspot.com/feeds/4558542132369073807/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3650981984408352034/4558542132369073807' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3650981984408352034/posts/default/4558542132369073807'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3650981984408352034/posts/default/4558542132369073807'/><link rel='alternate' type='text/html' href='http://pareshjagatia.blogspot.com/2008/05/safer-email-address.html' title='Safer Email Address'/><author><name>Paresh Jagatiya</name><uri>http://www.blogger.com/profile/10850885900014367688</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhn1FUQljdtVC15hVkjmGn9ujrgRQ-ckIUNjzH7NMOXeTfqZK89Ka9wRd5e6PFnu7uEydLZV_H9xkSYlsqN91pWZ9_-2z_fZYfcYX1LrGrS4pb7bIs_1QMYhkugUrjbL4U/s220/parth.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3650981984408352034.post-6683520784553769049</id><published>2008-04-30T18:55:00.008+05:30</published><updated>2008-09-14T13:04:45.931+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="VIEWSTATE"/><title type='text'>VIEWSTATE Serialization</title><content type='html'>&lt;p style=&quot;FONT-FAMILY: verdana&quot;&gt;The most important thing for an end user of a website is the how fast the page loads and our responsibility is to make them happy.&lt;/p&gt;&lt;p style=&quot;FONT-FAMILY: verdana&quot;&gt;Frequent thing to achieve this is to review the code and write the code such a way that it performs better (in terms of processing time) but what after this ?&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;FONT-FAMILY: verdana&quot;&gt;What if we still can increase the page serving speed. Apart from the code performance it is the ISP&#39;s speed and the size of the page that affects the download speed for a web page.&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;FONT-FAMILY: verdana&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;FONT-FAMILY: verdana&quot;&gt;what if we can decrease the size of the page to some extent ( the size generated after the server side scripting finishes ( i mean the final rendered output)&lt;/p&gt;&lt;p style=&quot;FONT-FAMILY: verdana&quot;&gt;for every server control if it&#39;s ViewState is enabled the data is kept in a viewstate in some encoded format(base64 encoded string as everyone says.)&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;FONT-FAMILY: verdana&quot;&gt;wo when showing a control on a page keeps data in the rendered output of control as well in the viewstate along with the&lt;/p&gt;&lt;p style=&quot;FONT-FAMILY: verdana&quot;&gt;state ( previous state) information ( doubles the size of final rendered output..!!)&lt;/p&gt;&lt;p style=&quot;FONT-FAMILY: verdana&quot;&gt;straighaway coming to the topic we can have this &lt;a rel=&quot;nofollow&quot; href=&quot;http://weblogs.asp.net/infinitiesloop/archive/2006/08/03/Truly-Understanding-Viewstate.aspx&quot; target=&quot;_blank&quot;&gt;VIEWSTATE&lt;/a&gt; buddy help us remotely ( not being rendered with the page so by decreasing the final rendered page out put size)&lt;/p&gt;&lt;p style=&quot;FONT-FAMILY: verdana&quot;&gt;This can be done keeping the &lt;a rel=&quot;nofollow&quot; href=&quot;http://weblogs.asp.net/infinitiesloop/archive/2006/08/03/Truly-Understanding-Viewstate.aspx&quot; target=&quot;_blank&quot;&gt;VIEWSTATE&lt;/a&gt; in the session or keep it at the server. I am keeping it at the web server as I have got the access to the web server and I have developed one web service that deletes files(holding the &lt;a rel=&quot;nofollow&quot; href=&quot;http://weblogs.asp.net/infinitiesloop/archive/2006/08/03/Truly-Understanding-Viewstate.aspx&quot; target=&quot;_blank&quot;&gt;VIEWSTATE&lt;/a&gt; on the web server) after a day. In short its upto you to write code into the &lt;strong&gt;SaveViewState&lt;/strong&gt; and &lt;strong&gt;GetViewState&lt;/strong&gt; methods.&lt;/p&gt;&lt;p style=&quot;FONT-FAMILY: verdana&quot;&gt;try the following code snippet ( just paste it in the code behind file of your aspx page)&lt;/p&gt;&lt;div dir=&quot;ltr&quot; align=&quot;left&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;249403112-31082005&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;span&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;protected override object&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt; LoadPageStateFromPersistenceMedium()&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;object&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt; _objViewState;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt; _strViewState;&lt;br /&gt;_strViewState = GetViewState();&lt;br /&gt;LosFormatter _lFormater = &lt;/span&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt; LosFormatter();&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;try&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;{&lt;br /&gt;//if(_strViewState!=String.Empty)&lt;br /&gt;_objViewState = _lFormater.Deserialize(_strViewState);&lt;br /&gt;//else&lt;br /&gt;//_objViewState=&quot;&quot;;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;catch&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;throw new&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt; HttpException(&quot;Invalid ViewState&quot;);&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt; _objViewState;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;protected override void&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt; SavePageStateToPersistenceMedium(&lt;/span&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;object&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt; viewState)&lt;br /&gt;{&lt;br /&gt;StringBuilder _sBuilder = &lt;/span&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt; StringBuilder();&lt;br /&gt;StringWriter _sWriter = new StringWriter(_sBuilder);&lt;br /&gt;LosFormatter _lFormater = new LosFormatter();&lt;br /&gt;_lFormater.Serialize(_sWriter,viewState);&lt;br /&gt;_sWriter.Close();&lt;br /&gt;SaveViewState(_sBuilder.ToString());&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;249403112-31082005&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;span&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;#region&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt; Save and Get ViewStateData&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;private void&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt; SaveViewState(&lt;/span&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt; _vState)&lt;br /&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; align=&quot;left&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;// keep identicle files user-wise ( byadding sessionid) and page wise (for different pages by aading this.toString())&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;249403112-31082005&quot;  style=&quot;font-family:courier new;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt; _file = @Request.ServerVariables[&quot;APPL_PHYSICAL_PATH&quot;]+Session.SessionID+this.ToString()+&quot;.txt&quot;;&lt;br /&gt;FileStream _fS = new FileStream(_file,System.IO.FileMode.OpenOrCreate,System.IO.FileAccess.ReadWrite,System.IO.FileShare.ReadWrite);&lt;br /&gt;StreamWriter _sW = new StreamWriter(_fS);&lt;br /&gt;_sW.Write(_vState);&lt;br /&gt;_sW.Close();&lt;br /&gt;_fS.Close();&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;private string&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt; GetViewState()&lt;br /&gt;{&lt;br /&gt;string _file = @Request.ServerVariables[&quot;APPL_PHYSICAL_PATH&quot;]+Session.SessionID+this.ToString()+&quot;.txt&quot;;&lt;br /&gt;string _retValue=String.Empty;&lt;br /&gt;if(File.Exists(_file))&lt;br /&gt;{&lt;br /&gt;StreamReader _sRead = new StreamReader(_file);&lt;br /&gt;_retValue= _sRead.ReadToEnd();&lt;br /&gt;_sRead.Close();&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt; _retValue;&lt;br /&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;p style=&quot;FONT-FAMILY: verdana&quot;&gt;happy programming..........&lt;/p&gt;&lt;p style=&quot;FONT-FAMILY: verdana&quot;&gt;one more thing not to forget if you are using above code and storing the &lt;a rel=&quot;nofollow&quot; href=&quot;http://weblogs.asp.net/infinitiesloop/archive/2006/08/03/Truly-Understanding-Viewstate.aspx&quot; target=&quot;_blank&quot;&gt;VIEWSTATE&lt;/a&gt; on web server in files.&lt;/p&gt;&lt;p style=&quot;FONT-FAMILY: verdana&quot;&gt;keep a code in your Session_End in the global.asax.cs file (works when your Session State uses InProc mode) to remove the above files to keep the web-server tension free !!!&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://pareshjagatia.blogspot.com/feeds/6683520784553769049/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3650981984408352034/6683520784553769049' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3650981984408352034/posts/default/6683520784553769049'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3650981984408352034/posts/default/6683520784553769049'/><link rel='alternate' type='text/html' href='http://pareshjagatia.blogspot.com/2008/04/viewstate-serialization.html' title='VIEWSTATE Serialization'/><author><name>Paresh Jagatiya</name><uri>http://www.blogger.com/profile/10850885900014367688</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhn1FUQljdtVC15hVkjmGn9ujrgRQ-ckIUNjzH7NMOXeTfqZK89Ka9wRd5e6PFnu7uEydLZV_H9xkSYlsqN91pWZ9_-2z_fZYfcYX1LrGrS4pb7bIs_1QMYhkugUrjbL4U/s220/parth.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3650981984408352034.post-5698951473251512752</id><published>2008-04-30T14:34:00.010+05:30</published><updated>2008-09-14T13:05:38.607+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="C# Pre Processor Directives"/><title type='text'>C# Pre Processor Directives</title><content type='html'>&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;One of the good features of C# that we rarely use are the Pre Processor directives. Let&#39;s see how we can use them for us.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;In general practice, we always write some test code in the application. As in JavaScript we use temporary alerts, in C# code behind too (or even in class library project) we use test code like temporary emailing and writing hardcode emails in the application emails. And very often this kind of code goes to production machine that is undesirable as well disastrous. To avoid this we can use the conditional compilation directives. Let&#39;s see how to use them&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;We are going to use three directives &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;#define&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;#if&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;#endif&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;. We can define the symbol in a file using the &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;#define&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt; directive like&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;#define&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt; TESTCODE (this will define a symbol named TESTCODE)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;And then we can write our test code within the conditional compilation &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;#if&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt; directive as below&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;#if&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt; TESTCODE (if the TESTCODE symbol is defined using the &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;#define&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt; then true, false otherwise)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;// Test Code goes here.....&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;#endif&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;Also this is a very good way to handle multiple environments like in one project we had three environments like DEVELOPER, STAGE, PRODUCTION and we also had different databases. Now it may happen that we do not want the test data in our production database so that we can define these three symbols and then in the function returning the connection string we can conditionally return the appropriate connection string as below&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;internal string&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt; GetConnectionString() { &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;string conStr = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;COLOR: rgb(163,21,21)&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;#if&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt; DEVELOPEMENT&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:gray;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;conStr = &quot;development database connection string&quot;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;#endif&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;#if&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt; STAGE&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:gray;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;conStr = &quot;Stage database connection string&quot;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;#endif&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;#if&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt; PRODUCTION&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:gray;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;conStr = &quot;Production database connection string&quot;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;#endif&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;return conStr;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;HOW TO DEFINE: &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;So now only if you have the above line (#define TESTCODE) in your file the above conditional code will compile, not otherwise. So in case you do not want the test code to be moved to the production environment dll then just go to the file and remove the #define TESTCODE.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;These conditional compilation symbols can be defined at file level or the project level. To define it at file level we can put the #define SYMBOLNAME in the file itself. To define the project level symbol follow the below steps.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;Right click the .csproj (project file) -&gt; click Properties -&gt; go to Build tab -&gt; find the Conditional compilation symbol and write the symbols in the text boxes. Multiple symbols can be separated by comma.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;Now in ASP.NET 2.0 website this can be in the web.config file too as below&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:brown;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;system.codedom&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:brown;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;compilers&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:brown;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;compiler &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:red;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;language&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;=&quot;c#;cs;csharp&quot; extension=&quot;.cs&quot;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:red;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;type&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;=&quot;Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0,&lt;br /&gt;Culture=neutral, PublicKeyToken=b77a5c561934e089&quot;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:red;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;compilerOptions&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;=&quot;/d:SYMBOL1,SYMBOL2&quot;/&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:brown;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;/compilers&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:brown;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;/system.codedom&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;USE &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;#warning&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt; AND &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;#error&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt; IN CODE REVIEW:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;Two other important directives are &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;#warning&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt; and &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;#error. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;Let us see how can we use them. These directives can be used while reviewing the code. As when some senior programming guy reviewing the code and if he find some better alternative for a piece of code he/she can put a warning there like &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;#warning&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt; Method implemented incorrectly. Do not use static variables.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;So whenever the code is compiled, we will find the above warning in the output window and the Error list window. If we find some bad code that is written wrongly then we can put #error MESSAGE so that the code will not be compiled ant the message will be shown in the output and the Error list window&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://pareshjagatia.blogspot.com/feeds/5698951473251512752/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3650981984408352034/5698951473251512752' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3650981984408352034/posts/default/5698951473251512752'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3650981984408352034/posts/default/5698951473251512752'/><link rel='alternate' type='text/html' href='http://pareshjagatia.blogspot.com/2008/04/c-pre-processor-directives.html' title='C# Pre Processor Directives'/><author><name>Paresh Jagatiya</name><uri>http://www.blogger.com/profile/10850885900014367688</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhn1FUQljdtVC15hVkjmGn9ujrgRQ-ckIUNjzH7NMOXeTfqZK89Ka9wRd5e6PFnu7uEydLZV_H9xkSYlsqN91pWZ9_-2z_fZYfcYX1LrGrS4pb7bIs_1QMYhkugUrjbL4U/s220/parth.jpg'/></author><thr:total>1</thr:total></entry></feed>