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

<channel>
	<title>Tech Insight ! &#187; .Net 2.0</title>
	<atom:link href="http://techinsight.dhanashree.com/category/net-2-0/feed/" rel="self" type="application/rss+xml" />
	<link>http://techinsight.dhanashree.com</link>
	<description>Technical blog on ASP.Net, PHP, Web Development, Web hosting , Database Programming</description>
	<lastBuildDate>Fri, 12 Aug 2011 07:26:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Copy Tables and Data using SMO (Sql Server Management Object) in asp.net</title>
		<link>http://techinsight.dhanashree.com/copy-tables-and-data-using-smo-sql-server-management-object-in-asp-net/</link>
		<comments>http://techinsight.dhanashree.com/copy-tables-and-data-using-smo-sql-server-management-object-in-asp-net/#comments</comments>
		<pubDate>Wed, 22 Jun 2011 10:16:17 +0000</pubDate>
		<dc:creator>jatin</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[SQL server 2005]]></category>
		<category><![CDATA[SMO]]></category>
		<category><![CDATA[SQLServer]]></category>

		<guid isPermaLink="false">http://techinsight.dhanashree.com/?p=268</guid>
		<description><![CDATA[SMO (Sql Server Management Object) can be used in .net application for dealing with database objects like table, stored procedure, views, and functions.
Basically you have to use “Microsoft.SqlServer.Management.Smo” namespace to use its classes in your application.
Additionally you need to use Microsoft.SqlServer.Management.Sdk.Sfc  assembly.
I have used following assemblies for this sample code:
using System.Data;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Sdk.Sfc;
using [...]]]></description>
			<content:encoded><![CDATA[<p>SMO (Sql Server Management Object) can be used in .net application for dealing with database objects like table, stored procedure, views, and functions.</p>
<p>Basically you have to use “Microsoft.SqlServer.Management.Smo” namespace to use its classes in your application.</p>
<p>Additionally you need to use Microsoft.SqlServer.Management.Sdk.Sfc  assembly.</p>
<p>I have used following assemblies for this sample code:</p>
<p>using System.Data;<br />
using Microsoft.SqlServer.Management.Common;<br />
using Microsoft.SqlServer.Management.Smo;<br />
using Microsoft.SqlServer.Management.Sdk.Sfc;<br />
using smo = Microsoft.SqlServer.Management.Smo;</p>
<p>Following code mentions use of SMO to copy tables and data.</p>
<p>/* SOURCE Database */<br />
string myDBServer = &#8220;sourceDBServer&#8221;;<br />
string myDBUsername = &#8220;testuser&#8221;;<br />
string myDBPassword = &#8220;password&#8221;;<br />
string myDBDatabase = &#8220;firstDB&#8221;;<br />
//</p>
<p>/* DESTINATION Database */<br />
string destServer = &#8220;destinationDBServer&#8221;;<br />
string destLogin = &#8220;testuser&#8221;;<br />
string destPassword = &#8220;password&#8221;;<br />
string destDatabase = &#8220;targetDB&#8221;;<br />
//</p>
<p>ServerConnection con = new ServerConnection(myDBServer, myDBUsername, myDBPassword);<br />
smo.Server sqlServer = new smo.Server(con);<br />
Database db = sqlServer.Databases[myDBDatabase];</p>
<p>Transfer transfer = new Transfer(db);<br />
transfer.CopyAllUsers = true;<br />
transfer.CreateTargetDatabase = false;<br />
transfer.CopyAllObjects = false;<br />
transfer.CopyAllTables = true;<br />
transfer.CopyData = true;<br />
transfer.Options.WithDependencies = true;<br />
transfer.Options.DriAll = true;<br />
transfer.Options.ContinueScriptingOnError = false;</p>
<p>//use following code if want to create destination databaes runtime<br />
/*<br />
ServerConnection destConnection = new ServerConnection(destServer, destLogin, destPassword);<br />
Server destServerObj = new Server(destConnection);<br />
Database newdb = new Database(destServerObj, destDatabase);<br />
newdb.Create();<br />
transfer.CreateTargetDatabase = true;<br />
*/<br />
transfer.CreateTargetDatabase = false;<br />
transfer.DestinationLoginSecure = true;<br />
transfer.DestinationServer = destServer;<br />
transfer.DestinationLogin = destLogin;<br />
transfer.DestinationPassword = destPassword;<br />
transfer.DestinationDatabase = destDatabase;<br />
transfer.ScriptTransfer();<br />
transfer.TransferData();</p>
<p>Personally I think aobve programm is very usefull when we need to take backup SQL Server database.</p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="color: red;" lang="EN-IN"><span style="font-size: 11pt;"><br />
<span style="font-family: Calibri;">NOTE<span style="mso-spacerun: yes;"> </span>: Also visit <a href="http://www.dhanashree.com">www.dhanashree.com</a></span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;"><br />
If you are in need of any </span><a href="http://dhanashree.com/web-development-services/asp-php-web-development" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">Web Development</span></a><span style="font-size: 11pt; font-family: Calibri;"> feel free to <span style="text-decoration: underline;"><a href="http://dhanashree.com/contact-web-designing-company" target="_blank">Inquire us</a></span> .<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a></span>. Expertise in <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">Asp.net Development</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/lamp-development-php-web-designing" target="_blank">Php Development</a></span>,<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><br />
<a href="http://dhanashree.com/web-development-services/website-designing" target="_blank">Website designing</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/open-source-wordpress-joomla-oscommerce-customisation" target="_blank">Open Source customisation</a></span>. <span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a> </span>can be our <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/offshore-website-designing-company" target="_blank">offshore development company</a></span> / </span><a href="http://dhanashree.com/web-designing-outsource-advantages" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">outsourcing</span></a><span style="font-size: 11pt; font-family: Calibri;"> <span style="text-decoration: underline;"><a href="http://dhanashree.com/dhanashree-web-development-profile" target="_blank">web development company</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">hire dedicated web programmers</a></span>.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;"><br />
Above information is for knowledge sharing<span style="mso-spacerun: yes;"> </span>if you have problem / issue / suggestion please intimate us with details for proper and prompt action.</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://techinsight.dhanashree.com/copy-tables-and-data-using-smo-sql-server-management-object-in-asp-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Read email from SSL enabled POP3 server</title>
		<link>http://techinsight.dhanashree.com/read-email-from-ssl-enabled-pop3-server/</link>
		<comments>http://techinsight.dhanashree.com/read-email-from-ssl-enabled-pop3-server/#comments</comments>
		<pubDate>Thu, 28 Oct 2010 06:58:18 +0000</pubDate>
		<dc:creator>jatin</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[POP3]]></category>

		<guid isPermaLink="false">http://techinsight.dhanashree.com/?p=240</guid>
		<description><![CDATA[In this article, I will explain you how to read email from POP3 server or read emails from POP3 server which require SSL. Although I have not developed my own library, I prefer to utilize the available resource.
Well, while being in the development, you have very limited time constraint to go and research on POP3 [...]]]></description>
			<content:encoded><![CDATA[<p>In this article, I will explain you how to read email from POP3 server or read emails from POP3 server which require SSL. Although I have not developed my own library, I prefer to utilize the available resource.</p>
<p>Well, while being in the development, you have very limited time constraint to go and research on POP3 and then develop your own component.</p>
<p>It is sometime wise decision to go and do the Googling and find out your requirement.</p>
<p>After all we, as developer should &#8220;do smart work, not hardwork&#8221;.</p>
<p>Anyway, for those who have kind of requirement like reading emails from POP3 server from asp.net, reading email from email server in asp.net etc. Here is the article that you probably find it useful.</p>
<p>Well I had requirement in couple of project where I need to collect emails that are there in particular email&#8217;s Inbox. Earlier I was used to with component &#8220;Indy.Sockets&#8221; component, which really help me to achieve my task.</p>
<p>You may find it from here.</p>
<p><a href="www.indyproject.org/" target="_blank">www.indyproject.org/</a></p>
<p>It is an open source socket library. It supports may protocols like SMTP, POP3, NNTP, HTTP, and many more.</p>
<p>Then in one of the module that I come to develop, I need to read Inbox of a Gmail account…!</p>
<p>Well as you know, Gmail requires SSL.</p>
<p>But the drawback with component is it does not support SSL.</p>
<p>So I discover <a href="http://www.agilecomponents.com/" target="_self">Mailsystem.NET</a>.</p>
<p>MailSystem is a suite of .NET components that provide users with an extensive set of email tools.</p>
<p>I will not explain more in detail on this, rather I will rather just explain how to integrate it and use it.</p>
<p>You can find more information from here..</p>
<p><a href="http://www.agilecomponents.com/" target="_blank">http://www.agilecomponents.com/</a></p>
<p>Once you download it and extract it, you will require to do following steps..</p>
<p>1. Navigate to &#8220;Release&#8221; folder in extracted folder.<br />
2. Find these DLLs: ActiveUp.Net.Mail.dll, ActiveUp.Net.Common.dll, ActiveUp.Net.Dns.dll, ActiveUp.Net.Pop3.dll.<br />
3. Add reference of these DLLs into your project.</p>
<p>Hurray… are almost done with you configuration.</p>
<p>Now, you only just need to develop your script that fetched and read emails from POP3 server.</p>
<p>So for that, here is the readymade script for you J.</p>
<p>public string[] GetSenderEmailsFromPOPServer()</p>
<p>{</p>
<p>Pop3Client pop = new Pop3Client();</p>
<p>System.Collections.Generic.List emails = new System.Collections.Generic.List();</p>
<p>try {</p>
<p>// Connect to the pop3 client</p>
<p>pop.ConnectSsl(SMTPHost, Port, SMTPUserId, SMTPPass);</p>
<p>MessageCollection mc = new MessageCollection();</p>
<p>for (int n = 1; n &lt;= pop.MessageCount; n++) {</p>
<p>Message newMessage = pop.RetrieveMessageObject(n);</p>
<p>//do your stuffs here using newMessage object.</p>
<p>}</p>
<p>} catch (Pop3Exception pexp) {</p>
<p>} finally {</p>
<p>if (pop.IsConnected) {</p>
<p>pop.Disconnect();</p>
<p>}</p>
<p>}</p>
<p>return emails.ToArray();</p>
<p>}</p>
<p>One important part in this script is object initialization.</p>
<p>// Connect to the pop3 client</p>
<p>pop.ConnectSsl(SMTPHost, Port, SMTPUserId, SMTPPass);</p>
<p>As per Gmail, you need to set:</p>
<p>Host: pop.gmail.com</p>
<p>Port: 995</p>
<p>As I told earlier, I want to read email from POP3 server that requires SSL in asp.net.</p>
<p>There are different overloaded constructors that you can use to connect to POP3 server from asp.net.</p>
<p>The library itself is very rich. You can achieve following functionality with POP3 server.</p>
<ul>
<li>Read/Read email from POP3 server in asp.net with CRAM authentication.</li>
<li>Retrieve/Read email from POP3 server in asp.net asynchronously.</li>
<li>Retrieve/Read email from POP3 server in asp.net with secure connection, like SSL in Gmail.</li>
<li>Retrieve/Read only email count from POP3 server in asp.net.</li>
<li>Retrieve/Read only email header from POP3 server in asp.net.</li>
<li>Retrieve/Read full emails from POP3 server in asp.net.</li>
<li>Retrieve/Read full emails to a file from POP3 server in asp.net.</li>
<p>Hope this will be handy to your programming..</p>
<p>Happy programming.</ul>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="color: red;" lang="EN-IN"><span style="font-size: 11pt;"><br />
<span style="font-family: Calibri;">NOTE<span style="mso-spacerun: yes;"> </span>: Also visit <a href="http://www.dhanashree.com">www.dhanashree.com</a></span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;"><br />
If you are in need of any </span><a href="http://dhanashree.com/web-development-services/asp-php-web-development" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">Web Development</span></a><span style="font-size: 11pt; font-family: Calibri;"> feel free to <span style="text-decoration: underline;"><a href="http://dhanashree.com/contact-web-designing-company" target="_blank">Inquire us</a></span> .<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a></span>. Expertise in <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">Asp.net Development</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/lamp-development-php-web-designing" target="_blank">Php Development</a></span>,<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><br />
<a href="http://dhanashree.com/web-development-services/website-designing" target="_blank">Website designing</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/open-source-wordpress-joomla-oscommerce-customisation" target="_blank">Open Source customisation</a></span>. <span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a> </span>can be our <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/offshore-website-designing-company" target="_blank">offshore development company</a></span> / </span><a href="http://dhanashree.com/web-designing-outsource-advantages" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">outsourcing</span></a><span style="font-size: 11pt; font-family: Calibri;"> <span style="text-decoration: underline;"><a href="http://dhanashree.com/dhanashree-web-development-profile" target="_blank">web development company</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">hire dedicated web programmers</a></span>.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;"><br />
Above information is for knowledge sharing<span style="mso-spacerun: yes;"> </span>if you have problem / issue / suggestion please intimate us with details for proper and prompt action.</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://techinsight.dhanashree.com/read-email-from-ssl-enabled-pop3-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to convert value to Enum</title>
		<link>http://techinsight.dhanashree.com/how-to-convert-value-to-enum/</link>
		<comments>http://techinsight.dhanashree.com/how-to-convert-value-to-enum/#comments</comments>
		<pubDate>Thu, 07 Oct 2010 11:10:18 +0000</pubDate>
		<dc:creator>jatin</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[.net 3.5]]></category>
		<category><![CDATA[C#.net]]></category>

		<guid isPermaLink="false">http://techinsight.dhanashree.com/?p=238</guid>
		<description><![CDATA[How to convert a value into Enum?
In project, we sometime come across a kind of situation where we need to convert some value to Enum and an Enum object into certain value.
One solution to this is we can write chunk of switch-case statement and return the desired result.
But is there any rationalize method to achieve [...]]]></description>
			<content:encoded><![CDATA[<h1>How to convert a value into Enum?</h1>
<p>In project, we sometime come across a kind of situation where we need to convert some value to Enum and an Enum object into certain value.</p>
<p>One solution to this is we can write chunk of switch-case statement and return the desired result.</p>
<p>But is there any rationalize method to achieve this? Yes here is the piece of code that you may find it useful. I have implemented it in many of my project and it really helps me reduce some overloaded work for me.</p>
<p>So here is that code for you in which I demonstrate how you can convert a value into Enum object.</p>
<p><span style="font-family: Courier New;"><span style="color: blue;">using</span> System;</span></p>
<p><span style="font-family: Courier New;"><span style="color: blue;">using</span> System.Collections.Generic;</span></p>
<p><span style="font-family: Courier New;"><span style="color: blue;">using</span> System.Linq;</span></p>
<p><span style="font-family: Courier New;"><span style="color: blue;">public</span></span></p>
<p><span style="color: blue;">static</span></p>
<p><span style="color: blue;">class</span></p>
<p><span style="color: #2b91af;">EnumsConverter</span></p>
<p><span style="font-family: Courier New;"> {</span></p>
<p><span style="font-family: Courier New;"> </span></p>
<p><span style="color: blue;">public</span></p>
<p><span style="color: blue;">static</span> T ConvertValueToEnum&lt;T&gt;(<span style="color: blue;">object</span> value, T defaultValue)</p>
<p><span style="font-family: Courier New;"> {</span></p>
<p><span style="font-family: Courier New;"> </span></p>
<p><span style="color: #2b91af;">Type</span> enumType = <span style="color: #2b91af;">Reflection</span>.ExtractEnumType(<span style="color: blue;">typeof</span>(T));</p>
<p><span style="font-family: Courier New;"> </span></p>
<p><span style="color: blue;">if</span> (enumType == <span style="color: blue;">null</span>)</p>
<p><span style="font-family: Courier New;"> {</span></p>
<p><span style="font-family: Courier New;"> </span></p>
<p><span style="color: blue;">throw</span></p>
<p><span style="color: blue;">new</span></p>
<p><span style="color: #2b91af;">ArgumentException</span>(<span style="color: #a31515;">&#8220;Type T is not an enumeration&#8221;</span>, <span style="color: #a31515;">&#8220;T&#8221;</span>);</p>
<p><span style="font-family: Courier New;"> }</span></p>
<p><span style="font-family: Courier New;"> </span></p>
<p><span style="color: blue;">try</span></p>
<p><span style="font-family: Courier New;"> {</span></p>
<p><span style="font-family: Courier New;"> </span></p>
<p><span style="color: blue;">return</span> (T)<span style="color: #2b91af;">Enum</span>.Parse(enumType, value.ToString());</p>
<p><span style="font-family: Courier New;"> }</span></p>
<p><span style="font-family: Courier New;"> </span></p>
<p><span style="color: blue;">catch</span> (<span style="color: #2b91af;">ArgumentException</span>)</p>
<p><span style="font-family: Courier New;"> {</span></p>
<p><span style="font-family: Courier New;"> </span></p>
<p><span style="color: blue;">return</span> defaultValue;</p>
<p><span style="font-family: Courier New;"> }</span></p>
<p><span style="font-family: Courier New;"> }</span></p>
<p><span style="font-family: Courier New;"> </span></p>
<p><span style="color: blue;">public</span></p>
<p><span style="color: blue;">static</span> T ConvertValueToEnum&lt;T&gt;(<span style="color: blue;">object</span> value)</p>
<p><span style="font-family: Courier New;"> {</span></p>
<p><span style="font-family: Courier New;"> </span></p>
<p><span style="color: #2b91af;">Type</span> enumType = <span style="color: #2b91af;">Reflection</span>.ExtractEnumType(<span style="color: blue;">typeof</span>(T));</p>
<p><span style="font-family: Courier New;"> </span></p>
<p><span style="color: blue;">if</span> (enumType == <span style="color: blue;">null</span>)</p>
<p><span style="font-family: Courier New;"> {</span></p>
<p><span style="font-family: Courier New;"> </span></p>
<p><span style="color: blue;">throw</span></p>
<p><span style="color: blue;">new</span></p>
<p><span style="color: #2b91af;">ArgumentException</span>(<span style="color: #a31515;">&#8220;Type T is not an enumeration&#8221;</span>, <span style="color: #a31515;">&#8220;T&#8221;</span>);</p>
<p><span style="font-family: Courier New;"> }</span></p>
<p><span style="font-family: Courier New;"> </span></p>
<p><span style="color: blue;">return</span> (T)<span style="color: #2b91af;">Enum</span>.Parse(enumType, value.ToString());</p>
<p><span style="font-family: Courier New;"> }</span></p>
<p><span style="font-family: Courier New;"> }</span></p>
<p>Here there are two overloaded methods. All you have to do is pass your desired enumeration object. The method itself will identify and return attached valued to that particular Enum object.</p>
<p>Happy programming…</p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="color: red;" lang="EN-IN"><span style="font-size: 11pt;"><br />
<span style="font-family: Calibri;">NOTE<span style="mso-spacerun: yes;"> </span>: Also visit <a href="http://www.dhanashree.com">www.dhanashree.com</a></span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;"><br />
If you are in need of any </span><a href="http://dhanashree.com/web-development-services/asp-php-web-development" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">Web Development</span></a><span style="font-size: 11pt; font-family: Calibri;"> feel free to <span style="text-decoration: underline;"><a href="http://dhanashree.com/contact-web-designing-company" target="_blank">Inquire us</a></span> .<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a></span>. Expertise in <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">Asp.net Development</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/lamp-development-php-web-designing" target="_blank">Php Development</a></span>,<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><br />
<a href="http://dhanashree.com/web-development-services/website-designing" target="_blank">Website designing</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/open-source-wordpress-joomla-oscommerce-customisation" target="_blank">Open Source customisation</a></span>. <span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a> </span>can be our <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/offshore-website-designing-company" target="_blank">offshore development company</a></span> / </span><a href="http://dhanashree.com/web-designing-outsource-advantages" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">outsourcing</span></a><span style="font-size: 11pt; font-family: Calibri;"> <span style="text-decoration: underline;"><a href="http://dhanashree.com/dhanashree-web-development-profile" target="_blank">web development company</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">hire dedicated web programmers</a></span>.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;"><br />
Above information is for knowledge sharing<span style="mso-spacerun: yes;"> </span>if you have problem / issue / suggestion please intimate us with details for proper and prompt action.</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://techinsight.dhanashree.com/how-to-convert-value-to-enum/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to call Google MAP Webservice API from asp.net, call Geocoding Map API Webservice from asp.net</title>
		<link>http://techinsight.dhanashree.com/how-to-call-google-map-webservice-api-from-asp-net-call-geocoding-map-api-webservice-from-asp-net/</link>
		<comments>http://techinsight.dhanashree.com/how-to-call-google-map-webservice-api-from-asp-net-call-geocoding-map-api-webservice-from-asp-net/#comments</comments>
		<pubDate>Thu, 07 Oct 2010 11:04:49 +0000</pubDate>
		<dc:creator>jatin</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[.net 3.5]]></category>

		<guid isPermaLink="false">http://techinsight.dhanashree.com/?p=234</guid>
		<description><![CDATA[How the necessities arise?
 
Necessity is mother of invention.
I was assigned a task to develop a restaurant portal.
The basic aim behind creation of this project is to have a marketplace for all restaurant owner or hotel business, and provide end user with integrative google map services so that they visualize realtime.
If we are supposed to [...]]]></description>
			<content:encoded><![CDATA[<p><strong>How the necessities arise?</strong></p>
<p><strong> </strong></p>
<p>Necessity is mother of invention.</p>
<p>I was assigned a task to develop a restaurant portal.</p>
<p>The basic aim behind creation of this project is to have a marketplace for all restaurant owner or hotel business, and provide end user with integrative google map services so that they visualize realtime.</p>
<p>If we are supposed to insert a simple google map, then we just have to insert a piece javascript code, and boom you are done.</p>
<p>But in my project, I have requirement where different restaurant/hotel owner register and give us their details and addresses.</p>
<p><strong>So, What is Google Map API?</strong></p>
<p><strong> </strong></p>
<p>The Google Maps API lets you embed Google Maps in your own web pages with JavaScript. The API provides a number of utilities for manipulating maps and adding content to the map through a variety of services, allowing you to create robust maps applications on your website.</p>
<p>All map related functionalities can be achieved as seen on <a href="http://maps.google.com/">http://maps.google.com/</a></p>
<p><strong>Then what was hurdle for me in using Map API?</strong></p>
<p><strong> </strong></p>
<p>These are the pure JavaScript code..!! You can develop whatever rich Map application you wanted to develop by writing piece of JavaScript codes.</p>
<p>Actually to host a map on your page, you need to have two parameters, Latitude &amp; Longitude. But how do I get lat. and long. from server side scripting?</p>
<p>But I had no idea how to call Google Map API from C#/VB.NET.</p>
<p>So for my project, as usual, I start googling to find out my piece of sweet.</p>
<p>After searching for couple of hours, I come across this good article.</p>
<p><a href="http://webcodeblog.com/2010/04/24/obtain-latitude-and-longitude-co-ordinates-for-an-address-using-asp-net-and-the-google-maps-api/">http://webcodeblog.com/2010/04/24/obtain-latitude-and-longitude-co-ordinates-for-an-address-using-asp-net-and-the-google-maps-api/</a></p>
<p>Here the author explained the how to obtain the latitude and longitude co-ordinates for an address using the Google Maps API.</p>
<p>But again here, it is pure JavaScript that utilize Google Map API to get lat &amp; long of any address. But my problem is still there?</p>
<p><strong>Hurrray….. I found the solution</strong></p>
<p><strong> </strong></p>
<p>Then accidently I come to across Google Maps API Web Services.</p>
<p>It is basically Maps API Web Services, a collection of HTTP interfaces to Google services providing geographic data for your maps applications.</p>
<p>In the documentation (<a href="http://code.google.com/apis/maps/documentation/webservices/">http://code.google.com/apis/maps/documentation/webservices/</a>),</p>
<p>I see that you can utilize Google Map API web service by making HTTP request to a specific URL, providing necessary parameters with URL. Which in return, gives a response in desired format.</p>
<p>You can get response inform of JSON or XML.</p>
<p>Say for e.g. it can be called like this URL</p>
<p><a href="http://maps.google.com/maps/geo?q=khandala, maharashtra&amp;output=xml&amp;key=xxxxxxxxxxxxxx"><span style="font-family: Courier New;">http://maps.google.com/maps/geo?q=khandala, maharashtra&amp;output=xml&amp;key=xxxxxxxxxxxxxx</span></a><span style="color: green; font-family: Courier New;"> </span></p>
<p>Paste it into your browser and you will receive a XML response.</p>
<p>Immediately, I get one &#8220;Mantos (<em>Dimag ki batti jala de</em>)&#8221; and found a clue <span style="font-family: Wingdings;">J</span></p>
<p>I thought why not to develop a library that make a call to this URL and parse the returned output to get lat &amp; long…!!?</p>
<p>So for that purpose I write this library.</p>
<p>Obviously, before doing all these, you will need to register with Google Map API and get a key so that you can utilize their API.</p>
<p>Sign up and get a Google Maps API Key.  You will need one for the domain name of where you will be hosting the map.  You can get your API Key from here (<a title="http://code.google.com/apis/maps/signup.html" href="http://code.google.com/apis/maps/signup.html">http://code.google.com/apis/maps/signup.html</a>)</p>
<p>Following is the complete code that I used to call Google Map <a href="http://code.google.com/apis/maps/documentation/geocoding/">Geocoding API</a> from Asp.net.</p>
<p>All you have to do Is to just create a class file and paste the following code. And you are ready to call Google Map <a href="http://code.google.com/apis/maps/documentation/geocoding/">Geocoding API</a>.</p>
<p><strong>How to call Geocoding API from Asp.net?</strong></p>
<p><strong> </strong></p>
<p><strong>Step 1</strong></p>
<p><strong> </strong></p>
<p><span style="font-family: Courier New;"> <span style="color: gray;">///</span><span style="color: green;"> Resolve addresses into latitude/longitude coordinates using Google MAP API webservices</span></span></p>
<p><span style="font-family: Courier New;"> <span style="color: gray;"> </span><span style="color: blue;">public static</span><span style="color: blue;"> class</span><span style="color: #2b91af;"> Geocoder</span></span></p>
<p><span style="font-family: Courier New;">{</span></p>
<p><span style="font-family: Courier New;"><span style="color: blue;">private</span><span style="color: blue;"> static</span><span style="color: blue;"> string</span> _GoogleMapsKey = <span style="color: #2b91af;">Config</span>.getAppSetting(<span style="color: #a31515;">&#8220;GoogleMapsKey&#8221;</span>);</span></p>
<p><span style="font-family: Courier New;"><span style="color: blue;">public</span><span style="color: blue;"> static</span><span style="color: #2b91af;"> Geolocation</span>? ResolveAddress(<span style="color: blue;">string</span> query)</span></p>
<p><span style="font-family: Courier New;"> {</span></p>
<p><span style="font-family: Courier New;"><span style="color: blue;">if</span> (<span style="color: blue;">string</span>.IsNullOrEmpty(_GoogleMapsKey))</span></p>
<p><span style="font-family: Courier New;"> _GoogleMapsKey = <span style="color: #2b91af;">ConfigurationManager</span>.AppSettings[<span style="color: #a31515;">"GoogleMapsKey"</span>];</span></p>
<p><span style="font-family: Courier New;"> </span></p>
<p><span style="color: blue;">string</span> url = <span style="color: #a31515;">&#8220;http://maps.google.com/maps/geo?q={0}&amp;output=xml&amp;key=&#8221;</span> + _GoogleMapsKey; <span style="color: green;"> </span></p>
<p><span style="font-family: Courier New;"> url = <span style="color: #2b91af;">String</span>.Format(url, query);</span></p>
<p><span style="font-family: Courier New;"><span style="color: #2b91af;">XmlNode</span> coords = <span style="color: blue;">null</span>;</span></p>
<p><span style="font-family: Courier New;"><span style="color: blue;">try</span>{</span></p>
<p><span style="font-family: Courier New;"><span style="color: blue;">string</span> xmlString = GetUrl(url);</span></p>
<p><span style="font-family: Courier New;"><span style="color: #2b91af;">XmlDocument</span> xd = <span style="color: blue;">new</span><span style="color: #2b91af;"> XmlDocument</span>();</span></p>
<p><span style="font-family: Courier New;"> xd.LoadXml(xmlString);</span></p>
<p><span style="font-family: Courier New;"><span style="color: #2b91af;">XmlNamespaceManager</span> xnm = <span style="color: blue;">new</span><span style="color: #2b91af;"> XmlNamespaceManager</span>(xd.NameTable);</span></p>
<p><span style="font-family: Courier New;"> coords = xd.GetElementsByTagName(<span style="color: #a31515;">&#8220;coordinates&#8221;</span>)[0];</span></p>
<p><span style="font-family: Courier New;"> }</span></p>
<p><span style="font-family: Courier New;"> </span></p>
<p><span style="color: blue;">catch</span> { }</p>
<p><span style="font-family: Courier New;"><span style="color: #2b91af;">Geolocation</span>? gl = <span style="color: blue;">null</span>;</span></p>
<p><span style="font-family: Courier New;"><span style="color: blue;">if</span> (coords != <span style="color: blue;">null</span>)</span><span style="font-family: Courier New;">{</span></p>
<p><span style="font-family: Courier New;"><span style="color: blue;">string</span>[] coordinateArray = coords.InnerText.Split(<span style="color: #a31515;">&#8216;,&#8217;</span>);</span></p>
<p><span style="font-family: Courier New;"><span style="color: blue;">if</span> (coordinateArray.Length &gt;= 2)</span></p>
<p><span style="font-family: Courier New;"> {</span></p>
<p><span style="font-family: Courier New;"> gl = <span style="color: blue;">new</span><span style="color: #2b91af;"> Geolocation</span>(<span style="color: #2b91af;">Convert</span>.ToDecimal(coordinateArray[1].ToString()), <span style="color: #2b91af;">Convert</span>.ToDecimal(coordinateArray[0].ToString()));</span></p>
<p><span style="font-family: Courier New;"> }</span></p>
<p><span style="font-family: Courier New;"> }</span></p>
<p><span style="font-family: Courier New;"> </span></p>
<p><span style="color: blue;">return</span> gl;</p>
<p><span style="font-family: Courier New;"> }</span></p>
<p><span style="font-family: Courier New;"> <span style="color: gray;"> </span></span></p>
<p><span style="color: blue;">public</span><span style="color: blue;"> static</span><span style="color: #2b91af;"> Geolocation</span>? ResolveAddress(<span style="color: blue;">string</span> address, <span style="color: blue;">string</span> city, <span style="color: blue;">string</span> state, <span style="color: blue;">string</span> postcode, <span style="color: blue;">string</span> country)</p>
<p><span style="font-family: Courier New;"> {</span></p>
<p><span style="font-family: Courier New;"><span style="color: blue;">return</span> ResolveAddress(address + <span style="color: #a31515;">&#8220;,&#8221;</span> + city + <span style="color: #a31515;">&#8220;,&#8221;</span> + state + <span style="color: #a31515;">&#8220;,&#8221;</span> + postcode + <span style="color: #a31515;">&#8221; &#8220;</span> + country);</span></p>
<p><span style="font-family: Courier New;"> }</span></p>
<p><span style="font-family: Courier New;"><span style="color: blue;">private</span><span style="color: blue;"> static</span><span style="color: blue;"> string</span> GetUrl(<span style="color: blue;">string</span> url)</span></p>
<p><span style="font-family: Courier New;"> {</span></p>
<p><span style="font-family: Courier New;"><span style="color: blue;">string</span> result = <span style="color: blue;">string</span>.Empty;</span></p>
<p><span style="font-family: Courier New;"> System.Net.<span style="color: #2b91af;">WebClient</span> Client = <span style="color: blue;">new</span><span style="color: #2b91af;"> WebClient</span>();</span></p>
<p><span style="font-family: Courier New;"><span style="color: blue;">using</span> (<span style="color: #2b91af;">Stream</span> strm = Client.OpenRead(url))</span></p>
<p><span style="font-family: Courier New;"> {</span></p>
<p><span style="font-family: Courier New;"><span style="color: #2b91af;">StreamReader</span> sr = <span style="color: blue;">new</span><span style="color: #2b91af;"> StreamReader</span>(strm);</span></p>
<p><span style="font-family: Courier New;"> result = sr.ReadToEnd();</span></p>
<p><span style="font-family: Courier New;"> }</span></p>
<p><span style="font-family: Courier New;"> </span></p>
<p><span style="color: blue;">return</span> result;</p>
<p><span style="font-family: Courier New;"> }</span></p>
<p><span style="font-family: Courier New;"> }</span></p>
<p><span style="font-family: Courier New;"> </span></p>
<p><span style="color: blue;">public</span><span style="color: blue;"> struct</span><span style="color: #2b91af;"> Geolocation</span></p>
<p><span style="font-family: Courier New;"> {</span></p>
<p><span style="font-family: Courier New;"><span style="color: blue;">public</span><span style="color: blue;"> decimal</span> Lat;</span></p>
<p><span style="font-family: Courier New;"> </span></p>
<p><span style="color: blue;">public</span><span style="color: blue;"> decimal</span> Lon;</p>
<p><span style="font-family: Courier New;"> </span></p>
<p><span style="color: blue;">public</span> Geolocation(<span style="color: blue;">decimal</span> lat, <span style="color: blue;">decimal</span> lon)</p>
<p><span style="font-family: Courier New;"> {</span></p>
<p><span style="font-family: Courier New;"> Lat = lat;</span></p>
<p><span style="font-family: Courier New;"> Lon = lon;</span></p>
<p><span style="font-family: Courier New;"> }</span></p>
<p><span style="font-family: Courier New;"> </span></p>
<p><span style="color: blue;">public</span><span style="color: blue;"> override</span><span style="color: blue;"> string</span> ToString()</p>
<p><span style="font-family: Courier New;"> {</span></p>
<p><span style="font-family: Courier New;"><span style="color: blue;">return</span><span style="color: #a31515;"> &#8220;Latitude: &#8220;</span> + Lat.ToString() + <span style="color: #a31515;">&#8221; Longitude: &#8220;</span> + Lon.ToString();</span></p>
<p><span style="font-family: Courier New;"> }</span></p>
<p><span style="font-family: Courier New;"><span style="color: blue;">public</span><span style="color: blue;"> string</span> ToQueryString()</span></p>
<p><span style="font-family: Courier New;"> {</span></p>
<p><span style="font-family: Courier New;"><span style="color: blue;">return</span><span style="color: #a31515;"> &#8220;+to:&#8221;</span> + Lat + <span style="color: #a31515;">&#8220;%2B&#8221;</span> + Lon;</span></p>
<p><span style="font-family: Courier New;"> }</span></p>
<p><span style="font-family: Courier New;"> }</span></p>
<p><strong>Step 2</strong></p>
<p><strong> </strong></p>
<p>Now, you just need to put a key in AppSetting section that hold your Google Map API key.</p>
<p><strong>Step 3</strong></p>
<p><strong> </strong></p>
<p>I have provided 2 overloaded methods to call Geocoding Map API Webservice, named <span style="font-family: Courier New;">ResolveAddress.</span></p>
<p>Say for e.g. you can call method like this.</p>
<p><span style="font-family: Courier New;"><span style="color: #2b91af;">Geocoder.</span>ResolveAddress(&#8220;University road&#8221;,&#8221;rajkot&#8221;,&#8221;gujarat&#8221;,&#8221;",&#8221;India&#8221;)</span></p>
<p>I hope this will solve your purpose, those who wanted to develop Geocoding application, those who want to access Google Map Webservice API from c#/vb.net.</p>
<p>Happy programming…</p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="color: red;" lang="EN-IN"><span style="font-size: 11pt;"><br />
<span style="font-family: Calibri;">NOTE<span style="mso-spacerun: yes;"> </span>: Also visit <a href="http://www.dhanashree.com">www.dhanashree.com</a></span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;"><br />
If you are in need of any </span><a href="http://dhanashree.com/web-development-services/asp-php-web-development" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">Web Development</span></a><span style="font-size: 11pt; font-family: Calibri;"> feel free to <span style="text-decoration: underline;"><a href="http://dhanashree.com/contact-web-designing-company" target="_blank">Inquire us</a></span> .<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a></span>. Expertise in <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">Asp.net Development</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/lamp-development-php-web-designing" target="_blank">Php Development</a></span>,<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><br />
<a href="http://dhanashree.com/web-development-services/website-designing" target="_blank">Website designing</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/open-source-wordpress-joomla-oscommerce-customisation" target="_blank">Open Source customisation</a></span>. <span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a> </span>can be our <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/offshore-website-designing-company" target="_blank">offshore development company</a></span> / </span><a href="http://dhanashree.com/web-designing-outsource-advantages" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">outsourcing</span></a><span style="font-size: 11pt; font-family: Calibri;"> <span style="text-decoration: underline;"><a href="http://dhanashree.com/dhanashree-web-development-profile" target="_blank">web development company</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">hire dedicated web programmers</a></span>.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;"><br />
Above information is for knowledge sharing<span style="mso-spacerun: yes;"> </span>if you have problem / issue / suggestion please intimate us with details for proper and prompt action.</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://techinsight.dhanashree.com/how-to-call-google-map-webservice-api-from-asp-net-call-geocoding-map-api-webservice-from-asp-net/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Combine/Compress/Minify JavaScript, CSS in Asp.net</title>
		<link>http://techinsight.dhanashree.com/combinecompressminify-javascript-css-in-asp-net/</link>
		<comments>http://techinsight.dhanashree.com/combinecompressminify-javascript-css-in-asp-net/#comments</comments>
		<pubDate>Mon, 05 Apr 2010 11:00:28 +0000</pubDate>
		<dc:creator>kiran</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[.net framework]]></category>
		<category><![CDATA[CSS 3]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Web Developement]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[.net developement]]></category>
		<category><![CDATA[asp.net developement]]></category>
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://techinsight.dhanashree.com/combinecompressminify-javascript-css-in-asp-net/</guid>
		<description><![CDATA[Introduction:

When we design and develop the website, the performance is in the core of development. The system you are developing must produce the result with high speed. For the web development perspective, website load performance is very essential thing to take care of. You need good working layout, easy layout and easy navigation.
Here with this [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Introduction:<br />
</strong></p>
<p>When we design and develop the website, the performance is in the core of development. The system you are developing must produce the result with high speed. For the web development perspective, website load performance is very essential thing to take care of. You need good working layout, easy layout and easy navigation.</p>
<p>Here with this article I m not going to talk about of all the aspects of web application performance improvements. But I am specifically targeting the topic when it comes to the CSS and JavaScript faster loading in the client browser.  In fact Google is also counting the speed of your website site when indexing to your website.</p>
<p>The goal was to improve overall performance on the client side. At the same time, it will show how we can force a client side script to be coached at the browser, so that in subsequent visit, it will take those scripts from the cache. This becomes increasingly important when using AJAX techniques within an application that introduce new features and functionality.</p>
<p>First of all I will outline the requirements and essential steps that this project is made of. So that if you want to implement the same in your development, it become easy for you to set up project.</p>
<p>To download complete project, <a href="http://www.esnips.com/doc/bb247398-9971-4fac-bb8e-02a8e8ebad7d/JS-CSS-Combiner-Minifier">click here</a></p>
<p><strong>Setup:<br />
</strong></p>
<p>To begin with, we will have following list of files to be created in the development studio.</p>
<ol>
<li>2 XML files, first one to hold source of JS files for each page and second to  hold CSS files for each page.</li>
<li>A generic class that implement <em>IHttpHandler, </em>that will be used to delivery combined and compressed JavaScript/CSS at the client.</li>
<li>And at last your .ASPX file that will be used to serve combined and compressed Javascript/CSS at client side.</li>
</ol>
<p><strong>Step by Step Implementation:<br />
</strong></p>
<p>Now let&#8217;s get dig into the actual development. To summarize, let&#8217;s say we have a page default.aspx that has following no. of JavaScript files and CSS files. Think of these file that we wanted to combine them and deliver at one go at the client browser.</p>
<ol>
<li>jquery.js</li>
<li>script-file-1.js</li>
<li>style-1.css</li>
<li>style-2.css</li>
</ol>
<p>As you can see, we have 2 different JavaScript file &amp; 2 CSS files. So what basically we will do in the next is to create a utility which can combine given JavaScript and compress it, then send it to client browser. Next the same process will be done for the CSS. Both the CSS files will be combined and compressed and send to client browser.</p>
<p>Now it&#8217;s time to take a look at into actual stuff that does this underlying work.</p>
<p>First of all we will create a CS class file that will hold the programming stuffs.</p>
<p>So perform the following steps to create &amp; configure that CS class file.</p>
<ol>
<li>
<div>Create CS class file with the name <em>ScriptCombiner.cs</em> and put the following code in that.</div>
</li>
</ol>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">public</span><span style="color: blue;"> </span><span style="color: blue;">class</span><br />
<span style="color: #2b91af;">ScriptCombiner</span> : <span style="color: #2b91af;">IHttpHandler<span style="color: #000000;">{</span></span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: blue;">private</span><span style="color: blue;"> </span><span style="color: blue;">readonly</span><span style="color: blue;"> </span><span style="color: blue;">static</span><span style="color: blue;"> </span><span style="color: #2b91af;">TimeSpan</span> CACHE_DURATION = <span style="color: #2b91af;">TimeSpan</span>.FromDays(1);</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: blue;">private</span><span style="color: blue;"> </span><span style="color: #2b91af;">HttpContext</span> context;</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: blue;">public</span><span style="color: blue;"> </span><span style="color: blue;">void</span> ProcessRequest(<span style="color: #2b91af;">HttpContext</span> context){</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> }<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">public</span><span style="color: blue;"> </span><span style="color: blue;">bool</span> IsReusable{</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">get</span> { <span style="color: blue;">return</span><span style="color: blue;"> </span><span style="color: blue;">true</span>; }<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> }</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;">}</span></p>
<p>As you can see, we are implementing the <span style="color: #2b91af; font-family: Courier New; font-size: 10pt;">IHttpHandler </span>interface.</p>
<p>You can write custom HTTP handlers to process specific, predefined types of HTTP requests in any Common Language Specification (CLS) compliant language. Executable code defined in the HttpHandler classes, rather than conventional ASP or ASP.NET Web pages, responds to these specific requests. HTTP handlers give you a means of interacting with the low-level request and response services of the IIS Web server and provide functionality much like ISAPI extensions but with a simpler programming model.</p>
<p>We are also implementing <span style="font-family: Courier New; font-size: 10pt;">IsReusable </span>properly as it is compulsory to implement as a part of inheritance of <span style="color: #2b91af; font-family: Courier New; font-size: 10pt;">IHttpHandler </span>interface.</p>
<p>Now, let&#8217;s put the nuts &amp; bolts inside the <span style="font-family: Courier New; font-size: 10pt;">ProcessRequest </span>function. I will also explain you the step by step each execution that is inside this function.</p>
<ol>
<li>We will also create another CS class file that is used to compress JavaScript. That file is named as &#8220;JavaScriptMinifier.cs&#8221;. Please take a look at the attached project solution file. As it is contain long lines of code, I can&#8217;t put it here.</li>
<li>Complete your class file with following functions.</li>
</ol>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">public</span><span style="color: blue;"> </span><span style="color: blue;">void</span> ProcessRequest(<span style="color: #2b91af;">HttpContext</span> context)<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> {</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: blue;">string</span> xStrType, xStrSet, xStrVer, xStrpagecode;</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: #2b91af;">Boolean</span> xBlnCanCompress;</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: blue;">this</span>.context = context;</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: #2b91af;">HttpRequest</span> request = context.Request;</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;">xStrType = (!<span style="color: #2b91af;">String</span>.IsNullOrEmpty(request[<span style="color: #a31515;">"type"</span>])) ? request[<span style="color: #a31515;">"type"</span>] : <span style="color: blue;">null</span>;</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> xStrSet = (!<span style="color: #2b91af;">String</span>.IsNullOrEmpty(request[<span style="color: #a31515;">"s"</span>])) ? request[<span style="color: #a31515;">"s"</span>] : <span style="color: blue;">null</span>;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> xStrVer = (!<span style="color: #2b91af;">String</span>.IsNullOrEmpty(request[<span style="color: #a31515;">"v"</span>])) ? request[<span style="color: #a31515;">"v"</span>] : <span style="color: blue;">null</span>;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> xStrpagecode = (!<span style="color: #2b91af;">String</span>.IsNullOrEmpty(request[<span style="color: #a31515;">"pcode"</span>])) ? request[<span style="color: #a31515;">"pcode"</span>] : <span style="color: blue;">null</span>;</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: green;">//first check if client browser can support compressions<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> xBlnCanCompress = CanClientGZip(request);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">using</span> (<span style="color: #2b91af;">MemoryStream</span> memStream = <span style="color: blue;">new</span><span style="color: blue;"> </span><span style="color: #2b91af;">MemoryStream</span>(8092))<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> {</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: #2b91af;">Stream</span> writer;</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: green;">//if browser is supporing GZip compression then create a new object using ICSharpCode.SharpZipLib.GZip</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: green;">//library which allow the compressed respose to send to client<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">if</span> (xBlnCanCompress) </span></p>
<p><span style="font-family: Courier New; font-size: 10pt;">writer = (<span style="color: blue;">new</span> ICSharpCode.SharpZipLib.GZip.GZipOutputStream(memStream));</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">else<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> writer = memStream;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">using</span> (writer){</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: green;">//now its time to read all the script/css files into a StringBuilder object.<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: #2b91af;">StringBuilder</span> combinedSource = <span style="color: blue;">new</span><span style="color: blue;"> </span><span style="color: #2b91af;">StringBuilder</span>();<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">foreach</span> (<span style="color: blue;">string</span> file <span style="color: blue;">in</span> GetFileNames(xStrSet, xStrpagecode, xStrType))<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> combinedSource.Append(System.IO.<span style="color: #2b91af;">File</span>.ReadAllText(context.Server.MapPath(file), <span style="color: #2b91af;">Encoding</span>.UTF8));<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: green;">//Upto now we have combined all css/javascript based on request.<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: green;">//its now time to remove extra white spaces and other unwanted characters from respose.</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: green;">//compression will take place now.<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">string</span> minified;</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: green;">//use the YUI Javascript/CSS minifier to compress all js files<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">if</span> (xStrType == <span style="color: #a31515;">&#8220;js&#8221;</span>)<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> minified = combinedSource.ToString();<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">else<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> minified = CompressCSS(combinedSource.ToString());<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: green;">// Send minfied string to output stream<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">byte</span>[] bt = <span style="color: #2b91af;">Encoding</span>.UTF8.GetBytes(minified);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> writer.Write(bt, 0, bt.Length);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> }</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: green;">//cache the respose so that in next request it can be reused<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">byte</span>[] responseBytes = memStream.ToArray();<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: green;">//context.Cache.Insert(GetCacheKey(xStrSet, xStrType, xStrVer, xBlnCanCompress), responseBytes, null, System.Web.Caching.Cache.NoAbsoluteExpiration, CACHE_DURATION);<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: green;">// Generate the response<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">this</span>.WriteBytes(responseBytes, xBlnCanCompress, xStrType);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> }<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> }</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">private</span><span style="color: blue;"> </span><span style="color: blue;">bool</span> CanClientGZip(<span style="color: #2b91af;">HttpRequest</span> request){</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">string</span> acceptEncoding = request.Headers[<span style="color: #a31515;">"Accept-Encoding"</span>];<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">if</span> (!<span style="color: blue;">string</span>.IsNullOrEmpty(acceptEncoding) &amp;&amp;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> (acceptEncoding.Contains(<span style="color: #a31515;">&#8220;gzip&#8221;</span>) || acceptEncoding.Contains(<span style="color: #a31515;">&#8220;deflate&#8221;</span>)))<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">return </span><span style="color: blue;">true</span>;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">return</span><span style="color: blue;"> </span><span style="color: blue;">false</span>;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> }</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: green;">// helper method that return an array of file names inside the text file stored in App_Data folder<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">private</span><span style="color: blue;"> </span><span style="color: blue;">static</span><span style="color: blue;"> </span><span style="color: blue;">string</span>[] GetFileNames(<span style="color: blue;">string</span> setName, <span style="color: blue;">string</span> pagecode, <span style="color: blue;">string</span> type)<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> {System.Xml.XPath.<span style="color: #2b91af;">XPathDocument</span> doc2;</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> System.Xml.XPath.<span style="color: #2b91af;">XPathNavigator</span> navigator;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> System.Xml.XPath.<span style="color: #2b91af;">XPathNodeIterator</span> iterator;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> System.Collections.Generic.<span style="color: #2b91af;">List</span>&lt;<span style="color: blue;">string</span>&gt; scripts = <span style="color: blue;">new</span> System.Collections.Generic.<span style="color: #2b91af;">List</span>&lt;<span style="color: blue;">string</span>&gt;();<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">string</span> key;</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: blue;">if</span> (type == <span style="color: #a31515;">&#8220;js&#8221;</span>)<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> key = <span style="color: #a31515;">&#8220;scriptfile&#8221;</span>;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">else<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> key = <span style="color: #a31515;">&#8220;cssfile&#8221;</span>;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">if</span> (System.Web.<span style="color: #2b91af;">HttpContext</span>.Current.Cache[key] != <span style="color: blue;">null</span>)<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> {doc2 = (System.Xml.XPath.<span style="color: #2b91af;">XPathDocument</span>)System.Web.<span style="color: #2b91af;">HttpContext</span>.Current.Cache[key];</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> }<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">else<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> {</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: blue;">string</span> filename;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> filename = System.Web.<span style="color: #2b91af;">HttpContext</span>.Current.Server.MapPath(<span style="color: #2b91af;">String</span>.Format(<span style="color: #a31515;">&#8220;~/App_Data/{0}.xml&#8221;</span>, setName));<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> doc2 = <span style="color: blue;">new</span> System.Xml.XPath.<span style="color: #2b91af;">XPathDocument</span>(filename);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> System.Web.<span style="color: #2b91af;">HttpContext</span>.Current.Cache.Insert(key, doc2, <span style="color: blue;">new</span> System.Web.Caching.<span style="color: #2b91af;">CacheDependency</span>(filename), <span style="color: #2b91af;">DateTime</span>.Now.AddMinutes(60), <span style="color: #2b91af;">TimeSpan</span>.Zero);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> }</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;">navigator = doc2.CreateNavigator();</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: blue;">if</span> (type == <span style="color: #a31515;">&#8220;js&#8221;</span>)</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;">iterator = navigator.Select(<span style="color: #a31515;">&#8220;/scripts/page[@pagecode='"</span> + pagecode + <span style="color: #a31515;">"']/script&#8221;</span>);</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">else<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> iterator = navigator.Select(<span style="color: #a31515;">&#8220;/styles/page[@pagecode='"</span> + pagecode + <span style="color: #a31515;">"']/style&#8221;</span>);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">while</span> (iterator.MoveNext())<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> scripts.Add(iterator.Current.InnerXml);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">return</span> scripts.ToArray();<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> }<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">private</span><span style="color: blue;"> </span><span style="color: blue;">string</span> GetCacheKey(<span style="color: blue;">string</span> type, <span style="color: blue;">string</span> setName, <span style="color: blue;">string</span> version, <span style="color: blue;">bool</span> cancompress)<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> {</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: blue;">return</span><span style="color: blue;"> </span><span style="color: #a31515;">&#8220;HttpCombiner.&#8221;</span> + setName + <span style="color: #a31515;">&#8220;.&#8221;</span> + type + <span style="color: #a31515;">&#8220;.&#8221;</span> + version + <span style="color: #a31515;">&#8220;.&#8221;</span> + cancompress;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> }<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">private</span><span style="color: blue;"> </span><span style="color: blue;">void</span> WriteBytes(<span style="color: blue;">byte</span>[] bytes, <span style="color: blue;">bool</span> isCompressed, <span style="color: blue;">string</span> type)<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> {<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: #2b91af;">HttpResponse</span> response = context.Response;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> response.AppendHeader(<span style="color: #a31515;">&#8220;Content-Length&#8221;</span>, bytes.Length.ToString());<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">if</span> (type == <span style="color: #a31515;">&#8220;js&#8221;</span>)<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> response.ContentType = <span style="color: #a31515;">&#8220;application/x-javascript&#8221;</span>;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">else<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> response.ContentType = <span style="color: #a31515;">&#8220;text/css&#8221;</span>;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">if</span> (isCompressed)<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> response.AppendHeader(<span style="color: #a31515;">&#8220;Content-Encoding&#8221;</span>, <span style="color: #a31515;">&#8220;gzip&#8221;</span>);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">else<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> response.AppendHeader(<span style="color: #a31515;">&#8220;Content-Encoding&#8221;</span>, <span style="color: #a31515;">&#8220;utf-8&#8243;</span>);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> context.Response.Cache.SetCacheability(<span style="color: #2b91af;">HttpCacheability</span>.Public);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> context.Response.Cache.SetExpires(<span style="color: #2b91af;">DateTime</span>.Now.Add(CACHE_DURATION));<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> context.Response.Cache.SetMaxAge(CACHE_DURATION);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> response.ContentEncoding = <span style="color: #2b91af;">Encoding</span>.Unicode;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> response.OutputStream.Write(bytes, 0, bytes.Length);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> response.Flush();<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> }<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">public</span><span style="color: blue;"> </span><span style="color: blue;">static</span><br />
<span style="color: blue;">string</span> GetScriptTag(<span style="color: blue;">string</span> setname, <span style="color: blue;">string</span> pageid, <span style="color: blue;">string</span> type, <span style="color: blue;">string</span> ver)<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> {</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: blue;">string</span> result = <span style="color: #a31515;">&#8220;&#8221;</span>;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">if</span> (type == <span style="color: #a31515;">&#8220;js&#8221;</span>)<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> result += <span style="color: #2b91af;">String</span>.Format(<span style="color: #a31515;">&#8220;&lt;script type=\&#8221;text/javascript\&#8221; src=\&#8221;/&#8221;</span> + Web.Utility.Functions.GetURLPrefix() + <span style="color: #a31515;">&#8220;ScriptCombiner.axd?s={0}&amp;v={1}&amp;type=js&amp;pcode={2}\&#8221;&gt;&lt;/script&gt;&#8221;</span>, setname, ver, pageid);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">else<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> result += <span style="color: #2b91af;">String</span>.Format(<span style="color: #a31515;">&#8220;&lt;link link href=\&#8221;ScriptCombiner.axd?s={0}&amp;v={1}&amp;type=css&amp;pcode={2}\&#8221; rel=\&#8221;stylesheet\&#8221; type=\&#8221;text/css\&#8221;/&gt;&#8221;</span>, setname, ver, pageid);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">return</span> result;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> }<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">public</span><span style="color: blue;"> </span><span style="color: blue;">static</span><span style="color: blue;"> </span><span style="color: blue;">string</span> CompressCSS(<span style="color: blue;">string</span> body)<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> {<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> body = <span style="color: #2b91af;">Regex</span>.Replace(body, <span style="color: #a31515;">&#8220;/\\*.+?\\*/&#8221;</span>, <span style="color: #a31515;">&#8220;&#8221;</span>, <span style="color: #2b91af;">RegexOptions</span>.Singleline);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> body = body.Replace(<span style="color: #a31515;">&#8221;  &#8220;</span>, <span style="color: blue;">string</span>.Empty);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> body = body.Replace(<span style="color: #2b91af;">Environment</span>.NewLine + <span style="color: #2b91af;">Environment</span>.NewLine + <span style="color: #2b91af;">Environment</span>.NewLine, <span style="color: blue;">string</span>.Empty);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> body = body.Replace(<span style="color: #2b91af;">Environment</span>.NewLine + <span style="color: #2b91af;">Environment</span>.NewLine, <span style="color: #2b91af;">Environment</span>.NewLine);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> body = body.Replace(<span style="color: #2b91af;">Environment</span>.NewLine, <span style="color: blue;">string</span>.Empty);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> body = body.Replace(<span style="color: #a31515;">&#8220;\\t&#8221;</span>, <span style="color: blue;">string</span>.Empty);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> body = body.Replace(<span style="color: #a31515;">&#8221; {&#8220;</span>, <span style="color: #a31515;">&#8220;{&#8220;</span>);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> body = body.Replace(<span style="color: #a31515;">&#8221; :&#8221;</span>, <span style="color: #a31515;">&#8220;:&#8221;</span>);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> body = body.Replace(<span style="color: #a31515;">&#8220;: &#8220;</span>, <span style="color: #a31515;">&#8220;:&#8221;</span>);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> body = body.Replace(<span style="color: #a31515;">&#8220;, &#8220;</span>, <span style="color: #a31515;">&#8220;,&#8221;</span>);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> body = body.Replace(<span style="color: #a31515;">&#8220;; &#8220;</span>, <span style="color: #a31515;">&#8220;;&#8221;</span>);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> body = body.Replace(<span style="color: #a31515;">&#8220;;}&#8221;</span>, <span style="color: #a31515;">&#8220;}&#8221;</span>);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> body = <span style="color: #2b91af;">Regex</span>.Replace(body, <span style="color: #a31515;">&#8220;/\\*[^\\*]*\\*+([^/\\*]*\\*+)*/&#8221;</span>, <span style="color: #a31515;">&#8220;$1&#8243;</span>);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> body = <span style="color: #2b91af;">Regex</span>.Replace(body, <span style="color: #a31515;">&#8220;(?&lt;=[&gt;])\\s{2,}(?=[&lt;])|(?&lt;=[&gt;])\\s{2,}(?=&amp;nbsp;)|(?&lt;=&amp;ndsp;)\\s{2,}(?=[&lt;])&#8221;</span>, <span style="color: blue;">string</span>.Empty);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">return</span> body;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> }</span></p>
<p>You are now almost done with 50% of work for your project.</p>
<p>Now let&#8217;s take a look at the few of important execution steps that are in this function.</p>
<p>First of all we are declaring four different string variables:</p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">string</span> xStrType, xStrSet, xStrVer, xStrpagecode;<br />
</span></p>
<p>They will be used to get the Querystring passed in to this handler. This is utilized later on the code.</p>
<p>Moving next, you will find these function call:</p>
<p><span style="color: green; font-family: Courier New; font-size: 10pt;">//first check if client browser can support compressions<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> xBlnCanCompress = CanClientGZip(request);<br />
</span></p>
<p>This is basically to check does client browser support GZip compression.</p>
<p>Gzip compression, otherwise known as content encoding, is a publicly defined way to compress textual content transferred from web servers to browsers. HTTP compression uses public domain compression algorithms, like gzip and compress, to compress XHTML, JavaScript, CSS, and other text files at the server. This standards-based method of delivering compressed content is built into HTTP 1.1, and most modern browsers that support HTTP 1.1 support ZLIB inflation of deflated documents. In other words, they can decompress compressed files automatically, which saves time and bandwidth.</p>
<p>In the next step it is preparing the <em>stream</em> object used to hold the response output. We will not take dipper look into that code. As I expect that the a beginning developer even must be able know about next few line of code. <span style="font-family: Wingdings;">J</span></p>
<p>Let&#8217;s move to the line of code:</p>
<p><span style="color: green; font-family: Courier New; font-size: 10pt;">//now its time to read all the script/css files into a StringBuilder object.<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><br />
<span style="color: #2b91af;">StringBuilder</span> combinedSource = <span style="color: blue;">new</span><br />
<span style="color: #2b91af;">StringBuilder</span>();<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">foreach</span> (<span style="color: blue;">string</span> file <span style="color: blue;">in</span> GetFileNames(xStrSet, xStrpagecode, xStrType))<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> combinedSource.Append(System.IO.<span style="color: #2b91af;">File</span>.ReadAllText(context.Server.MapPath(file), <span style="color: #2b91af;">Encoding</span>.UTF8));<br />
</span></p>
<p>As you can see in the foreach loop, it is calling to method <span style="font-family: Courier New; font-size: 10pt;">GetFileNames, </span>by passing 3 different parameters. Here this is also core and important part of this project. Let me outline you first what this function basically do. This function will read to the &#8220;script.xml&#8221; file that hold content of script file that we want to load. Please look inside the attached project solution to understand it better. The function will read xml file and return array of string object containing JavaScript files to read.</p>
<p>In the subsequent line of code, it iterate through each file name and read it. Each content of read file is placed inside a <span style="color: #2b91af; font-family: Courier New; font-size: 10pt;">StringBuilder </span>object.</p>
<p>Please take look at the code inside the <span style="font-family: Courier New; font-size: 10pt;">GetFileNames </span>function to understand what is actually happening inside it. It fetches the JavaScript/CSS based on the parameter passed. And return either the JavaScript file name array or CSS file name array.</p>
<p>So now we have a combined script/CSS with us. It&#8217;s a time to minify JavaScript/CSS now.</p>
<p>Following line of code will minify respective JavaScript/CSS based on type of client script requested.</p>
<p><span style="color: green; font-family: Courier New; font-size: 10pt;">//use the YUI Javascript/CSS minifier to compress all js files<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><br />
<span style="color: blue;">if</span> (xStrType == <span style="color: #a31515;">&#8220;js&#8221;</span>)<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> {</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: #2b91af;">JavaScriptMinifier</span> minifier = <span style="color: blue;">new</span><br />
<span style="color: #2b91af;">JavaScriptMinifier</span>();<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> minified = minifier.Minify(combinedSource.ToString());<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> }</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: blue;">else<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> {<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> minified = CompressCSS(combinedSource.ToString());<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> }<br />
</span></p>
<p>The <span style="color: #2b91af; font-family: Courier New; font-size: 10pt;">JavaScriptMinifier </span>has been created in the 2<sup>nd</sup> step. Please refer to the attached solution project for more detail regarding this class file. I have adopted this class file from one of the article</p>
<p>You will also see function <span style="font-family: Courier New; font-size: 10pt;">CompressCSS </span>that is used to compress CSS file. The compressor of CSS file is done through just few regular expression. JavaScript compression has different algorithm.</p>
<p>After that it is calling to <span style="font-family: Courier New; font-size: 10pt;">WriteBytes </span>function that will prepare the combined &amp; compressed JavaScript &amp; CSS response and send it to the client.</p>
<p>Hurray… as part of implementation we are done.</p>
<p>Now it&#8217;s time to check that in action. You can run the project attached here with and check it In live action.</p>
<p>To download complete project, <a href="http://www.esnips.com/doc/bb247398-9971-4fac-bb8e-02a8e8ebad7d/JS-CSS-Combiner-Minifier">click here</a></p>
<p>Let&#8217;s compare the result of two different pages. The first one is with the compressed JavaScript &amp; CSS. The second one is with the normal JavaScript &amp; CSS. We will also see the difference in load time and size of content received.</p>
<p>Response time with compressed JavaScript &amp; CSS.</p>
<p><img src="http://techinsight.dhanashree.com/article-images/040510_1059_CombineComp1.jpg" alt="" /></p>
<p>Response time without compressed JavaScript &amp; CSS.</p>
<p><img src="http://techinsight.dhanashree.com/article-images/040510_1059_CombineComp2.jpg" alt="" /></p>
<p>As you can see from given statistics</p>
<p>With Combined &amp; Compressed JavaScript and CSS ..</p>
<p>Total request: 3</p>
<p>Response size: 16.3 KB</p>
<p>Without Combined &amp; Compressed JavaScript and CSS ..</p>
<p>Total request: 5</p>
<p>Response size: 96 KB</p>
<p>You can clearly see the difference between these two request.</p>
<p>To get more idea open and run the project yourself. That will give you better idea.</p>
<p>Hope you will find it very useful.</p>
<p>Happy coding…. <span style="font-family: Wingdings;">J</span></p>
<p><span style="font-family: Calibri; font-size: 15px; color: #ff0000;">NOTE<span style="mso-spacerun: yes;"> </span>:</span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">If you are in need of any </span><a href="http://dhanashree.com/web-development-services/asp-php-web-development" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">Web Development</span></a><span style="font-size: 11pt; font-family: Calibri;"> feel free to <span style="text-decoration: underline;"><a href="http://dhanashree.com/contact-web-designing-company" target="_blank">Inquire us</a></span> .<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a></span>. Expertise in <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">Asp.net Development</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/lamp-development-php-web-designing" target="_blank">Php Development</a></span>,<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/website-designing" target="_blank">Website designing</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/open-source-wordpress-joomla-oscommerce-customisation" target="_blank">Open Source customisation</a></span>. <span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a> </span>can be our <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/offshore-website-designing-company" target="_blank">offshore development company</a></span> / </span><a href="http://dhanashree.com/web-designing-outsource-advantages" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">outsourcing</span></a><span style="font-size: 11pt; font-family: Calibri;"> <span style="text-decoration: underline;"><a href="http://dhanashree.com/dhanashree-web-development-profile" target="_blank">web development company</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">hire dedicated web programmers</a></span>.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">Above information is for knowledge sharing<span style="mso-spacerun: yes;"> </span>if you have problem / issue / suggestion please intimate us with details for proper and prompt action.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="color: red;" lang="EN-IN"><span style="font-size: 11pt;"><br />
<span style="font-family: Calibri;">NOTE<span style="mso-spacerun: yes;"> </span>: Also visit <a href="http://www.dhanashree.com">www.dhanashree.com</a></span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;"><br />
If you are in need of any </span><a href="http://dhanashree.com/web-development-services/asp-php-web-development" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">Web Development</span></a><span style="font-size: 11pt; font-family: Calibri;"> feel free to <span style="text-decoration: underline;"><a href="http://dhanashree.com/contact-web-designing-company" target="_blank">Inquire us</a></span> .<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a></span>. Expertise in <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">Asp.net Development</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/lamp-development-php-web-designing" target="_blank">Php Development</a></span>,<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><br />
<a href="http://dhanashree.com/web-development-services/website-designing" target="_blank">Website designing</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/open-source-wordpress-joomla-oscommerce-customisation" target="_blank">Open Source customisation</a></span>. <span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a> </span>can be our <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/offshore-website-designing-company" target="_blank">offshore development company</a></span> / </span><a href="http://dhanashree.com/web-designing-outsource-advantages" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">outsourcing</span></a><span style="font-size: 11pt; font-family: Calibri;"> <span style="text-decoration: underline;"><a href="http://dhanashree.com/dhanashree-web-development-profile" target="_blank">web development company</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">hire dedicated web programmers</a></span>.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;"><br />
Above information is for knowledge sharing<span style="mso-spacerun: yes;"> </span>if you have problem / issue / suggestion please intimate us with details for proper and prompt action.</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://techinsight.dhanashree.com/combinecompressminify-javascript-css-in-asp-net/feed/</wfw:commentRss>
		<slash:comments>41</slash:comments>
		</item>
		<item>
		<title>Custom error tracking library in asp.net using XML &amp; C#</title>
		<link>http://techinsight.dhanashree.com/custom-error-tracking-library-in-asp-net-using-xml-c/</link>
		<comments>http://techinsight.dhanashree.com/custom-error-tracking-library-in-asp-net-using-xml-c/#comments</comments>
		<pubDate>Mon, 28 Dec 2009 09:14:01 +0000</pubDate>
		<dc:creator>kiran</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[C#.net]]></category>
		<category><![CDATA[Web Developement]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[.net developement]]></category>
		<category><![CDATA[asp.net developement]]></category>

		<guid isPermaLink="false">http://dhanashree.com/techblog/?p=80</guid>
		<description><![CDATA[
Being an asp.net developers we develop a web project and get it completed in a months of time as there are many organizations which works on very tight bound timeline for developing web sites Or web application projects. And delivers the project to client in months of time
While after project delivery if client come up [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>Being an <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">asp.net developers</a> we develop a web project and get it completed in a months of time as there are many organizations which works on very tight bound timeline for <a href="http://www.dhanashree.com/web-development-services/website-designing" target="_blank">developing web sites</a> Or <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development" target="_blank">web application</a> projects. And delivers the project to client in months of time</p>
<p>While after project delivery if client come up saying that they are facing problems or <a href="http://www.dhanashree.com/web-development-services/web-software-application-development" target="_blank">application</a> is giving errors, that time it always becomes a headache for a <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development" target="_blank">developer</a> to test each things even whole project sometimes to find a smaller errors (by means of error here we are not talking about logical errors, we talking about exceptions which mostly responsible for errors in the application), there are many exceptions .net framework fires which we never come to find out while debugging or developing the application. Those exceptions never affect directly to the <a href="http://www.dhanashree.com/web-development-services/web-software-application-development" target="_blank">application</a> but each small exception puts the unnecessary load on the server.</p>
<p>Here is the solution to track each and every smallest things happening inside your <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">asp.net web application</a>. Which I named as “<strong>Custom error tracking library</strong>”</p>
<p><strong><em>Custom error tracking library</em></strong></p>
<p>Very first question will come is that, what is the core concept for this.</p>
<p>Concept is like we will be maintaining an XML file with a predefined structure which I have built which will contain all the required fields as nodes and subs. Which we call as <strong>errorlog.xml</strong></p>
<p>There will be a CS library file which will track each and every minor errors/exceptions happens inside the <a href="http://www.dhanashree.com/web-development-services/web-software-application-development" target="_blank">application</a> or .net framework and will put the error details inside the XML file.</p>
<p>Once we got CS library ready with us we just have to a simple function with 2 overload methods as per requirement in each <strong>try/catch</strong> blocks of the code and also in <strong>Application_Error </strong>event of <strong>Global.asax</strong> file.</p>
<h3><em>XML File (errorlog.xml)</em></h3>
<p>&lt;?xml version=”1.0″ encoding=”utf-8″?&gt;</p>
<p>&lt;errorlog&gt;</p>
<p>&lt;error&gt;</p>
<p>&lt;datetime&gt;datetime&lt;/datetime&gt;</p>
<p>&lt;filename&gt;filename&lt;/filename&gt;</p>
<p>&lt;classname&gt;classname&lt;/classname&gt;</p>
<p>&lt;methodname&gt;methodname&lt;/methodname&gt;</p>
<p>&lt;errormethod&gt;errormethod&lt;/errormethod&gt;</p>
<p>&lt;messsage&gt;ErrorMessage&lt;/messsage&gt;</p>
<p>&lt;errordetails&gt;Details goes here&lt;/errordetails&gt;</p>
<p>&lt;IP&gt;IP adress&lt;/IP&gt;</p>
<p>&lt;url&gt;URL&lt;/url&gt;</p>
<p>&lt;/error&gt;</p>
<p>&lt;error&gt;</p>
<p><strong>&lt;/</strong><strong>errorlog</strong><strong>&gt;</strong></p>
<p>Root node of XLM file will be <strong>&lt;errorlog&gt;&lt;/errorlog&gt;</strong> inside root node there will be a sub node  <strong>&lt;error&gt;&lt;/error&gt;</strong> which will get duplicated for each error. For each error, library will generate a node will all the below listed details in XML file. Next to last error node. So for each error there will be a seaprate ERROR node.</p>
<p>Each fields of the above XML file is descibed beloe :</p>
<ol>
<li><strong>1. </strong><strong>Datetime : </strong>date and time of the error/exception<strong> </strong></li>
<li><strong>2. </strong><strong>File name : </strong>file name where exception or error happens<strong> </strong></li>
<li><strong>3. </strong><strong>Class name : </strong>classname in which error occurred<strong> </strong></li>
<li><strong>4. </strong><strong>Methodname : </strong>function name where errored<strong> </strong></li>
<li><strong>5. </strong><strong>Errormethod :</strong> name of the function which contains error code.<strong> </strong></li>
<li><strong>6. </strong><strong>Message : </strong>error message/exception message<strong> </strong></li>
<li><strong>7. </strong><strong>Error details: </strong>detailed error description which will show whole<strong>stack trace</strong> of the functional execution.<strong> </strong></li>
<li><strong>8. </strong><strong>IP : </strong>client IP address<strong> </strong></li>
<li><strong>9. </strong><strong>URL : </strong>absolute error ULR<strong> </strong></li>
</ol>
<p><strong> </strong></p>
<p><strong> </strong></p>
<h3><em>CS library</em></h3>
<p>There will be a CS library file where we will write all functionality for error handling and writing errors into XML file.</p>
<p><strong>errorHamdler.cs </strong>file will<strong> </strong>have 2 statis methods named <strong>WriteError(), </strong>there will be 2 overloaded methods for same functions with diff. parameters.</p>
<p><strong>CS file will look as given below. We name it as errorHamdler.cs</strong></p>
<h3>errorHandler.cs</h3>
<p>using System;</p>
<p>using System.Collections.Generic;</p>
<p>using System.Text;</p>
<p>using System.Xml;</p>
<p>using System.Reflection;</p>
<p>using System.Diagnostics;</p>
<p>namespace code_center</p>
<p>{</p>
<p>public class errorHandler</p>
<p>{</p>
<p>string _strErrorMessage, _strDetails, _strClassName, _strMethodName;</p>
<p>DateTime _dtOccuranceTime = new DateTime();</p>
<p>public errorHandler()</p>
<p>{</p>
<p>}</p>
<p>public errorHandler(DateTime time, string className, string methodName, string errorMessage, string details)</p>
<p>{</p>
<p>_dtOccuranceTime = time;</p>
<p>_strClassName = className;</p>
<p>_strDetails = details;</p>
<p>_strErrorMessage = errorMessage;</p>
<p>_strMethodName = methodName;</p>
<p>}</p>
<p>public static void WriteError(Exception ex)</p>
<p>{</p>
<p>WriteError(ex, “”);</p>
<p>}</p>
<p><strong>public static void WriteError(Exception ex, string fileName)</strong></p>
<p>{</p>
<p>XmlDocument doc = new XmlDocument();</p>
<p>string strRootPath = System.Configuration.ConfigurationManager.AppSettings["logfilepath"].ToString();</p>
<p>string xmlPath = System.Web.HttpContext.Current.Server.MapPath(strRootPath);</p>
<p>doc.Load(@xmlPath);</p>
<p>XmlNode newXMLNode, oldXMLNode;</p>
<p>oldXMLNode = doc.ChildNodes[1].ChildNodes[0];</p>
<p>newXMLNode = oldXMLNode.CloneNode(true);</p>
<p>StackTrace stackTrace = new StackTrace();</p>
<p>StackFrame stackFrame = stackTrace.GetFrame(1);</p>
<p>MethodBase methodBase = stackFrame.GetMethod();</p>
<p>newXMLNode.ChildNodes[0].InnerText = DateTime.Now.ToString();</p>
<p>newXMLNode.ChildNodes[1].InnerText = fileName;</p>
<p>newXMLNode.ChildNodes[2].InnerText = methodBase.DeclaringType.FullName;</p>
<p>newXMLNode.ChildNodes[3].InnerText = methodBase.Name;</p>
<p>newXMLNode.ChildNodes[4].InnerText = ex.TargetSite.Name;</p>
<p>newXMLNode.ChildNodes[5].InnerText = ex.Message;</p>
<p>newXMLNode.ChildNodes[6].InnerText = ex.StackTrace;</p>
<p>newXMLNode.ChildNodes[7].InnerText = System.Web.HttpContext.Current.Request.UserHostAddress;</p>
<p>newXMLNode.ChildNodes[8].InnerText = System.Web.HttpContext.Current.Request.Url.OriginalString;</p>
<p>doc.ChildNodes[1].AppendChild(newXMLNode);</p>
<p>doc.Save(@xmlPath);</p>
<p>doc.RemoveAll();</p>
<p>}</p>
<p>}</p>
<p>}</p>
<p>In above code there is a line “string strRootPath = System.Configuration.ConfigurationManager.AppSettings["logfilepath"].ToString();”</p>
<p>We need to give XML file path also where we have placed XML file in the project, so just have to add 1 line in web.config file as given below to store actual XML file path, which will be used in abiove functon.</p>
<h3><em>Code inside web.config</em></h3>
<p>&lt;appSettings&gt;</p>
<p>&lt;add key=”logfilepath” value=”~/errorHandling/errorlog.xml”/&gt;</p>
<p>&lt;/appSettings&gt;</p>
<h1><em>How to use error handler in application</em></h1>
<p>Now everything is ready to be used in real time<a href="http://www.dhanashree.com/web-development-services/web-software-application-development" target="_blank"> application</a>. In each <strong>try/catch</strong>block we have to call</p>
<p><strong>Writeerror()</strong> function as described below .</p>
<h3><em>Code inside Default.aspx.vb</em></h3>
<p>protected void Page_Load(object sender, EventArgs e)</p>
<p>{</p>
<p>try</p>
<p>{</p>
<p>throw new Exception(“Custom error”);</p>
<p>}</p>
<p>catch (Exception ex)</p>
<p>{</p>
<p>Response.Write(ex.Message);</p>
<p><strong>code_center.errorHandler.WriteError(ex, “Default.aspx.vb”);</strong></p>
<p>}</p>
<p>}</p>
<p>Apart from each <strong>try/catch</strong> blocks we will put some code in <strong>Global.asax </strong>file also, as given below.</p>
<p>void Application_Error(object sender, EventArgs e)</p>
<p>{</p>
<p>code_center.errorHandler.WriteError(Server.GetLastError().GetBaseException(), “Global.asax”);</p>
<p>}</p>
<p>The reason behind putting code in Global.asax file is very important and necessory as there might be many exceptions which occurs at application level and canot be tracable in any <strong>try/catch</strong> blocks in any function or events. So anyerror except try/catch blocks will come in this event (Application_Error) and will get inserted intoXML file.</p>
<p>That’s it, we have done with the error handling, and all errors will be tractable from the XML file which is being generated via the error handler.</p>
</div>
<p><span style="text-decoration: underline;"><strong><em><br />
</em></strong></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="color: red;" lang="EN-IN"><span style="font-size: 11pt;"><span style="font-family: Calibri;"><br />
NOTE<span style="mso-spacerun: yes;"> </span>:</span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">If you are in need of any </span><a href="http://dhanashree.com/web-development-services/asp-php-web-development" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">Web Development</span></a><span style="font-size: 11pt; font-family: Calibri;"> feel free to <span style="text-decoration: underline;"><a href="http://dhanashree.com/contact-web-designing-company" target="_blank">Inquire us</a></span> .<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a></span>. Expertise in <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">Asp.net Development</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/lamp-development-php-web-designing" target="_blank">Php Development</a></span>,<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/website-designing" target="_blank">Website designing</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/open-source-wordpress-joomla-oscommerce-customisation" target="_blank">Open Source customisation</a></span>. <span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a> </span>can be our <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/offshore-website-designing-company" target="_blank">offshore development company</a></span> / </span><a href="http://dhanashree.com/web-designing-outsource-advantages" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">outsourcing</span></a><span style="font-size: 11pt; font-family: Calibri;"> <span style="text-decoration: underline;"><a href="http://dhanashree.com/dhanashree-web-development-profile" target="_blank">web development company</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">hire dedicated web programmers</a></span>.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">Above information is for knowledge sharing<span style="mso-spacerun: yes;"> </span>if you have problem / issue / suggestion please intimate us with details for proper and prompt action.</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://techinsight.dhanashree.com/custom-error-tracking-library-in-asp-net-using-xml-c/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>List of technology which can be adopted into development</title>
		<link>http://techinsight.dhanashree.com/list-of-technology-which-can-be-adopted-into-development/</link>
		<comments>http://techinsight.dhanashree.com/list-of-technology-which-can-be-adopted-into-development/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 07:51:15 +0000</pubDate>
		<dc:creator>kiran</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tools & Technology]]></category>
		<category><![CDATA[Web Developement]]></category>
		<category><![CDATA[.net developement]]></category>
		<category><![CDATA[asp.net developement]]></category>
		<category><![CDATA[C#.net]]></category>

		<guid isPermaLink="false">http://dhanashree.com/techblog/?p=77</guid>
		<description><![CDATA[Business Intelligence Application Development
 
Companies are investing millions of dollars in ERP solutions or have invested till date to improve the way they conduct their business. While ERP provides significant benefits organizations are finding that, in order to achieve critical decision making business goals, they often need to supplement it with additional external reporting capabilities [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Business Intelligence <a href="http://www.dhanashree.com/web-development-services/web-software-application-development" target="_blank">Application Development</a></strong></p>
<p><strong> </strong></p>
<p>Companies are investing millions of dollars in ERP solutions or have invested till date to improve the way they conduct their business. While ERP provides significant benefits organizations are finding that, in order to achieve critical decision making business goals, they often need to supplement it with additional external reporting capabilities for it end users. With the wealth of data entered and stored in ERP databases the ability to analyze and interpret the data is significant for management reporting. With Business Intelligence tool, it has greatly alleviated the backlog of report requests and has provided users with decision making information in a timely manner.</p>
<p>Business Intelligence is a method of storing and presenting key enterprise data so that anyone in your company can quickly and easily ask questions of accurate and timely data. Effective BI allows end users to use data to understand why your business got the particular results that it did, to decide on courses of action based on past data, and to accurately forecast future  results.</p>
<p>BI data is displayed in a fashion that is appropriate to each type of user, i.e. analysts will be able to drill into detailed data, executives will see timely summaries, and middle managers will see data presented at the level of detail that they need to make good business decisions. Microsoft’s BI uses cubes, rather than tables, to store information and presents information via reports. The reports can be presented to end users in a variety of formats:Windows applications,<a href="http://www.dhanashree.com/web-development-services/asp-php-web-development" target="_blank">Web Applications</a>, and Microsoft BI client tools, such</p>
<p>as Excel or SQL Reporting Services.</p>
<p>Need for the BI application:</p>
<p>Check out following article where it is explain what is the important of BI application</p>
<p><a href="http://www.cio.com/article/153500/Need_for_Business_Intelligence_Grows_Too_Much_Information_Not_Enough_Insight">http://www.cio.com/article/153500/Need_for_Business_Intelligence_Grows_Too_Much_Information_Not_Enough_Insight</a></p>
<p>Microsoft products involved in BI <a href="http://www.dhanashree.com/web-development-services/web-software-application-development" target="_blank">application development</a>:</p>
<p><strong>SQL Server 2005</strong>: This is the preferred staging and, possibly, source location for BI solutions. Data can actually be retrieved from a variety of data stores (Oracle, DB2, and so on), so a SQL Server installation is not strictly required to build a Microsoft BI solution. However, due to the integration of some key toolsets that are part of nearly all BI solutions—for example, SSIS or SQL Server Integration Services, which is usually used to perform the ETL of source data into the data warehouse—most BI solutions will include at least one SQL Server 2005 installation. Another key component in many BI solutions is SQL Server Reporting Services (SSRS). When working with SQL Server to perform OLAP administrative tasks, you will use the management interface, which is called SQL Server Management Studio (SSMS).</p>
<p><strong>SQL Server Analysis Service</strong>: This is the core server in Microsoft’s BI solution. SSAS provides storage for the data used in cubes for your data warehouse.</p>
<p><strong>SQL Server 2005 Integration Service</strong>: This toolset is a key component in most BI solutions that is used to import, cleanse, and validate data prior to making the data available to the  analysis Services for reporting purposes. It is typical to use data from many disparate sources (relational, flat file, XML, and so on) as source data to a data warehouse. For this reason, a sophisticated toolset, such as SSIS is used to facilitate the complex data loads that are often common to BI solutions. As stated earlier, this functionality is often called ETL (Extract, Transform, and Load) in a BI solution.</p>
<p><strong>SQL Server 2005 Reporting Service</strong>: This is an optional component for your BI solution.</p>
<p><strong>Excel 2003 and 2007: </strong>This is another optional component for your BI solution. Many  companies already own Office 2003, so use of Excel as a BI client is often attractive for its low cost and (relatively) low training curve.</p>
<p><strong> </strong></p>
<p>Apart from Microsoft BI solution, there are number of other solution provider are there in market.</p>
<p>Following are the list of BI solution &amp; tools provider</p>
<p>Cognos: <a href="http://www.cognos.com/products/cognos8businessintelligence/index.html">http://www.cognos.com/products/cognos8businessintelligence/index.html</a></p>
<p>SAP: <a href="http://www.sap.com/solutions/netweaver/components/bi/index.epx">http://www.sap.com/solutions/netweaver/components/bi/index.epx</a></p>
<p>Business Object: <a href="http://www.uk.businessobjects.com/products/platform/enterprise.asp">http://www.uk.businessobjects.com/products/platform/enterprise.asp</a></p>
<p>Oracle: <a href="http://www.oracle.com/solutions/business_intelligence/index.html">http://www.oracle.com/solutions/business_intelligence/index.html</a></p>
<p><strong><span style="text-decoration: underline;"><br />
</span></strong></p>
<p><strong><span style="text-decoration: underline;"> </span></strong></p>
<p><strong><span style="text-decoration: underline;">SharePoint Portal Service/Server</span></strong></p>
<p><strong><span style="text-decoration: underline;"> </span></strong></p>
<p>Microsoft Windows SharePoint Services 3.0 is a versatile technology that organizations and business units of all sizes can use to increase the efficiency of business processes and improve team productivity. With tools for collaboration that help people stay connected across organizational and geographic boundaries, Windows SharePoint Services gives people access to information they need.</p>
<p>Built on Microsoft Windows Server 2003, Windows SharePoint Services also provides a  foundation platform for building <a href="http://www.dhanashree.com/web-development-services/web-software-application-development/business-communication-sytems" target="_blank">Web-based business applications</a> that can flex and scale easily to meet the changing and growing needs of your business. Robust administrative controls for managing storage and Web infrastructure give IT departments a cost-effective way to implement and manage a high-performance collaboration environment. With a familiar, <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development" target="_blank">Web-based interface</a> and close integration with everyday tools including the Microsoft Office system, Windows SharePoint Services is easy to use and can be deployed rapidly</p>
<p>Need of SharePoint?</p>
<p>• As companies grow so does the amount of their files. It soon becomes difficult to keep track of the multiplying documents and their locations.  SharePoint overcomes this by allowing you to store and share your files in a central site.</p>
<p>• Sharing work files through email is a cumbersome process.  SharePoint eliminates this by allowing files to be stored in one location, allowing easy access to all team members.</p>
<p>• Business Intelligence has traditionally remained in the hands of a few key decision makers within organizations.  For years, it has been the goal of BI providers to “democratize business intelligence” by making it available to all levels of workers throughout companies.  With the addition of PerformancePoint to the SharePoint Enterprise version of SharePoint, this vision is realized, finally taking business intelligence out of the hands of the few and into the hands of many.</p>
<p>• Today’s work occurs over multiple locations, whether it is in different countries, office locations, separate departments or at your home office. SharePoint enables teams and individuals to connect and collaborate together regardless of where they are located.</p>
<p>• Surveys have shown that employees can spend up to 20 – 30 % of their day searching for data and information.  SharePoint eliminates this drag on productivity by providing the robust search functionality needed to find the information and expertise buried in the thousands, or hundreds of thousands of files a company generates in the course of business.</p>
<p>• It’s difficult and time consuming to create and maintain sites.  SharePoint allows anyone to <a href="http://www.dhanashree.com/web-development-services" target="_blank">create sites</a> for use within their company’s Intranet, as they are needed, whether they are departmental sites, document libraries, meetings sites, survey sites, or discussion boards.</p>
<p>Ref: <a href="http://office.microsoft.com/en-us/sharepointserver/FX100492001033.aspx">http://office.microsoft.com/en-us/sharepointserver/FX100492001033.aspx</a></p>
<p><strong><span style="text-decoration: underline;"><br />
</span></strong></p>
<p><strong><span style="text-decoration: underline;">iPhone Application Development</span></strong></p>
<p><strong><span style="text-decoration: underline;"> </span></strong></p>
<p><strong><span style="text-decoration: underline;"> </span></strong></p>
<p>iPhone is Revolutionary device which is designed and marketed by Apple Inc. iPhone provides downgraded version of OS framework to Mac OS X framework. iPhone has Cocoa Touch Framework.</p>
<p>Development tools involved in <a href="http://www.dhanashree.com/web-development-services/mobile-application-iphone-application-anoroid-development" target="_blank">IPhone application development</a>:</p>
<p><strong>XCode</strong>: Complete <a href="http://www.dhanashree.com/web-development-services" target="_blank">development</a> environment provides project management, a powerful source editor, and a graphical debugger</p>
<p><strong>iPhone Simulator</strong>: Run, test, and debug your <a href="http://www.dhanashree.com/web-development-services/web-software-application-development" target="_blank">application</a> locally on your Mac using a simulated iPhone</p>
<p><strong>Instruments</strong>: Collect, display, and compare performance data graphically in real-time to optimize your application.</p>
<p><strong>Interface Builder: </strong>Interface Builder makes <a href="http://www.dhanashree.com/web-development-services/website-designing" target="_blank">designing</a> a user interface as easy as drag and drop.</p>
<p>The more detail on the <a href="http://www.dhanashree.com/web-development-services/mobile-application-iphone-application-anoroid-development" target="_blank">iPhone application development</a>, check out the official “iPhone Developer Program” website.</p>
<p><a href="http://developer.apple.com/iphone/program/">http://developer.apple.com/iphone/program/</a></p>
<p><strong><em><span style="text-decoration: underline;">Development Related</span></em></strong></p>
<p><strong> </strong></p>
<p><strong><span style="text-decoration: underline;">ORM</span></strong></p>
<p>Object-relational mapping is used to map object-oriented programming objects to relational databases managed by Oracle, DB2, Sybase, and other relational database managers (RDBMSs). This site provides facts about object-relational mapping products, architecture problem-solving, and direction in product comparison and selection.</p>
<p>Object-relational mapping products are designed to work well with object programming languages such as C#, C++, and Java. Database objects appear as programming language objects. Often, the interface for object-relational mapping products is the same as the interface for object-oriented databases.</p>
<p><strong>ORM tools for .Net</strong></p>
<p>ADO.NET Entity Framework is an <a title="Object-relational mapping" href="http://en.wikipedia.org/wiki/Object-relational_mapping">object-relational mapping</a> (ORM) framework for the <a title=".NET Framework" href="http://en.wikipedia.org/wiki/.NET_Framework">.NET Framework</a>. This framework is an ORM offering from Microsoft for the <a title=".NET Framework" href="http://en.wikipedia.org/wiki/.NET_Framework">.NET Framework</a></p>
<p><a href="http://www.dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">ADO.NET</a> Entity Framework is included with <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">.NET</a> Framework 3.5 Service Pack 1 and <a title="Microsoft Visual Studio" href="http://en.wikipedia.org/wiki/Microsoft_Visual_Studio">Visual Studio 2008</a> Service Pack 1, released on 11 Aug 2008. It also includes the capability of executing <a title="Language Integrated Query" href="http://en.wikipedia.org/wiki/Language_Integrated_Query">LINQ</a> against ADO.NET Entity Framework entities.</p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong>ORM for PHP</strong></p>
<p><strong> </strong></p>
<p>There are several tools available right now for implementing ORM technique in PHP.</p>
<p>Following are the list of few ORM tools which can be used with PHP.</p>
<ul>
<li><a href="http://cakephp.org/">CakePHP</a>’s ORM layer</li>
<li><a href="http://www.symfony-project.org/">Symfony</a></li>
<li><a href="http://www.phpdoctrine.org/">Doctrine</a></li>
<li><a href="http://propel.phpdb.org/trac/">Propel</a></li>
</ul>
<p>Check out following articles which demonstrate you in detail ORM implementation in PHP.</p>
<p><a href="http://www.developertutorials.com/blog/php/getting-started-with-orm-in-php-331/">http://www.developertutorials.com/blog/php/getting-started-with-orm-in-php-331/</a><br />
<strong><span style="text-decoration: underline;">Microsoft .Net 3.5</span></strong></p>
<p>There are several .NET language enhancements to be introduced with Visual Studio 2008 including implicitly typed variables, extension methods, anonymous types, object initializers, collection initializers and automatic properties. These language enhancements, along with features like generics, are critical to the use of some of the new features, such as LINQ with the ADO.NET Entity Framework.</p>
<p>These are the such enhancements in .net framework which really can bust development as well as productivity of <a href="http://www.dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">developers</a>.</p>
<p>Following are the few of articles which demonstrate the practical usage of new .net framework 3.5 enhancement.</p>
<p><a href="http://www.simple-talk.com/dotnet/.net-framework/.net-3.5-language-enhancements/">http://www.simple-talk.com/dotnet/.net-framework/.net-3.5-language-enhancements/</a></p>
<p><strong><span style="text-decoration: underline;">MVC framework</span></strong></p>
<p>MVC is a framework methodology that divides an application&#8217;s implementation into three component roles: models, views, and controllers.</p>
<ul>
<li>&#8220;Models&#8221;      in a MVC based application are the components of the application that      are responsible for maintaining state.  Often this state is      persisted inside a database (for example: we might have a Product class      that is used to represent order data from the Products table inside SQL).</li>
</ul>
<ul>
<li>&#8220;Views&#8221;      in a MVC based application are the components responsible for      displaying the application&#8217;s user interface.  Typically      this UI is created off of the model data (for example: we might      create an Product &#8220;Edit&#8221; view that surfaces textboxes, dropdowns      and checkboxes based on the current state of a Product object).</li>
</ul>
<ul>
<li>&#8220;Controllers&#8221;      in a MVC based application are the components responsible for      handling end user interaction, manipulating the model, and ultimately      choosing a view to render to display UI.  In a MVC application the      view is only about displaying information &#8211; it is the controller that      handles and responds to user input and interaction.</li>
</ul>
<p>One of the benefits of using a MVC methodology is that it helps enforce a clean separation of concerns between the models, views and controllers within an <a href="http://www.dhanashree.com/web-development-services/web-software-application-development" target="_blank">application</a>.  Maintaining a clean separation of concerns makes the testing of applications much easier, since the contract between different application components are more clearly defined and articulated.</p>
<p>The MVC pattern can also help enable red/green <a href="http://en.wikipedia.org/wiki/Test-driven_development" target="_blank">test driven development</a> (TDD) &#8211; where you implement automated unit tests, which define and verify the requirements of new code, first before you actually write the code itself.</p>
<p><strong>MVC Framework for .NET</strong></p>
<p>The <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">ASP.NET</a> MVC framework provides an alternative to the ASP.NET Web Forms pattern for creating MVC-based <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development" target="_blank">Web applications</a></p>
<p>Check out following articles for the overview of ASP.NET MVC framework</p>
<p><em><a href="http://www.asp.net/learn/mvc/tutorial-01-cs.aspx">http://www.asp.net/learn/mvc/tutorial-01-cs.aspx</a></em></p>
<p><em> </em></p>
<p><strong>MVC Framework for PHP</strong></p>
<p>php.MVC implements the Model-View-Controller (MVC) design pattern, and encourages application design based on the Model 2 paradigm. This design model allows the Web page or other contents (View) to be mostly separated from the internal application code (Controller/Model), making it easier for <a href="http://www.dhanashree.com/web-development-services/website-designing/website-designing-services" target="_blank">designers</a> and <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development" target="_blank">programmers</a> to focus on their respective areas of expertise.</p>
<p>Reference: <a href="http://www.phpmvc.net/">http://www.phpmvc.net/</a><br />
<strong><span style="text-decoration: underline;">IIS Search Engine Optimization Toolkit</span></strong></p>
<p>The IIS <a href="http://www.dhanashree.com/web-development-services/search-engine-promotion-submission" target="_blank">Search Engine Optimization</a> (SEO) Toolkit helps <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development" target="_blank">Web developers</a>, hosting providers, and Web server administrators to improve their Web site’s relevance in search results by recommending how to make the site content more search engine-friendly. The IIS <a href="http://www.dhanashree.com/web-development-services/search-engine-promotion-submission" target="_blank">SEO</a> Toolkit includes the Site Analysis module, the Robots Exclusion module, and the Sitemaps and Site Indexes module, which let you perform detailed analysis and offer recommendations and editing tools for managing your Robots and Sitemaps files.</p>
<p>The components of IIS Search Engine Optimization Toolkit include the following features:</p>
<ol>
<li>Site Analysis:</li>
</ol>
<p>1.1. Fully featured site crawling engine &#8211; in order to perform detailed analysis of site&#8217;s structure and content, Site Analysis tool uses a built-in web crawler, called &#8220;iisbot&#8221;, to download and cache all the publicly available web site content. The web crawler is fully compliant with robots exclusion protocol.</p>
<p>1.2. Report summary dashboard &#8211; the results of site analysis are presented in an easy to use dashboard page that serves as a start page for various types of analysis. In addition this page includes a large set of pre-built queries for most common reports.</p>
<p>1.3. Query builder &#8211; Site Analysis tool includes a powerful and flexible query builder user interface that lets you create any custom queries that are run against the cached web site content.</p>
<p>1.4.  Detailed URL information &#8211; you can obtain various detailed information about every URL in your web site, such as response headers and content, the pages that link to that URL as well as all the referenced URLs.</p>
<p>1.5. Detailed Violations descriptions &#8211; each content or SEO violation found on a web site has a detailed description as well as a recommended corrective action.</p>
<p>1.6. Word Analysis &#8211; any web page can be analyzed with regards to the most commonly used words and phrases within the content of that page. The results of that analysis can be used to select the keywords that most accurately describe the content of the page.</p>
<p>1.7. Route Analysis &#8211; unique routes to any page can be displayed in a separate report. This kind of information helps better understand how search engine and site visitors reach a particular page on your web site.</p>
<ol>
<li>Robots Exclusion</li>
</ol>
<p>2.1.   User interface for editing robots.txt file &#8211; the content of the robots exclusion file &#8211; robots.txt &#8211; can be edited by using IIS Manager GUI</p>
<p>2.2. Selecting URL paths from physical view of web site &#8211; the paths that are specified for &#8220;Allow&#8221; and &#8220;Disallow&#8221; directives in robots.txt file can be selected from the physical file system layout of your web site.</p>
<p>2.3. Selecting URL paths from virtual view of web site &#8211; the paths that are specified for &#8220;Allow&#8221; and &#8220;Disallow&#8221; directives in robots.txt file can be selected from the logical view of your web site obtained from the results of site analysis.</p>
<ol>
<li>Sitemaps and Sitemap Indexes</li>
</ol>
<p>3.1. User interface for managing sitemap and sitemap indexes files &#8211; the content of the sitemap and indexes files can be edited by using IIS Manager GUI</p>
<p>3.2. Selecting URLs from physical view of web site &#8211; the URLs that are specified within a sitemap can be selected from the physical file system layout of your web site.</p>
<p>3.3. Selecting URLs from virtual view of web site &#8211; the URLs that are specified within a sitemap can be selected from the logical view of your web site obtained from the results of site analysis.</p>
<p><strong><span style="text-decoration: underline;">Rich Internet Application Tools</span></strong></p>
<p><strong><span style="text-decoration: underline;"> </span></strong></p>
<p><strong>Adobe AIR</strong></p>
<p>The Adobe® AIR™ runtime lets <a href="http://www.dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">developers</a> use proven <a href="http://www.dhanashree.com/web-development-services" target="_blank">web technologies</a> to build rich <a href="http://www.dhanashree.com/web-development-services/web-software-application-development/supply-chain-management" target="_blank">Internet applications</a> that run outside the browser on multiple operating systems.</p>
<p>Adobe AIR is divided into 3 different categories as per the expertise of particular <a href="http://www.dhanashree.com/web-development-services/dedicated-php-dotnet-developer/dedicated-development-team" target="_blank">developer</a>.</p>
<p>AJAX: <a href="http://www.adobe.com/products/air/develop/ajax/">http://www.adobe.com/products/air/develop/ajax/</a></p>
<p>AIR with Flex : <a href="http://www.adobe.com/products/air/develop/flex/">http://www.adobe.com/products/air/develop/flex/</a></p>
<p>AIR with flash: <a href="http://www.adobe.com/products/air/develop/flash/">http://www.adobe.com/products/air/develop/flash/</a></p>
<p><strong>Google Web toolkit</strong></p>
<p>Google Web Toolkit 1.6 is a unique and remarkable platform-independent Java to JavaScript cross-compiler. The whole application may be written using most of the Java 1.5 features for which there is much tooling and test support. Not only that, but it is also possible to follow the Model View Controller (MVC) approach separating user interface from business logic, reducing cost of maintenance and increasing development flexibility. DOJO, on the other hand, requires you to develop the client using only the JavaScript language. This can be much more time consuming and more difficult to work with<strong> </strong></p>
<p><a href="http://code.google.com/webtoolkit/">http://code.google.com/webtoolkit/</a></p>
<p><strong>jQuery</strong></p>
<p>jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid <a href="http://www.dhanashree.com/dhanashree-web-development-profile" target="_blank">web development</a>. jQuery is designed to change the way that you write JavaScript.</p>
<p><a href="http://jquery.com/">http://jquery.com/</a></p>
<p><strong>Yahoo User Interface</strong></p>
<p>The YUI Library is a set of utilities and controls, written in JavaScript, for building richly <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">interactive web applications</a> using techniques such as DOM scripting, DHTML and AJAX</p>
<p><a href="http://developer.yahoo.com/yui/">http://developer.yahoo.com/yui/</a></p>
<p>Apart from these library/toolkits, there are several other toolkits which can also be utilized.</p>
<p>Mootools: <a href="http://mootools.net/">http://mootools.net/</a></p>
<p>Dojo: <cite><a href="http://www.dojotoolkit.org/">www.<strong>dojo</strong>toolkit.org/</a></cite></p>
<p>List of other toolkits: <a href="http://www.javascriptlibraries.com/">http://www.javascriptlibraries.com/</a></p>
<p><strong>Tools for Web Development &amp; Testing</strong></p>
<p>Following are few exiting tools for the <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development/lamp-development-php-web-designing" target="_blank">web development</a> testing.</p>
<ol>
<li>XenoCode Browser SandboxBrowser testing is one of the most tedious and frustrating parts of <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development" target="_blank">web development</a>. What <a href="http://www.dhanashree.com/web-development-services/website-designing/website-designing-services" target="_blank">designer</a> or programmer hasn’t screamed bloody murder at broken alignments in Internet Explorer 6? One of the difficult parts of browser testing is that no developer can have every browser type on a single computer for proper testing.Enter XenoCode Browser Sandbox, a series of virtual applications that can run all popular browsers simultaneously. It does not even require the installation of software. However, XenoCode (Xenocode)’s Browser Sandbox can be heavy in some browsers and is still lacking in a Mac version.Use the following URL for further instruction on how to make use of such toolsRef: <a href="http://www.xenocode.com/browsers/">http://www.xenocode.com/browsers/</a></li>
<li>W3C Validation ServicesW3C is THE standard in all of web validation. The W3C Validator looks into the markup of any website and display errors based on industry standards. It comes in over a dozen languages and a dozen varieties. Here are some of the most important validators:Following are the popular validation services provided by W3C<a href="http://validator.w3.org/" target="_blank">W3C Markup Validation</a><br />
<a href="http://jigsaw.w3.org/css-validator/" target="_blank">W3C CSS Validation</a><br />
<a href="http://validator.w3.org/checklink" target="_blank">W3C Link Checker</a><br />
<a href="http://validator.w3.org/mobile/" target="_blank">W3C mobileOK Checker</a></li>
<li>Javascript &amp; CSS minifyHere is the site which allows you to minify javascript and perhaps the css also<a href="http://www.vlead.in/resources/tools/minify-javascript/index.php">http://www.vlead.in/resources/tools/minify-javascript/index.php</a></li>
</ol>
<p>Following are the list of few articles which can also be referenced for different area of</p>
<p><strong>Web development tools</strong></p>
<p>There are many other tools available over the internet which can be utilized in daily <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development" target="_blank">web development</a>.</p>
<p>Check out following link to improve your productivity</p>
<p><a href="http://mashable.com/2008/11/01/web-development-tools/">http://mashable.com/2008/11/01/web-development-tools/</a></p>
<p><strong>Web 2.0 application &amp; tools</strong></p>
<p><em><a href="http://www.go2web20.net/">http://www.go2web20.net</a></em></p>
<p><span style="text-decoration: underline;"><strong><em><br />
</em></strong></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="color: red;" lang="EN-IN"><span style="font-size: 11pt;"><span style="font-family: Calibri;"><br />
NOTE<span style="mso-spacerun: yes;"> </span>:</span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">If you are in need of any </span><a href="http://dhanashree.com/web-development-services/asp-php-web-development" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">Web Development</span></a><span style="font-size: 11pt; font-family: Calibri;"> feel free to <span style="text-decoration: underline;"><a href="http://dhanashree.com/contact-web-designing-company" target="_blank">Inquire us</a></span> .<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a></span>. Expertise in <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">Asp.net Development</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/lamp-development-php-web-designing" target="_blank">Php Development</a></span>,<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/website-designing" target="_blank">Website designing</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/open-source-wordpress-joomla-oscommerce-customisation" target="_blank">Open Source customisation</a></span>. <span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a> </span>can be our <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/offshore-website-designing-company" target="_blank">offshore development company</a></span> / </span><a href="http://dhanashree.com/web-designing-outsource-advantages" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">outsourcing</span></a><span style="font-size: 11pt; font-family: Calibri;"> <span style="text-decoration: underline;"><a href="http://dhanashree.com/dhanashree-web-development-profile" target="_blank">web development company</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">hire dedicated web programmers</a></span>.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">Above information is for knowledge sharing<span style="mso-spacerun: yes;"> </span>if you have problem / issue / suggestion please intimate us with details for proper and prompt action.</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://techinsight.dhanashree.com/list-of-technology-which-can-be-adopted-into-development/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Storing and Retrieving image in SQL server 2005 &amp; asp.net using large value data type &amp; HTTP handler</title>
		<link>http://techinsight.dhanashree.com/storing-and-retrieving-image-in-sql-server-2005-asp-net-using-large-value-data-type-http-handler/</link>
		<comments>http://techinsight.dhanashree.com/storing-and-retrieving-image-in-sql-server-2005-asp-net-using-large-value-data-type-http-handler/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 13:51:13 +0000</pubDate>
		<dc:creator>kiran</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[C#.net]]></category>
		<category><![CDATA[SQL server 2005]]></category>
		<category><![CDATA[Web Developement]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[.net developement]]></category>
		<category><![CDATA[asp.net developement]]></category>
		<category><![CDATA[SQL server]]></category>

		<guid isPermaLink="false">http://dhanashree.com/techblog/?p=22</guid>
		<description><![CDATA[ASPX page :
&#60;form id=&#8221;form1&#8243; runat=&#8221;server&#8221;&#62;
&#60;div style=&#8221;padding: 200px;&#8221;&#62;
&#60;asp:Image ID=&#8221;imagebox&#8221; runat=&#8221;server&#8221; ImageUrl=&#8221;~/sql-image-store/image-handler.ashx&#8221; /&#62;
&#60;/div&#62;
&#60;/form&#62;
Handler code: image-handler.ashx 
&#60;%@ WebHandler Language=&#8221;C#&#8221; Class=&#8221;image_handler&#8221; %&#62;
using System;
using System.Web;
using System.IO;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Configuration;
public class image_handler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string xStrCon = System.Configuration.ConfigurationManager.ConnectionStrings["conStrImage"].ConnectionString;
SqlConnection xCon = new SqlConnection(xStrCon);
xCon.Open();
SqlCommand xCom = new SqlCommand(&#8220;select * from images where&#8221;, xCon);
SqlDataAdapter xAda = new SqlDataAdapter(xCom);
DataSet ds = new [...]]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste"><strong><a href="http://www.dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">ASPX</a> page :</strong></div>
<div>&lt;form id=&#8221;form1&#8243; runat=&#8221;server&#8221;&gt;</div>
<div id="_mcePaste">&lt;div style=&#8221;padding: 200px;&#8221;&gt;</div>
<div id="_mcePaste">&lt;asp:Image ID=&#8221;imagebox&#8221; runat=&#8221;server&#8221; ImageUrl=&#8221;~/sql-image-store/image-handler.ashx&#8221; /&gt;</div>
<div id="_mcePaste">&lt;/div&gt;</div>
<div id="_mcePaste">&lt;/form&gt;</div>
<p><strong>Handler code: </strong>image-handler.ashx<strong> </strong></p>
<p>&lt;%@ WebHandler Language=&#8221;C#&#8221; Class=&#8221;image_handler&#8221; %&gt;</p>
<p>using System;</p>
<p>using System.Web;</p>
<p>using System.IO;</p>
<p>using System.Data;</p>
<p>using System.Data.Sql;</p>
<p>using System.Data.SqlClient;</p>
<p>using System.Configuration;</p>
<p>public class image_handler : IHttpHandler</p>
<p>{</p>
<p>public void ProcessRequest(HttpContext context)</p>
<p>{</p>
<p>string xStrCon = System.Configuration.ConfigurationManager.ConnectionStrings["conStrImage"].ConnectionString;</p>
<p>SqlConnection xCon = new SqlConnection(xStrCon);</p>
<p>xCon.Open();</p>
<p>SqlCommand xCom = new SqlCommand(&#8220;select * from images where&#8221;, xCon);</p>
<p>SqlDataAdapter xAda = new SqlDataAdapter(xCom);</p>
<p>DataSet ds = new DataSet();</p>
<p>xAda.Fill(ds);</p>
<p>// Image processing starts</p>
<p>byte[] bytImage = ReadFile(context.Server.MapPath(&#8220;banner.JPG&#8221;));</p>
<p>xCom.CommandText = &#8220;insert into images values(2,&#8217;kensington&#8217;,@imagedata)&#8221;;</p>
<p>xCom.Parameters.Add(new SqlParameter(&#8220;@imagedata&#8221;, (object)bytImage));</p>
<p>xCon.Close();</p>
<p>//Display image from SQL server</p>
<p>byte[] imageData = (byte[])ds.Tables[0].Rows[0][2];</p>
<p>context.Response.Clear();</p>
<p>context.Response.ContentType = &#8220;image/JPEG&#8221;;</p>
<p>context.Response.OutputStream.Write(imageData, 0, imageData.Length);</p>
<p>}</p>
<p>byte[] ReadFile(string sPath)</p>
<p>{</p>
<p>//Initialize byte array with a null value initially.</p>
<p>byte[] data = null;</p>
<p>//Use FileInfo object to get file size.</p>
<p>FileInfo fInfo = new FileInfo(sPath);</p>
<p>long numBytes = fInfo.Length;</p>
<p>//Open FileStream to read file</p>
<p>FileStream fStream = new FileStream(sPath, FileMode.Open, FileAccess.Read);</p>
<p>//Use BinaryReader to read file stream into byte array.</p>
<p>BinaryReader br = new BinaryReader(fStream);</p>
<p>//When you use BinaryReader, you need to supply number of bytes to read from file.</p>
<p>//In this case we want to read entire file. So supplying total number of bytes.</p>
<p>data = br.ReadBytes((int)numBytes);</p>
<p>return data;</p>
<p>}</p>
<p>public bool IsReusable</p>
<p>{</p>
<p>get</p>
<p>{</p>
<p>return false;</p>
<p>}</p>
<p>}</p>
<p>}</p>
<p><span style="text-decoration: underline;"><strong><em><br />
</em></strong></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="color: red;" lang="EN-IN"><span style="font-size: 11pt;"><span style="font-family: Calibri;"><br />
NOTE<span style="mso-spacerun: yes;"> </span>:</span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">If you are in need of any </span><a href="http://dhanashree.com/web-development-services/asp-php-web-development" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">Web Development</span></a><span style="font-size: 11pt; font-family: Calibri;"> feel free to <span style="text-decoration: underline;"><a href="http://dhanashree.com/contact-web-designing-company" target="_blank">Inquire us</a></span> .<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a></span>. Expertise in <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">Asp.net Development</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/lamp-development-php-web-designing" target="_blank">Php Development</a></span>,<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/website-designing" target="_blank">Website designing</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/open-source-wordpress-joomla-oscommerce-customisation" target="_blank">Open Source customisation</a></span>. <span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a> </span>can be our <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/offshore-website-designing-company" target="_blank">offshore development company</a></span> / </span><a href="http://dhanashree.com/web-designing-outsource-advantages" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">outsourcing</span></a><span style="font-size: 11pt; font-family: Calibri;"> <span style="text-decoration: underline;"><a href="http://dhanashree.com/dhanashree-web-development-profile" target="_blank">web development company</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">hire dedicated web programmers</a></span>.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">Above information is for knowledge sharing<span style="mso-spacerun: yes;"> </span>if you have problem / issue / suggestion please intimate us with details for proper and prompt action.</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://techinsight.dhanashree.com/storing-and-retrieving-image-in-sql-server-2005-asp-net-using-large-value-data-type-http-handler/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Developing custom AD rotator control with multiple Image Mapping using C#.net &amp; XML</title>
		<link>http://techinsight.dhanashree.com/developing-custom-ad-rotator-control-with-multiple-image-mapping-using-c-net-xml/</link>
		<comments>http://techinsight.dhanashree.com/developing-custom-ad-rotator-control-with-multiple-image-mapping-using-c-net-xml/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 07:48:24 +0000</pubDate>
		<dc:creator>kiran</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[C#.net]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[.net developement]]></category>
		<category><![CDATA[asp.net developement]]></category>
		<category><![CDATA[Web Developement]]></category>

		<guid isPermaLink="false">http://dhanashree.com/techblog/?p=3</guid>
		<description><![CDATA[We are all familiar with AD rotator control asp.net provides to show rotating/random ads on every page refresh.
But I found a limitation of this control while I needed to develop functionality where AD banners get changed on every page refresh as well as each banners should have multiple links which navigates to diff. URLs ( [...]]]></description>
			<content:encoded><![CDATA[<p>We are all familiar with AD rotator control asp.net provides to show rotating/random ads on every page refresh.</p>
<p>But I found a limitation of this control while I needed to develop functionality where AD banners get changed on every page refresh as well as each banners should have multiple links which navigates to diff. URLs ( multiple image mapping in each AD banners )</p>
<p>As this is not possible with AD rotator I have developed a custom asp.net control which provides all this flexibilities with all AD rotator features.</p>
<p><strong>Basic Concept:</strong></p>
<p>To make the control easy to use &amp; understand we will be keeping the concept of defining Ads same like AD rotator control using XML file.</p>
<p>Control will read the Ad banners from the XML file and render all the details with multiple image mappings in the aspx page.</p>
<p><strong>XML file structure: </strong></p>
<p>First and foremost step is to finalize the XML file structure that to be used in custom control to render the ads on random bases.</p>
<p>XML file will look as given in below sample file.</p>
<p><strong>bannes.xml</strong></p>
<p><strong> </strong></p>
<p>&lt;?xml version=”1.0″ encoding=”utf-8″ ?&gt;</p>
<p>&lt;banbers&gt;</p>
<p>&lt;banner&gt;</p>
<p>&lt;ImageUrl&gt;http://xyz.com/banner1.jpg&lt;/ImageUrl&gt;</p>
<p>&lt;AlternateText&gt;Site1 Main&lt;/AlternateText&gt;</p>
<p>&lt;mappings&gt;</p>
<p>&lt;map&gt;</p>
<p>&lt;left&gt;0&lt;/left&gt;</p>
<p>&lt;top&gt;0&lt;/top&gt;</p>
<p>&lt;right&gt;50&lt;/right&gt;</p>
<p>&lt;bottom&gt;50&lt;/bottom&gt;</p>
<p>&lt;navigateUrl&gt;google.com&lt;/navigateUrl&gt;</p>
<p>&lt;/map&gt;</p>
<p>&lt;/mappings&gt;</p>
<p>&lt;/banner&gt;</p>
<p>&lt;banner&gt;</p>
<p>&lt;ImageUrl&gt;banners/5.jpg&lt;/ImageUrl&gt;</p>
<p>&lt;AlternateText&gt;b5&lt;/AlternateText&gt;</p>
<p>&lt;mappings&gt;</p>
<p>&lt;map&gt;</p>
<p>&lt;left&gt;10&lt;/left&gt;</p>
<p>&lt;top&gt;10&lt;/top&gt;</p>
<p>&lt;right&gt;10&lt;/right&gt;</p>
<p>&lt;bottom&gt;10&lt;/bottom&gt;</p>
<p>&lt;navigateUrl&gt;google.com&lt;/navigateUrl&gt;</p>
<p>&lt;/map&gt;</p>
<p>&lt;map&gt;</p>
<p>&lt;left&gt;25&lt;/left&gt;</p>
<p>&lt;top&gt;25&lt;/top&gt;</p>
<p>&lt;right&gt;25&lt;/right&gt;</p>
<p>&lt;bottom&gt;25&lt;/bottom&gt;</p>
<p>&lt;navigateUrl&gt;google.com&lt;/navigateUrl&gt;</p>
<p>&lt;/map&gt;</p>
<p>&lt;map&gt;</p>
<p>&lt;left&gt;10&lt;/left&gt;</p>
<p>&lt;top&gt;10&lt;/top&gt;</p>
<p>&lt;right&gt;10&lt;/right&gt;</p>
<p>&lt;bottom&gt;10&lt;/bottom&gt;</p>
<p>&lt;navigateUrl&gt;google.com&lt;/navigateUrl&gt;</p>
<p>&lt;/map&gt;</p>
<p>&lt;map&gt;</p>
<p>&lt;left&gt;25&lt;/left&gt;</p>
<p>&lt;top&gt;25&lt;/top&gt;</p>
<p>&lt;right&gt;25&lt;/right&gt;</p>
<p>&lt;bottom&gt;25&lt;/bottom&gt;</p>
<p>&lt;navigateUrl&gt;google.com&lt;/navigateUrl&gt;</p>
<p>&lt;/map&gt;</p>
<p>&lt;map&gt;</p>
<p>&lt;left&gt;10&lt;/left&gt;</p>
<p>&lt;top&gt;10&lt;/top&gt;</p>
<p>&lt;right&gt;10&lt;/right&gt;</p>
<p>&lt;bottom&gt;10&lt;/bottom&gt;</p>
<p>&lt;navigateUrl&gt;google.com&lt;/navigateUrl&gt;</p>
<p>&lt;/map&gt;</p>
<p>&lt;map&gt;</p>
<p>&lt;left&gt;25&lt;/left&gt;</p>
<p>&lt;top&gt;25&lt;/top&gt;</p>
<p>&lt;right&gt;25&lt;/right&gt;</p>
<p>&lt;bottom&gt;25&lt;/bottom&gt;</p>
<p>&lt;navigateUrl&gt;google.com&lt;/navigateUrl&gt;</p>
<p>&lt;/map&gt;</p>
<p>&lt;/mappings&gt;</p>
<p>&lt;/banner&gt;</p>
<p>&lt;/banbers&gt;</p>
<p>Inside main <strong>banners</strong> TAG there will be multiple banners TAG to be added for each AD banner,</p>
<p>Each banner TAG will have child nodes(attributes) as listed below:</p>
<ol>
<li>Image URL – AD image URL to be specified here</li>
<li>Alternate text – alt attribute for image</li>
<li>Mappings  &#8211; list of all mappings with relative  <strong>left-right-top-Bottom </strong> attributes
<ol>
<li>Left – left side relative axis</li>
<li>Right – right side relative axis</li>
<li>Top– Top relative axis</li>
<li>Bottom– Bottom relative axis</li>
<li>Navigate URL – URL to navigate</li>
</ol>
</li>
</ol>
<p><strong>Developing Custom Control:</strong></p>
<p>Now next step is to build a custom asp.net control which will read the above XML structure and renders the data accordingly on ASPX page.</p>
<p><strong>C# code file will be as given below: </strong></p>
<p><strong> </strong></p>
<p><strong>ad-banners.cs</strong></p>
<p><strong> </strong></p>
<p>this control will have 1 public property where the XML file path will be given called</p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p>using System;</p>
<p>using System.Collections.Generic;</p>
<p>using System.ComponentModel;</p>
<p>using System.Text;</p>
<p>using System.Web;</p>
<p>using System.Web.UI;</p>
<p>using System.Web.UI.WebControls;</p>
<p>using System.Xml;</p>
<p>namespace InfoquestLibrary.Controls</p>
<p>{</p>
<p>[DefaultProperty("Text")]</p>
<p>[ToolboxData("&lt;{0}:banner runat=server /&gt;")]</p>
<p>public class banner : System.Web.UI.WebControls.WebControl</p>
<p>{</p>
<p>string _strImageURL, _strXMLpath;</p>
<p>[Bindable(true)]</p>
<p>[Category("Appearance")]</p>
<p>[DefaultValue("")]</p>
<p>[Localizable(true)]</p>
<p>public string ImageURL</p>
<p>{</p>
<p>get { return _strImageURL; }</p>
<p>set { _strImageURL = value; }</p>
<p>}</p>
<p>public string XMLpath</p>
<p>{</p>
<p>get { return _strXMLpath; }</p>
<p>set { _strXMLpath = value; }</p>
<p>}</p>
<p>public override void RenderBeginTag(HtmlTextWriter writer)</p>
<p>{</p>
<p>}</p>
<p>public override void RenderEndTag(HtmlTextWriter writer)</p>
<p>{</p>
<p>}</p>
<p>protected override void RenderContents(HtmlTextWriter output)</p>
<p>{</p>
<p>XmlDocument xDoc = new XmlDocument();</p>
<p>XmlNode xRandomNode;</p>
<p>bool useMapping = true;</p>
<p>int xIntRandomNumber;</p>
<p>Random r = new Random();</p>
<p>xDoc.Load(System.Web.HttpContext.Current.Server.MapPath(this.XMLpath));</p>
<p>xIntRandomNumber = r.Next(xDoc.ChildNodes[1].ChildNodes.Count);</p>
<p>xRandomNode = xDoc.ChildNodes[1].ChildNodes[xIntRandomNumber];</p>
<p>if (xRandomNode.ChildNodes[2].Equals(null))</p>
<p>{</p>
<p>useMapping = false;</p>
<p>}</p>
<p>else</p>
<p>{</p>
<p>if (xRandomNode.ChildNodes[2].ChildNodes.Count == 0)</p>
<p>useMapping = false;</p>
<p>}</p>
<p>if (xRandomNode.HasChildNodes)</p>
<p>{</p>
<p>this.ImageURL = xRandomNode.ChildNodes[0].InnerText;</p>
<p>}</p>
<p>output.AddAttribute(HtmlTextWriterAttribute.Src, this.ImageURL);</p>
<p>if (useMapping)</p>
<p>{</p>
<p>output.AddAttribute(HtmlTextWriterAttribute.Usemap, “#map” + this.ID);</p>
<p>}</p>
<p>output.AddAttribute(HtmlTextWriterAttribute.Border, “none”);</p>
<p>this.AddAttributesToRender(output);</p>
<p>output.RenderBeginTag(HtmlTextWriterTag.Img);</p>
<p>if (useMapping)</p>
<p>{</p>
<p>int xIntMaps, xIntCounter;</p>
<p>xIntMaps = xRandomNode.ChildNodes[2].ChildNodes.Count;</p>
<p>output.AddAttribute(HtmlTextWriterAttribute.Name, “map” + this.ID);</p>
<p>output.AddAttribute(HtmlTextWriterAttribute.Id, “map” + this.ID);</p>
<p>this.AddAttributesToRender(output);</p>
<p>output.RenderBeginTag(HtmlTextWriterTag.Map);</p>
<p>for (xIntCounter = 0; xIntCounter &lt; xIntMaps; xIntCounter++)</p>
<p>{</p>
<p>XmlNode xMap = xRandomNode.ChildNodes[2].ChildNodes[xIntCounter];</p>
<p>if (xMap.HasChildNodes)</p>
<p>{</p>
<p>output.AddAttribute(HtmlTextWriterAttribute.Shape, “rect”);</p>
<p>output.AddAttribute(HtmlTextWriterAttribute.Coords, xMap.ChildNodes[0].InnerText + “,” + xMap.ChildNodes[1].InnerText + “,” + xMap.ChildNodes[2].InnerText + “,” + xMap.ChildNodes[3].InnerText);</p>
<p>output.AddAttribute(HtmlTextWriterAttribute.Href, xMap.ChildNodes[4].InnerText);</p>
<p>output.AddAttribute(HtmlTextWriterAttribute.Title, “”);</p>
<p>output.AddAttribute(HtmlTextWriterAttribute.Alt, “”);</p>
<p>output.RenderBeginTag(HtmlTextWriterTag.Area);</p>
<p>output.RenderEndTag();</p>
<p>}</p>
<p>}</p>
<p>output.RenderEndTag();</p>
<p>}</p>
<p>}</p>
<p>protected override void OnPreRender(EventArgs e)</p>
<p>{</p>
<p>}</p>
<p>}</p>
<p>}</p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong>Using customer control in ASPX page:</strong></p>
<p><strong> </strong></p>
<p>Now we are done with developing customer control with all the required functionality.</p>
<p>And control now ready for use.</p>
<p><strong><em>Registering custom control</em></strong></p>
<p><strong><em> </em></strong></p>
<p>&lt;%@ Register Assembly=”code_center_library” TagPrefix=”TCC” Namespace=”TCC.Controls” %&gt;</p>
<p><strong><em>Defining Custom control in ASPX page</em></strong></p>
<p><strong><em> </em></strong></p>
<p>&lt;TCC:banner ID=”ads” runat=”server” XMLpath=”~/banner-mapping/bannes.xml” /&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://techinsight.dhanashree.com/developing-custom-ad-rotator-control-with-multiple-image-mapping-using-c-net-xml/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

