<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1084787999077704213</id><updated>2024-11-01T03:38:00.738-07:00</updated><category term="c# faqs"/><category term="Adding GOOGLE MAP into your .NET website in just 15 minutes"/><category term="Adding google site map blogger"/><category term="Asp.net faqs"/><category term="Encryption and Decryption of a COOKIE"/><category term="Exporting WebPage to Excel using Javascript"/><category term="Generating pdf report using asp.net"/><category term="Improve your ASP.NET Site performance with Caching"/><category term="Master Pages in ASP.Net 2.0"/><category term="Preventing Caching of htm and images being stored in Client Machine"/><category term="Sending Email in ASP.NET 2.0"/><category term="Using HttpHandlers and HttpModules in your ASP.NET Websites"/><category term="VB.NET and C# Programming Basics"/><category term="dotnet faqs .net faqs"/><category term="interview questions"/><category term="radio button inside datagrid"/><title type='text'>Florence Blog about asp.net , C#, Sql server, WCF tutorials and interview Questions</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://dflorence25.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default'/><link rel='alternate' type='text/html' href='http://dflorence25.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default?start-index=26&amp;max-results=25'/><author><name>Flor</name><uri>http://www.blogger.com/profile/04517282987785226840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZYDSF-y7Vt7gRkup1yqg7Bn4ZODIz5NU2tDOUW10ZJaIM1D6fsTwAnmqU8WoJ88bq-dw_3l8jGR540YHTwHjr6NuJv-MBT47BwaJPkF2d2BNnV22Q5ddqbc9W3ut75w/s220/Flor.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>32</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1084787999077704213.post-6189401256771629602</id><published>2009-07-18T00:09:00.000-07:00</published><updated>2009-07-18T00:12:33.939-07:00</updated><title type='text'>JavaScript Progress Bar</title><content type='html'>&lt;span style=&quot;font-weight:bold;&quot;&gt;JavaScript Progress Bar&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;table align=&amp;quot;center&amp;quot;&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;div id=&amp;quot;showbar&amp;quot; style=&amp;quot;font-size:8pt;padding:2px;border:solid black 1px;visibility:hidden&amp;quot;&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;span id=&amp;quot;progress1&amp;quot;&amp;gt;&amp;amp;nbsp; &amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;span id=&amp;quot;progress2&amp;quot;&amp;gt;&amp;amp;nbsp; &amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;span id=&amp;quot;progress3&amp;quot;&amp;gt;&amp;amp;nbsp; &amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;span id=&amp;quot;progress4&amp;quot;&amp;gt;&amp;amp;nbsp; &amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;span id=&amp;quot;progress5&amp;quot;&amp;gt;&amp;amp;nbsp; &amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;span id=&amp;quot;progress6&amp;quot;&amp;gt;&amp;amp;nbsp; &amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;span id=&amp;quot;progress7&amp;quot;&amp;gt;&amp;amp;nbsp; &amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;span id=&amp;quot;progress8&amp;quot;&amp;gt;&amp;amp;nbsp; &amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;span id=&amp;quot;progress9&amp;quot;&amp;gt;&amp;amp;nbsp; &amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;script language=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;&lt;br /&gt;var progressEnd = 9; // set to number of progress &amp;lt;span&amp;gt;&#39;s.&lt;br /&gt;&lt;br /&gt;var progressColor = &#39;blue&#39;; // set to progress bar color&lt;br /&gt;&lt;br /&gt;var progressInterval = 1000; // set to time between updates (milli-seconds)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;var progressAt = progressEnd;&lt;br /&gt;&lt;br /&gt;var progressTimer;&lt;br /&gt;&lt;br /&gt;function progress_clear() {&lt;br /&gt;&lt;br /&gt;for (var i = 1; i &amp;lt;= progressEnd; i++) document.getElementById(&#39;progress&#39;+i).style.backgroundColor = &#39;transparent&#39;;&lt;br /&gt;&lt;br /&gt;progressAt = 0;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function progress_update() {&lt;br /&gt;&lt;br /&gt;document.getElementById(&#39;showbar&#39;).style.visibility = &#39;visible&#39;;&lt;br /&gt;&lt;br /&gt;progressAt++;&lt;br /&gt;&lt;br /&gt;if (progressAt &amp;gt; progressEnd) progress_clear();&lt;br /&gt;&lt;br /&gt;else document.getElementById(&#39;progress&#39;+progressAt).style.backgroundColor = progressColor;&lt;br /&gt;&lt;br /&gt;progressTimer = setTimeout(&#39;progress_update()&#39;,progressInterval);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function progress_stop() {&lt;br /&gt;&lt;br /&gt;clearTimeout(progressTimer);&lt;br /&gt;&lt;br /&gt;progress_clear();&lt;br /&gt;&lt;br /&gt;document.getElementById(&#39;showbar&#39;).style.visibility = &#39;hidden&#39;;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//progress_update(); // start progress bar&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;input type=&amp;quot;button&amp;quot; name=&amp;quot;b1&amp;quot; value=&amp;quot;Start Progress Bar&amp;quot; onClick=&amp;quot;progress_update()&amp;quot;&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;input type=&amp;quot;button&amp;quot; name=&amp;quot;b2&amp;quot; value=&amp;quot;Stop Progress Bar&amp;quot; onClick=&amp;quot;progress_stop()&amp;quot;&amp;gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;FeedBurner&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dflorence25.blogspot.com/feeds/6189401256771629602/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1084787999077704213/6189401256771629602' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/6189401256771629602'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/6189401256771629602'/><link rel='alternate' type='text/html' href='http://dflorence25.blogspot.com/2009/07/javascript-progress-bar.html' title='JavaScript Progress Bar'/><author><name>Flor</name><uri>http://www.blogger.com/profile/04517282987785226840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZYDSF-y7Vt7gRkup1yqg7Bn4ZODIz5NU2tDOUW10ZJaIM1D6fsTwAnmqU8WoJ88bq-dw_3l8jGR540YHTwHjr6NuJv-MBT47BwaJPkF2d2BNnV22Q5ddqbc9W3ut75w/s220/Flor.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1084787999077704213.post-4555660264451357350</id><published>2009-07-06T05:06:00.000-07:00</published><updated>2009-07-06T05:13:42.127-07:00</updated><title type='text'>Asp.Net CAPTCHA and Asp.Net AJAX CAPTCHA</title><content type='html'>&lt;a href=&quot;http://dflorence25.blogspot.com/2009/07/aspnet-captcha-and-aspnet-ajax-captcha.html#links&quot;&gt;Florence Blogspot about asp.net tutorials and web design and web development: Asp.Net CAPTCHA and Asp.Net AJAX CAPTCHA&lt;/a&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;FeedBurner&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dflorence25.blogspot.com/feeds/4555660264451357350/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1084787999077704213/4555660264451357350' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/4555660264451357350'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/4555660264451357350'/><link rel='alternate' type='text/html' href='http://dflorence25.blogspot.com/2009/07/florence-blogspot-about-aspnet.html' title='Asp.Net CAPTCHA and Asp.Net AJAX CAPTCHA'/><author><name>Flor</name><uri>http://www.blogger.com/profile/04517282987785226840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZYDSF-y7Vt7gRkup1yqg7Bn4ZODIz5NU2tDOUW10ZJaIM1D6fsTwAnmqU8WoJ88bq-dw_3l8jGR540YHTwHjr6NuJv-MBT47BwaJPkF2d2BNnV22Q5ddqbc9W3ut75w/s220/Flor.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1084787999077704213.post-436670283734379236</id><published>2009-07-06T05:03:00.000-07:00</published><updated>2009-07-06T05:08:33.503-07:00</updated><title type='text'>Asp.Net CAPTCHA and Asp.Net AJAX CAPTCHA</title><content type='html'>&lt;h3 class=&quot;post-title entry-title&quot;&gt; Asp.Net CAPTCHA and Asp.Net AJAX CAPTCHA&lt;/h3&gt;   I am using a great Asp.Net CAPTCHA by &lt;a href=&quot;http://www.codeproject.com/script/Membership/Profiles.aspx?mid=462079&quot;&gt;BrainJar&lt;/a&gt; in a number of web sites with and without Asp.Net AJAX. It’s a simple and really easy to use Asp.Net CAPTCHA. The actual source code is in C#, but you can use it with both C# and VB.Net by simply wrapping the functionality in a class library.&lt;br /&gt;&lt;br /&gt;In Asp.Net forums and in many other user communities I have seen lot of people asking for VB.Net CAPTCHA. So I thought to write a blog post and create some sample implementations. The zip file contains C# CAPTCHA and VB.Net CAPTCHA. I have included the samples for Asp.Net AJAX CAPTCHA also.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.deynu.com/downloads/captcha.zip&quot;&gt;You can download the samples and implementation from here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Implementing Asp.Net AJAX CAPTCHA is really simple. Just wrap the main Asp.Net CAPTCHA with Asp.Net AJAX update panel and put a random query string at the end of CAPTCHA image src. The random query string will avoid showing the old CAPTCHA from browser cache.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;STEPS TO ADD ASP.NET CAPTCHA IN YOUR WEBSITE&lt;/u&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Refer the assembly CaptchaDLL.dll in your project&lt;/li&gt;&lt;li&gt;Copy JpegImage_CS.aspx or JpegImage_VB.aspx (according to the language of choice) to your website.&lt;/li&gt;&lt;li&gt;Open the above file and make changes in Colors and Font if needed. (read the inline comments to know more)&lt;/li&gt;&lt;li&gt;Now user the sample codes from Default.aspx or Ajax.aspx pages. The code is straight forward. You make a session and generate an image with the string in the Session. Now when you submit you have to check the session value and textbox value to see whether the entered CAPTCHA is correct.&lt;/li&gt;&lt;/ol&gt;&lt;a href=&quot;http://www.deynu.com/downloads/captcha.zip&quot;&gt;DOWNLOAD THE SOURCE AND SAMPLES FROM HERE&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;If you have any questions please put as a comment.&lt;div class=&quot;blogger-post-footer&quot;&gt;FeedBurner&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dflorence25.blogspot.com/feeds/436670283734379236/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1084787999077704213/436670283734379236' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/436670283734379236'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/436670283734379236'/><link rel='alternate' type='text/html' href='http://dflorence25.blogspot.com/2009/07/aspnet-captcha-and-aspnet-ajax-captcha.html' title='Asp.Net CAPTCHA and Asp.Net AJAX CAPTCHA'/><author><name>Flor</name><uri>http://www.blogger.com/profile/04517282987785226840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZYDSF-y7Vt7gRkup1yqg7Bn4ZODIz5NU2tDOUW10ZJaIM1D6fsTwAnmqU8WoJ88bq-dw_3l8jGR540YHTwHjr6NuJv-MBT47BwaJPkF2d2BNnV22Q5ddqbc9W3ut75w/s220/Flor.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1084787999077704213.post-5207805907009837353</id><published>2009-06-03T03:30:00.000-07:00</published><updated>2009-06-03T03:48:33.483-07:00</updated><title type='text'>Date Formatting in C#</title><content type='html'>&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 153, 0);&quot;&gt; Date Formatting in C#&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Cheat sheet&lt;br /&gt;&lt;br /&gt;&lt;%= String.Format(&quot;{specifier}&quot;, DateTime.Now) %&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Specifier  Description                       Output&lt;br /&gt;d          Short Date                        08/04/2007&lt;br /&gt;D          Long Date                         08 April 2007&lt;br /&gt;t          Short Time                        21:08&lt;br /&gt;T          Long Time                         21:08:59&lt;br /&gt;f          Full date and time                08 April 2007 21:08&lt;br /&gt;F          Full date and time (long)         08 April 2007 21:08:59&lt;br /&gt;g          Default date and time             08/04/2007 21:08&lt;br /&gt;G          Default date and time (long)      08/04/2007 21:08:59&lt;br /&gt;M          Day / Month                       08 April&lt;br /&gt;r          RFC1123 date                      Sun, 08 Apr 2007 21:08:59 GMT&lt;br /&gt;s          Sortable date/time                2007-04-08T21:08:59&lt;br /&gt;u          Universal time, local timezone    2007-04-08 21:08:59Z&lt;br /&gt;Y          Month / Year                      April 2007&lt;br /&gt;dd         Day                               08&lt;br /&gt;ddd        Short Day Name                    Sun&lt;br /&gt;dddd       Full Day Name                     Sunday&lt;br /&gt;hh         2  digit hour                     09&lt;br /&gt;HH         2 digit hour (24 hour)            21&lt;br /&gt;mm         2 digit minute                    08&lt;br /&gt;MM         Month                             04&lt;br /&gt;MMM        Short Month name                  Apr&lt;br /&gt;MMMM       Month name                        April&lt;br /&gt;ss         seconds                           59&lt;br /&gt;tt         AM/PM                             PM&lt;br /&gt;yy         2 digit year                      07&lt;br /&gt;yyyy       4 digit year                      2007&lt;br /&gt;:          seperator, e.g. {0:hh:mm:ss}      09:08:59&lt;br /&gt;/          seperator, e.g. {0:dd/MM/yyyy}    08/04/2007&lt;/pre&gt;&lt;/span&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;FeedBurner&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dflorence25.blogspot.com/feeds/5207805907009837353/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1084787999077704213/5207805907009837353' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/5207805907009837353'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/5207805907009837353'/><link rel='alternate' type='text/html' href='http://dflorence25.blogspot.com/2009/06/date-formatting-in-c.html' title='Date Formatting in C#'/><author><name>Flor</name><uri>http://www.blogger.com/profile/04517282987785226840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZYDSF-y7Vt7gRkup1yqg7Bn4ZODIz5NU2tDOUW10ZJaIM1D6fsTwAnmqU8WoJ88bq-dw_3l8jGR540YHTwHjr6NuJv-MBT47BwaJPkF2d2BNnV22Q5ddqbc9W3ut75w/s220/Flor.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1084787999077704213.post-7926815998842528083</id><published>2009-05-29T23:00:00.001-07:00</published><updated>2009-05-29T23:00:51.028-07:00</updated><title type='text'>Read the emailID from txt file</title><content type='html'>Read the emailID from txt file:&lt;br /&gt;_____________________________________&lt;br /&gt;&lt;br /&gt;Using Regular Expression, we can do this.&lt;br /&gt;&lt;br /&gt;the textfile format may be in any format like&lt;br /&gt;&lt;br /&gt;sdfsd&lt;br /&gt;&lt;br /&gt;danasegarane@test.com,&lt;br /&gt;&lt;br /&gt;test@test.com,&lt;br /&gt;&lt;br /&gt;me@me.com&lt;br /&gt;&lt;br /&gt;sdf&lt;br /&gt;&lt;br /&gt;sdfs&lt;br /&gt;&lt;br /&gt;dfsd&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;First Method:&lt;br /&gt;&lt;br /&gt;  string pattern = @&quot;[a-z0-9!#$%&amp;amp;&#39;*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&amp;amp;&#39;*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?&quot;;&lt;br /&gt;&lt;br /&gt;System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(pattern);&lt;br /&gt;&lt;br /&gt;//Read file&lt;br /&gt;string sFileContents =System.IO.File.ReadAllText(Server.MapPath(&quot;Email.txt&quot;));&lt;br /&gt;&lt;br /&gt;System.Text.RegularExpressions.MatchCollection mc = reg.Matches(sFileContents);&lt;br /&gt;&lt;br /&gt;//string array for stroing&lt;br /&gt;System.Collections.Generic.List&lt;string&gt; str = new System.Collections.Generic.List&lt;string&gt;();foreach (System.Text.RegularExpressions.Match m in mc)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;str.Add(m.Value);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;OR&lt;br /&gt;&lt;br /&gt;Second Method:&lt;br /&gt;&lt;br /&gt;using System.Text.RegularExpressions;&lt;br /&gt;using System.IO;&lt;br /&gt;&lt;br /&gt;try&lt;br /&gt;      {&lt;br /&gt;          //the file is in the root - you may need to change it&lt;br /&gt;          string filePath = MapPath(&quot;~&quot;) + &quot;/EmailText.txt&quot;;&lt;br /&gt;&lt;br /&gt;          using (StreamReader sr = new StreamReader( filePath) )&lt;br /&gt;          {&lt;br /&gt;              string content = sr.ReadToEnd();&lt;br /&gt;              if (content.Length &gt; 0)&lt;br /&gt;              {&lt;br /&gt;                  //this pattern is taken from Asp.Net regular expression validators library&lt;br /&gt;                  string pattern = @&quot;\w+([-+.&#39;]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*&quot;;&lt;br /&gt;                  MatchCollection mc = Regex.Matches(content, pattern);&lt;br /&gt;                  for (int i = 0; i &lt;&gt;&lt;/string&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;FeedBurner&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dflorence25.blogspot.com/feeds/7926815998842528083/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1084787999077704213/7926815998842528083' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/7926815998842528083'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/7926815998842528083'/><link rel='alternate' type='text/html' href='http://dflorence25.blogspot.com/2009/05/read-emailid-from-txt-file.html' title='Read the emailID from txt file'/><author><name>Flor</name><uri>http://www.blogger.com/profile/04517282987785226840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZYDSF-y7Vt7gRkup1yqg7Bn4ZODIz5NU2tDOUW10ZJaIM1D6fsTwAnmqU8WoJ88bq-dw_3l8jGR540YHTwHjr6NuJv-MBT47BwaJPkF2d2BNnV22Q5ddqbc9W3ut75w/s220/Flor.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1084787999077704213.post-3376579239602161962</id><published>2009-05-25T03:55:00.001-07:00</published><updated>2009-05-25T03:56:05.620-07:00</updated><title type='text'>Export Data To Excel using ADO.Net</title><content type='html'>&lt;p style=&quot;margin: 0in 0in 10pt; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: Arial,sans-serif;&quot;&gt;Excel Workbook is just like database with sheets corresponding to tables. See the mapping below.&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 10pt; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: Arial,sans-serif;&quot;&gt;&lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 10pt; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: Arial,sans-serif;&quot;&gt;Database   &lt;—————&gt;    Excel Workbook&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 10pt; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: Arial,sans-serif;&quot;&gt;Sheet        &lt;—————-&gt;    Table &lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 10pt; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: Arial,sans-serif;&quot;&gt;&lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 10pt; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;strong&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial,sans-serif;&quot;&gt;Connection String for Excel 97-2003 Format (.XLS)&lt;/span&gt;&lt;/strong&gt;  &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 10pt; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: Arial,sans-serif;&quot;&gt;For Excel 97-2003 format &lt;strong&gt;Microsoft Jet OLEDB Driver 4.0&lt;/strong&gt; is used. A sample connection string as follows.&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;div style=&quot;border: 1pt solid windowtext; padding: 1pt 4pt; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;&quot;&gt; &lt;p style=&quot;border: medium none ; margin: 0in 0in 0pt; padding: 0in; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; color: maroon; font-family: &#39;Courier New&#39;;&quot;&gt;&quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Book1.xls;Extended Properties=&#39;Excel 8.0;HDR=Yes&#39;&quot;&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;/div&gt; &lt;p style=&quot;margin: 0in 0in 0pt; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; color: maroon; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 10pt; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;strong&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial,sans-serif;&quot;&gt;&lt;/span&gt;&lt;/strong&gt; &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 10pt; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;strong&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial,sans-serif;&quot;&gt;Connection String for Excel 2007 Format (.XLSX)&lt;/span&gt;&lt;/strong&gt;  &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 10pt; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: Arial,sans-serif;&quot;&gt;For Excel 2007 format the new &lt;strong&gt;Microsoft Ace OLEDB Driver 12.0&lt;/strong&gt; is used. A sample connection string as follows.&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;div style=&quot;border: 1pt solid windowtext; padding: 1pt 4pt; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;&quot;&gt; &lt;p style=&quot;border: medium none ; margin: 0in 0in 0pt; padding: 0in; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; color: maroon; font-family: &#39;Courier New&#39;;&quot;&gt;&quot;Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Book1.xlsx;Extended Properties=&#39;Excel 8.0;HDR=Yes&#39;&quot;&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;/div&gt; &lt;p style=&quot;margin: 0in 0in 0pt; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 0pt; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: Arial,sans-serif;&quot;&gt;Rest everything is same for both versions. One thing to note &lt;strong&gt;Microsoft Ace OLEDB Driver 12.0&lt;/strong&gt;  works for both Excel 2003 and Excel 2007 format.&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 0pt; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: Arial,sans-serif;&quot;&gt;&lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 0pt; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: Arial,sans-serif;&quot;&gt;You can specify whether your Excel file has Headers or not using the &lt;strong&gt;HDR &lt;/strong&gt;property.&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 0pt; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: Arial,sans-serif;&quot;&gt;When HDR is set to Yes the First Row is considered as the Header of the Excel file.&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 0pt; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: Arial,sans-serif;&quot;&gt;&lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 0pt; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: Arial,sans-serif;&quot;&gt;&lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 0pt; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;strong&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial,sans-serif;&quot;&gt;&lt;/span&gt;&lt;/strong&gt; &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 0pt; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;strong&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial,sans-serif;&quot;&gt;Establish a Connection&lt;/span&gt;&lt;/strong&gt;  &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 0pt; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: Arial,sans-serif;&quot;&gt;&lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;div style=&quot;border: 1pt solid windowtext; padding: 1pt 4pt; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;&quot;&gt; &lt;p style=&quot;border: medium none ; margin: 0in 0in 0pt; padding: 0in; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; color: teal; font-family: &#39;Courier New&#39;;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;;&quot;&gt; strExcelConn = &lt;span style=&quot;color: maroon;&quot;&gt;&quot;Provider=Microsoft.Jet.OLEDB.4.0;&quot;&lt;/span&gt; &lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;border: medium none ; margin: 0in 0in 0pt; padding: 0in; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;;&quot;&gt;+ &lt;span style=&quot;color: maroon;&quot;&gt;&quot;Data Source=Book1.xls;&quot;&lt;/span&gt; &lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;border: medium none ; margin: 0in 0in 0pt; padding: 0in; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;;&quot;&gt;+ &lt;span style=&quot;color: maroon;&quot;&gt;&quot;Extended Properties=&#39;Excel 8.0;HDR=Yes&#39;&quot;&lt;/span&gt;; &lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;border: medium none ; margin: 0in 0in 0pt; padding: 0in; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; color: teal; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;border: medium none ; margin: 0in 0in 0pt; padding: 0in; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; color: teal; font-family: &#39;Courier New&#39;;&quot;&gt;OleDbConnection&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;;&quot;&gt; connExcel = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: teal;&quot;&gt;OleDbConnection&lt;/span&gt;(strExcelConn); &lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;border: medium none ; margin: 0in 0in 0pt; padding: 0in; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; color: teal; font-family: &#39;Courier New&#39;;&quot;&gt;OleDbCommand&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;;&quot;&gt; cmdExcel = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: teal;&quot;&gt;OleDbCommand&lt;/span&gt;();&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;border: medium none ; margin: 0in 0in 0pt; padding: 0in; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;;&quot;&gt;cmdExcel.Connection = connExcel;&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;/div&gt; &lt;p style=&quot;margin: 0in 0in 0pt; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: Arial,sans-serif;&quot;&gt;&lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 0pt; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: Arial,sans-serif;&quot;&gt;&lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 0pt; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;strong&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial,sans-serif;&quot;&gt;&lt;/span&gt;&lt;/strong&gt; &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 0pt; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;strong&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial,sans-serif;&quot;&gt;Accessing Sheets&lt;/span&gt;&lt;/strong&gt;  &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 0pt; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;strong&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial,sans-serif;&quot;&gt;&lt;/span&gt;&lt;/strong&gt; &lt;/p&gt;&lt;br /&gt;&lt;div style=&quot;border: 1pt solid windowtext; padding: 1pt 4pt; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;&quot;&gt; &lt;p style=&quot;border: medium none ; margin: 0in 0in 0pt; padding: 0in; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;;&quot;&gt;connExcel.Open();&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;border: medium none ; margin: 0in 0in 0pt; padding: 0in; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; color: teal; font-family: &#39;Courier New&#39;;&quot;&gt;DataTable&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;;&quot;&gt; dtExcelSchema;&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;border: medium none ; margin: 0in 0in 0pt; padding: 0in; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;;&quot;&gt;dtExcelSchema = connExcel.GetOleDbSchemaTable(&lt;span style=&quot;color: teal;&quot;&gt;OleDbSchemaGuid&lt;/span&gt;.Tables, &lt;span style=&quot;color: blue;&quot;&gt;null&lt;/span&gt;);&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;border: medium none ; margin: 0in 0in 0pt; padding: 0in; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;;&quot;&gt;connExcel.Close();&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;/div&gt; &lt;p style=&quot;margin: 0in 0in 10pt; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: Arial,sans-serif;&quot;&gt;  &lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 10pt;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; line-height: 115%; font-family: Arial,sans-serif;&quot;&gt;The &lt;strong&gt;dtExcelSchema &lt;/strong&gt;contains all the Sheets present in your Excel Workbook&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 10pt;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; line-height: 115%; font-family: Arial,sans-serif;&quot;&gt;You access them in the following way&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;div style=&quot;border: 1pt solid windowtext; padding: 1pt 4pt; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;&quot;&gt; &lt;p style=&quot;border: medium none ; margin: 0in 0in 0pt; padding: 0in; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;&quot; class=&quot;MsoListParagraphCxSpFirst&quot;&gt; &lt;span style=&quot;font-size: 10pt; color: blue; line-height: 115%; font-family: &#39;Courier New&#39;;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; line-height: 115%; font-family: &#39;Courier New&#39;;&quot;&gt; sheetName = dtExcelSchema.Rows[0][&lt;span style=&quot;color: maroon;&quot;&gt;&quot;TABLE_NAME&quot;&lt;/span&gt;];&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;/div&gt; &lt;p style=&quot;margin: 0in 0in 0pt;&quot; class=&quot;MsoListParagraphCxSpMiddle&quot;&gt; &lt;span style=&quot;font-size: 10pt; line-height: 115%; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 0pt;&quot; class=&quot;MsoListParagraphCxSpMiddle&quot;&gt; &lt;span style=&quot;font-size: 10pt; line-height: 115%; font-family: Arial,sans-serif;&quot;&gt;This will give the name of the first sheet. i.e. &lt;strong&gt;Sheet1$&lt;/strong&gt;&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 10pt;&quot; class=&quot;MsoListParagraphCxSpLast&quot;&gt; &lt;span style=&quot;font-size: 10pt; line-height: 115%; font-family: Arial,sans-serif;&quot;&gt;&lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 10pt;&quot; class=&quot;MsoNormal&quot;&gt; &lt;strong&gt;&lt;span style=&quot;font-size: 10pt; line-height: 115%; font-family: Arial,sans-serif;&quot;&gt;Create a new sheet&lt;/span&gt;&lt;/strong&gt;  &lt;/p&gt;&lt;br /&gt;&lt;div style=&quot;border: 1pt solid windowtext; padding: 1pt 4pt; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;&quot;&gt; &lt;p style=&quot;border: medium none ; margin: 0in 0in 0pt; padding: 0in; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;;&quot;&gt;cmdExcel.CommandText = &lt;span style=&quot;color: maroon;&quot;&gt;&quot;CREATE TABLE [tblData]&quot;&lt;/span&gt; +&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;border: medium none ; margin: 0in 0in 0pt; padding: 0in; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;span&gt; &lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;&quot;(ID varchar(10), Name varchar(50));&quot;&lt;/span&gt;;&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;border: medium none ; margin: 0in 0in 0pt; padding: 0in; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;;&quot;&gt;connExcel.Open();&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;border: medium none ; margin: 0in 0in 0pt; padding: 0in; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;;&quot;&gt;cmdExcel.ExecuteNonQuery();&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;border: medium none ; margin: 0in 0in 0pt; padding: 0in; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;;&quot;&gt;connExcel.Close();&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;/div&gt; &lt;p style=&quot;margin: 0in 0in 10pt;&quot; class=&quot;MsoNormal&quot;&gt; &lt;strong&gt;&lt;span style=&quot;font-size: 10pt; line-height: 115%; font-family: Arial,sans-serif;&quot;&gt;&lt;/span&gt;&lt;/strong&gt; &lt;/p&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 10pt; line-height: 115%; font-family: Arial,sans-serif;&quot;&gt;The above code creates a new Sheet in the Excel Workbook with the name tblData&lt;/span&gt; &lt;span style=&quot;font-size: 10pt; line-height: 115%; font-family: Arial,sans-serif;&quot;&gt;with two columns ID and Name.&lt;/span&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 10pt;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; line-height: 115%; font-family: Arial,sans-serif;&quot;&gt;&lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 10pt;&quot; class=&quot;MsoNormal&quot;&gt; &lt;strong&gt;&lt;span style=&quot;font-size: 10pt; line-height: 115%; font-family: Arial,sans-serif;&quot;&gt;Insert Record into Sheet&lt;/span&gt;&lt;/strong&gt;  &lt;/p&gt;&lt;br /&gt;&lt;div style=&quot;border: 1pt solid windowtext; padding: 1pt 4pt; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;&quot;&gt; &lt;p style=&quot;border: medium none ; margin: 0in 0in 0pt; padding: 0in; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;;&quot;&gt;connExcel.Open();&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;border: medium none ; margin: 0in 0in 0pt; padding: 0in; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;;&quot;&gt;cmdExcel.CommandText = &lt;span style=&quot;color: maroon;&quot;&gt;&quot;INSERT INTO [tblData] (ID, Name)&quot;&lt;/span&gt; +&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;border: medium none ; margin: 0in 0in 0pt; padding: 0in; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; color: maroon; font-family: &#39;Courier New&#39;;&quot;&gt;&quot; values (&#39;1&#39;, &#39;MAK&#39;)&quot;&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;;&quot;&gt;; &lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;border: medium none ; margin: 0in 0in 0pt; padding: 0in; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;;&quot;&gt;cmdExcel.ExecuteNonQuery();&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;border: medium none ; margin: 0in 0in 0pt; padding: 0in; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;;&quot;&gt;connExcel.Close();&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;/div&gt; &lt;p style=&quot;margin: 0in 0in 0pt; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 0pt; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 10pt;&quot; class=&quot;MsoNormal&quot;&gt; &lt;strong&gt;&lt;span style=&quot;font-size: 10pt; line-height: 115%; font-family: Arial,sans-serif;&quot;&gt;&lt;/span&gt;&lt;/strong&gt; &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin: 0in 0in 10pt;&quot; class=&quot;MsoNormal&quot;&gt; &lt;strong&gt;&lt;span style=&quot;font-size: 10pt; line-height: 115%; font-family: Arial,sans-serif;&quot;&gt;Update existing Record into Sheet&lt;/span&gt;&lt;/strong&gt;  &lt;/p&gt;&lt;br /&gt; &lt;p style=&quot;border: medium none ; margin: 0in 0in 0pt; padding: 0in; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;;&quot;&gt;connExcel.Open();&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;border: medium none ; margin: 0in 0in 0pt; padding: 0in; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;;&quot;&gt;cmdExcel.CommandText = &lt;span style=&quot;color: maroon;&quot;&gt;&quot;UPDATE [tblData] &quot; &lt;/span&gt;+&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;border: medium none ; margin: 0in 0in 0pt; padding: 0in; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; color: maroon; font-family: &#39;Courier New&#39;;&quot;&gt;&quot;SET Name =&#39;John&#39; WHERE ID = &#39;1&#39;&quot;&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;;&quot;&gt;; &lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;border: medium none ; margin: 0in 0in 0pt; padding: 0in; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;;&quot;&gt;cmdExcel.ExecuteNonQuery();&lt;/span&gt;  &lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;border: medium none ; margin: 0in 0in 0pt; padding: 0in; background: rgb(194, 214, 155) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: normal;&quot; class=&quot;MsoNormal&quot;&gt; &lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;;&quot;&gt;connExcel.Close();&lt;/span&gt;  &lt;/p&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;FeedBurner&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dflorence25.blogspot.com/feeds/3376579239602161962/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1084787999077704213/3376579239602161962' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/3376579239602161962'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/3376579239602161962'/><link rel='alternate' type='text/html' href='http://dflorence25.blogspot.com/2009/05/export-data-to-excel-using-adonet.html' title='Export Data To Excel using ADO.Net'/><author><name>Flor</name><uri>http://www.blogger.com/profile/04517282987785226840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZYDSF-y7Vt7gRkup1yqg7Bn4ZODIz5NU2tDOUW10ZJaIM1D6fsTwAnmqU8WoJ88bq-dw_3l8jGR540YHTwHjr6NuJv-MBT47BwaJPkF2d2BNnV22Q5ddqbc9W3ut75w/s220/Flor.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1084787999077704213.post-5894326693840454673</id><published>2009-05-25T03:46:00.001-07:00</published><updated>2009-05-25T03:48:21.892-07:00</updated><title type='text'>C# How to place an arraylist inside a Session Variable and Iterate through it</title><content type='html'>&lt;p&gt;Question:&lt;/p&gt; &lt;p&gt;Hi,&lt;br /&gt;&lt;/p&gt; &lt;p&gt;In my web form, I want to store multiple IDs inside an arraylist and then store the arraylist in a Session Variable (e.g. Session[&quot;InstallationID&quot;]) to use it in a different web form where I want to use every ID inside the arraylist.&lt;/p&gt; &lt;p&gt;How do I place the arraylist inside the Session Variable and then take each ID off of it to be used in a SELECT statement?&lt;/p&gt; &lt;p&gt;Answer:&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Something like this:&lt;br /&gt;&lt;/p&gt;&lt;pre class=&quot;coloredcode&quot;&gt;&lt;b id=&quot;1&quot;&gt;1    &lt;/b&gt;&lt;span class=&quot;kwd&quot;&gt;protected void&lt;/span&gt; Page_Load(&lt;span class=&quot;kwd&quot;&gt;object&lt;/span&gt; sender, EventArgs e)&lt;br /&gt;&lt;b id=&quot;2&quot;&gt;2    &lt;/b&gt;{&lt;br /&gt;&lt;b id=&quot;3&quot;&gt;3    &lt;/b&gt;    &lt;span class=&quot;kwd&quot;&gt;if&lt;/span&gt; (!IsPostBack)&lt;br /&gt;&lt;b id=&quot;4&quot;&gt;4    &lt;/b&gt;    {&lt;br /&gt;&lt;b id=&quot;5&quot;&gt;5    &lt;/b&gt;        List&lt;&lt;span class=&quot;kwd&quot;&gt;int&lt;/span&gt;&gt; ids = &lt;span class=&quot;kwd&quot;&gt;new&lt;/span&gt; List&lt;&lt;span class=&quot;kwd&quot;&gt;int&lt;/span&gt;&gt; {1, 2, 3, 4, 5};&lt;br /&gt;&lt;b id=&quot;6&quot;&gt;6    &lt;/b&gt;        Session[&lt;span class=&quot;st&quot;&gt;&quot;myIds&quot;&lt;/span&gt;] = ids;&lt;br /&gt;&lt;b id=&quot;7&quot;&gt;7    &lt;/b&gt;    }&lt;br /&gt;&lt;b id=&quot;8&quot;&gt;8    &lt;/b&gt;}&lt;br /&gt;&lt;b id=&quot;9&quot;&gt;9    &lt;/b&gt;&lt;br /&gt;&lt;b id=&quot;10&quot;&gt;10   &lt;/b&gt;&lt;span class=&quot;kwd&quot;&gt;protected void&lt;/span&gt; buttonSubmit_Click(&lt;span class=&quot;kwd&quot;&gt;object&lt;/span&gt; sender, EventArgs e)&lt;br /&gt;&lt;b id=&quot;11&quot;&gt;11   &lt;/b&gt;{&lt;br /&gt;&lt;b id=&quot;12&quot;&gt;12   &lt;/b&gt;    List&lt;&lt;span class=&quot;kwd&quot;&gt;int&lt;/span&gt;&gt; ids = Session[&lt;span class=&quot;st&quot;&gt;&quot;myIds&quot;&lt;/span&gt;] != &lt;span class=&quot;kwd&quot;&gt;null&lt;/span&gt; ? (List&lt;&lt;span class=&quot;kwd&quot;&gt;int&lt;/span&gt;&gt;) Session[&lt;span class=&quot;st&quot;&gt;&quot;myIds&quot;&lt;/span&gt;] : &lt;span class=&quot;kwd&quot;&gt;null&lt;/span&gt;;&lt;br /&gt;&lt;b id=&quot;13&quot;&gt;13   &lt;/b&gt;    &lt;span class=&quot;kwd&quot;&gt;if&lt;/span&gt; (ids != &lt;span class=&quot;kwd&quot;&gt;null&lt;/span&gt;)&lt;br /&gt;&lt;b id=&quot;14&quot;&gt;14   &lt;/b&gt;    {&lt;br /&gt;&lt;b id=&quot;15&quot;&gt;15   &lt;/b&gt;        &lt;span class=&quot;kwd&quot;&gt;foreach&lt;/span&gt; (&lt;span class=&quot;kwd&quot;&gt;int&lt;/span&gt; id &lt;span class=&quot;kwd&quot;&gt;in&lt;/span&gt; ids)&lt;br /&gt;&lt;b id=&quot;16&quot;&gt;16   &lt;/b&gt;        {&lt;br /&gt;&lt;b id=&quot;17&quot;&gt;17   &lt;/b&gt;            ListBox1.Items.Add(String.Format(&lt;span class=&quot;st&quot;&gt;&quot;select * from customer where id={0}&quot;&lt;/span&gt;, id));&lt;br /&gt;&lt;b id=&quot;18&quot;&gt;18   &lt;/b&gt;        }&lt;br /&gt;&lt;b id=&quot;19&quot;&gt;19   &lt;/b&gt;    }&lt;br /&gt;&lt;b id=&quot;20&quot;&gt;20   &lt;/b&gt;}&lt;br /&gt;&lt;br /&gt;OR&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;kwd&quot;&gt;protected void&lt;/span&gt; Page_Load(&lt;span class=&quot;kwd&quot;&gt;object&lt;/span&gt; sender, EventArgs e)&lt;br /&gt;  {&lt;br /&gt;      &lt;span class=&quot;cmt&quot;&gt;//Save&lt;/span&gt;&lt;br /&gt;      ArrayList idList = &lt;span class=&quot;kwd&quot;&gt;new&lt;/span&gt; ArrayList();&lt;br /&gt;      idList.Add(&lt;span class=&quot;st&quot;&gt;&quot;1&quot;&lt;/span&gt;);&lt;br /&gt;      idList.Add(&lt;span class=&quot;st&quot;&gt;&quot;2&quot;&lt;/span&gt;);&lt;br /&gt;      idList.Add(&lt;span class=&quot;st&quot;&gt;&quot;3&quot;&lt;/span&gt;);&lt;br /&gt;      Session[&lt;span class=&quot;st&quot;&gt;&quot;InstallationId&quot;&lt;/span&gt;] = idList;&lt;br /&gt;  }//Page2&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot; &gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot; &gt;protected&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot; &gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot; &gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt; Page_Load(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot; &gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot; &gt;object&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt; sender, &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 128);font-size:85%;&quot; &gt;&lt;span style=&quot;color: rgb(0, 128, 128);font-size:85%;&quot; &gt;EventArgs&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt; e)&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;{&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(0, 128, 0);font-size:85%;&quot; &gt;&lt;span style=&quot;color: rgb(0, 128, 0);font-size:85%;&quot; &gt;//Retreive&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style=&quot;color: rgb(0, 128, 128);font-size:85%;&quot; &gt;&lt;span style=&quot;color: rgb(0, 128, 128);font-size:85%;&quot; &gt;ArrayList&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt; idList = (&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 128);font-size:85%;&quot; &gt;&lt;span style=&quot;color: rgb(0, 128, 128);font-size:85%;&quot; &gt;ArrayList&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;)Session[&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0);font-size:85%;&quot; &gt;&lt;span style=&quot;color: rgb(128, 0, 0);font-size:85%;&quot; &gt;&quot;InstallationId&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;];&lt;/span&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot; &gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot; &gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt; id1 = idList[0].ToString() ;&lt;/span&gt;&lt;/p&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot; &gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot; &gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt; id2 = idList[1].ToString();&lt;/span&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot; &gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-size:85%;&quot; &gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt; id3 = idList[2].ToString(); &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Refer for references: &lt;a href=&quot;http://forums.asp.net/t/1425975.aspx&quot;&gt;http://forums.asp.net/t/1425975.aspx&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;pre class=&quot;coloredcode&quot;&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;FeedBurner&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dflorence25.blogspot.com/feeds/5894326693840454673/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1084787999077704213/5894326693840454673' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/5894326693840454673'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/5894326693840454673'/><link rel='alternate' type='text/html' href='http://dflorence25.blogspot.com/2009/05/c-how-to-place-arraylist-inside-session.html' title='C# How to place an arraylist inside a Session Variable and Iterate through it'/><author><name>Flor</name><uri>http://www.blogger.com/profile/04517282987785226840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZYDSF-y7Vt7gRkup1yqg7Bn4ZODIz5NU2tDOUW10ZJaIM1D6fsTwAnmqU8WoJ88bq-dw_3l8jGR540YHTwHjr6NuJv-MBT47BwaJPkF2d2BNnV22Q5ddqbc9W3ut75w/s220/Flor.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1084787999077704213.post-7809954253050836201</id><published>2009-05-19T02:54:00.000-07:00</published><updated>2009-05-19T02:59:51.308-07:00</updated><title type='text'>Maintain Scroll Position after Asynchronous Postback</title><content type='html'>&lt;span style=&quot;font-style: italic; font-weight: bold; color: rgb(255, 0, 0);&quot;&gt;Maintain Scroll Position after Asynchronous Postback&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Do you want to maintain the scroll position of a GridView, Div, Panel, or whatever that is inside of an UpdatePanel after an asynchronous postback?  Normally, if the updatepanel posts back, the item will scroll back to the top because it has been reloaded.  What you need to do is “remember” where the item was scrolled to and jump back to there after the postback.  Place the following script after the ScriptManager on your page.  And since the _endRequest event of the PageRequestManager happens before the page is rendered, you’ll never even see your item move!&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 102, 0); font-weight: bold; font-style: italic;&quot;&gt;&amp;lt;script type=&quot;text/javascript&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 102, 0); font-weight: bold; font-style: italic;&quot;&gt;    var xPos, yPos;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 102, 0); font-weight: bold; font-style: italic;&quot;&gt;    var prm = Sys.WebForms.PageRequestManager.getInstance();&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 102, 0); font-weight: bold; font-style: italic;&quot;&gt;    prm.add_beginRequest(BeginRequestHandler);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 102, 0); font-weight: bold; font-style: italic;&quot;&gt;    prm.add_endRequest(EndRequestHandler);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 102, 0); font-weight: bold; font-style: italic;&quot;&gt;    function BeginRequestHandler(sender, args) {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 102, 0); font-weight: bold; font-style: italic;&quot;&gt;        xPos = $get(&#39;scrollDiv&#39;).scrollLeft;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 102, 0); font-weight: bold; font-style: italic;&quot;&gt;        yPos = $get(&#39;scrollDiv&#39;).scrollTop;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 102, 0); font-weight: bold; font-style: italic;&quot;&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 102, 0); font-weight: bold; font-style: italic;&quot;&gt;    function EndRequestHandler(sender, args) {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 102, 0); font-weight: bold; font-style: italic;&quot;&gt;        $get(&#39;scrollDiv&#39;).scrollLeft = xPos;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 102, 0); font-weight: bold; font-style: italic;&quot;&gt;        $get(&#39;scrollDiv&#39;).scrollTop = yPos;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 102, 0); font-weight: bold; font-style: italic;&quot;&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 102, 0); font-weight: bold; font-style: italic;&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;FeedBurner&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dflorence25.blogspot.com/feeds/7809954253050836201/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1084787999077704213/7809954253050836201' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/7809954253050836201'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/7809954253050836201'/><link rel='alternate' type='text/html' href='http://dflorence25.blogspot.com/2009/05/maintain-scroll-position-after.html' title='Maintain Scroll Position after Asynchronous Postback'/><author><name>Flor</name><uri>http://www.blogger.com/profile/04517282987785226840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZYDSF-y7Vt7gRkup1yqg7Bn4ZODIz5NU2tDOUW10ZJaIM1D6fsTwAnmqU8WoJ88bq-dw_3l8jGR540YHTwHjr6NuJv-MBT47BwaJPkF2d2BNnV22Q5ddqbc9W3ut75w/s220/Flor.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1084787999077704213.post-4029799742898107127</id><published>2009-05-12T00:48:00.000-07:00</published><updated>2009-05-12T00:49:04.236-07:00</updated><title type='text'>How to check the Status of the Internet connection from windows application in C#.net</title><content type='html'>How to check the Status of the Internet connection from windows application in C#.net&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;try this:&lt;br /&gt;bool ConnectionExists()&lt;br /&gt;{&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;System.Net.Sockets.TcpClient clnt=new System.Net.Sockets.TcpClient(&quot;www.google.com&quot;,80);&lt;br /&gt;clnt.Close();&lt;br /&gt;return true;&lt;br /&gt;}&lt;br /&gt;catch(System.Exception ex)&lt;br /&gt;{&lt;br /&gt;return false;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;or this one&lt;br /&gt;&lt;br /&gt;public static bool Test(string url) &lt;br /&gt;{ &lt;br /&gt;HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); &lt;br /&gt;req.Method = &quot;HEAD&quot;; &lt;br /&gt;try { &lt;br /&gt; HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); &lt;br /&gt; resp.Close(); return true; &lt;br /&gt;} &lt;br /&gt;catch { return false; } } &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;or&lt;br /&gt;&lt;br /&gt;In this tutorial, we&#39;ll create a class with a static function that returns true if connected and false if not, using our API function in private state.&lt;br /&gt;&lt;br /&gt;Check this out :&lt;br /&gt;&lt;br /&gt;using System ;&lt;br /&gt;using System.Runtime ;&lt;br /&gt;using System.Runtime.InteropServices ;&lt;br /&gt;&lt;br /&gt;public class InternetCS&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;    //Creating the extern function...&lt;br /&gt;    [DllImport(&quot;wininet.dll&quot;)]&lt;br /&gt;    private extern static bool InternetGetConnectedState( int out Description, int ReservedValue ) ;&lt;br /&gt;&lt;br /&gt;    //Creating a function that uses the API function...&lt;br /&gt;    public static bool IsConnectedToInternet( )&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        int Desc ;&lt;br /&gt;        return InternetGetConnectedState( out Desc, 0 ) ;&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;}&lt;div class=&quot;blogger-post-footer&quot;&gt;FeedBurner&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dflorence25.blogspot.com/feeds/4029799742898107127/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1084787999077704213/4029799742898107127' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/4029799742898107127'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/4029799742898107127'/><link rel='alternate' type='text/html' href='http://dflorence25.blogspot.com/2009/05/how-to-check-status-of-internet.html' title='How to check the Status of the Internet connection from windows application in C#.net'/><author><name>Flor</name><uri>http://www.blogger.com/profile/04517282987785226840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZYDSF-y7Vt7gRkup1yqg7Bn4ZODIz5NU2tDOUW10ZJaIM1D6fsTwAnmqU8WoJ88bq-dw_3l8jGR540YHTwHjr6NuJv-MBT47BwaJPkF2d2BNnV22Q5ddqbc9W3ut75w/s220/Flor.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1084787999077704213.post-1214521383462804041</id><published>2009-05-01T22:46:00.000-07:00</published><updated>2009-05-01T22:52:23.167-07:00</updated><title type='text'>Get the Checkboxlist values using javascript:</title><content type='html'>&lt;meta equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;meta name=&quot;ProgId&quot; content=&quot;Word.Document&quot;&gt;&lt;meta name=&quot;Generator&quot; content=&quot;Microsoft Word 11&quot;&gt;&lt;meta name=&quot;Originator&quot; content=&quot;Microsoft Word 11&quot;&gt;&lt;link rel=&quot;File-List&quot; href=&quot;file:///C:%5CDOCUME%7E1%5Cflorence%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml&quot;&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate=&quot;false&quot; latentstylecount=&quot;156&quot;&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:&quot;&quot;; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:&quot;Times New Roman&quot;; 	mso-fareast-font-family:&quot;Times New Roman&quot;;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:&quot;Table Normal&quot;; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:&quot;&quot;; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:&quot;Times New Roman&quot;; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;Get the Checkboxlist values using javascript:&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;We cannot get the value of the checkbox in the checkboxlist because it is rendered in the form of table , td, input and the text of the check is like label.&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;So we need to bind the value of checkbox in the tilte attribute and then we can read the title values using javascript.&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: maroon;&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt; &lt;span style=&quot;color: red;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;text/javascript&quot;&amp;gt;&lt;/span&gt;&lt;span style=&quot;&quot;&gt;                    &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;function&lt;/span&gt; IsCheck()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;         &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;var&lt;/span&gt; UserID=&lt;span style=&quot;color: maroon;&quot;&gt;&quot;&quot;&lt;/span&gt;;&lt;span style=&quot;&quot;&gt;     &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;var&lt;/span&gt; UserCode=&lt;span style=&quot;color: maroon;&quot;&gt;&quot;&quot;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;var&lt;/span&gt; cblist = &lt;span style=&quot;color: maroon;&quot;&gt;&quot;ChkBoxListUsers&quot;&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;var&lt;/span&gt; chkList1= document.getElementById(cblist);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;var&lt;/span&gt; arrayOfCheckBoxes= chkList1.getElementsByTagName(&lt;span style=&quot;color: maroon;&quot;&gt;&quot;input&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;var&lt;/span&gt; arrayOfCheckBoxspans= chkList1.getElementsByTagName(&lt;span style=&quot;color: maroon;&quot;&gt;&quot;span&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;var&lt;/span&gt; arrayOfCheckBoxLabels= chkList1.getElementsByTagName(&lt;span style=&quot;color: maroon;&quot;&gt;&quot;label&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;var&lt;/span&gt; listcount = arrayOfCheckBoxes.length;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: blue;&quot;&gt;var&lt;/span&gt; i=0;i&amp;lt;arrayOfCheckBoxes.length;i++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;             &lt;/span&gt;{&lt;span style=&quot;&quot;&gt;                &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;                &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;(arrayOfCheckBoxes[i].checked)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;                &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;                &lt;/span&gt;UserCode += arrayOfCheckBoxspans[i].title + &lt;span style=&quot;color: maroon;&quot;&gt;&quot;,&quot;&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;                &lt;/span&gt;UserID += arrayOfCheckBoxLabels[i].innerHTML+ &lt;span style=&quot;color: maroon;&quot;&gt;&quot;, &quot;&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;                &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;             &lt;/span&gt;}&lt;span style=&quot;&quot;&gt;            &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;            &lt;/span&gt;window.opener.document.forms[0].HdnSelectedUsers.value=UserCode; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;            &lt;/span&gt;window.opener.document.forms[0].txtSelectedUsers.value=UserID;&lt;span style=&quot;&quot;&gt;             &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;            &lt;/span&gt;window.close();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;Frontend:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&amp;lt;body&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;&amp;lt;form id=&quot;form1&quot; runat=&quot;server&quot;&amp;gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;&amp;lt;div style=&quot;text-align: center&quot;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;            &lt;/span&gt;&amp;lt;fieldset class=&quot;Fieldset&quot; style=&quot;width: 95%&quot; runat=&quot;server&quot; id=&quot;fsToolDetails&quot;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                &lt;/span&gt;&amp;lt;legend class=&quot;Legend_Text&quot;&amp;gt;&amp;lt;strong&amp;gt;User Details&amp;lt;/strong&amp;gt;&amp;lt;/legend&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                &lt;/span&gt;&amp;lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;width: 100%&quot;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                    &lt;/span&gt;&amp;lt;tr&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                        &lt;/span&gt;&amp;lt;td align=&quot;center&quot;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                            &lt;/span&gt;&amp;lt;asp:Label ID=&quot;Label1&quot; runat=&quot;server&quot; Text=&quot;SELECT USER&quot; Width=&quot;240px&quot; CssClass=&quot;Headlabel&quot;&amp;gt;&amp;lt;/asp:Label&amp;gt;&amp;lt;/td&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                    &lt;/span&gt;&amp;lt;/tr&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                    &lt;/span&gt;&amp;lt;tr&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                        &lt;/span&gt;&amp;lt;td align=&quot;left&quot; style=&quot;height: 14px&quot;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                            &lt;/span&gt;&amp;lt;asp:Label ID=&quot;lblError&quot; runat=&quot;server&quot; CssClass=&quot;Err_label&quot;&amp;gt;&amp;lt;/asp:Label&amp;gt;&amp;lt;/td&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                    &lt;/span&gt;&amp;lt;/tr&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                    &lt;/span&gt;&amp;lt;tr&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                        &lt;/span&gt;&amp;lt;td width=&quot;100%&quot; align=&quot;left&quot; height=&quot;150px&quot;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                            &lt;/span&gt;&amp;lt;div align=&quot;left&quot; style=&quot;width:300px; height: 159px; width: 100%; overflow: auto; padding-top: 1px;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                                &lt;/span&gt;padding-left: 1px&quot;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                                &lt;/span&gt;&amp;lt;asp:CheckBoxList ID=&quot;ChkBoxListUsers&quot; runat=&quot;server&quot; CssClass=&quot;selectBox&quot; Width=&quot;500px&quot; RepeatColumns=&quot;2&quot; RepeatDirection=&quot;Horizontal&quot; OnDataBound=&quot;ChkBoxListUsers_DataBound&quot;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                                &lt;/span&gt;&amp;lt;/asp:CheckBoxList&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                                &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                                &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                            &lt;/span&gt;&amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                        &lt;/span&gt;&amp;lt;/td&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                    &lt;/span&gt;&amp;lt;/tr&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                    &lt;/span&gt;&amp;lt;tr&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                        &lt;/span&gt;&amp;lt;td align=&quot;center&quot;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                            &lt;/span&gt;&amp;lt;asp:Button ID=&quot;btnSubmit&quot; Text=&quot;Order&quot; runat=&quot;server&quot; CssClass=&quot;buttons&quot;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                                &lt;/span&gt;Width=&quot;57px&quot;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;/&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                            &lt;/span&gt;&amp;lt;asp:Button ID=&quot;btnClose&quot; Text=&quot;Close&quot; runat=&quot;server&quot; CssClass=&quot;buttons&quot; Width=&quot;54px&quot;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                                &lt;/span&gt;OnClientClick=&quot;window.close();&quot; /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                                &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                &lt;/span&gt;&lt;span style=&quot;&quot;&gt;                &lt;/span&gt;&amp;lt;/td&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                    &lt;/span&gt;&amp;lt;/tr&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                    &lt;/span&gt;&amp;lt;tr&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                        &lt;/span&gt;&amp;lt;td align=&quot;center&quot;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                            &lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                        &lt;/span&gt;&amp;lt;/td&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                    &lt;/span&gt;&amp;lt;/tr&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;&amp;lt;/table&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;            &lt;/span&gt;&amp;lt;/fieldset&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;&amp;lt;/div&amp;gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;&amp;lt;script type=&quot;text/javascript&quot;&amp;gt;&lt;span style=&quot;&quot;&gt;                    &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;function IsCheck()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;         &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;var UserID=&quot;&quot;;&lt;span style=&quot;&quot;&gt;     &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;var UserCode=&quot;&quot;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;var cblist = &quot;ChkBoxListUsers&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;var chkList1= document.getElementById(cblist);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;var arrayOfCheckBoxes= chkList1.getElementsByTagName(&quot;input&quot;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;var arrayOfCheckBoxspans= chkList1.getElementsByTagName(&quot;span&quot;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;var arrayOfCheckBoxLabels= chkList1.getElementsByTagName(&quot;label&quot;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;var listcount = arrayOfCheckBoxes.length;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;for(var i=0;i&amp;lt;arrayOfCheckBoxes.length;i++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;             &lt;/span&gt;{&lt;span style=&quot;&quot;&gt;                &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                &lt;/span&gt;if(arrayOfCheckBoxes[i].checked)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;&quot;&gt;               &lt;/span&gt;UserCode += arrayOfCheckBoxspans[i].title + &quot;,&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                &lt;/span&gt;UserID += arrayOfCheckBoxLabels[i].innerHTML+ &quot;, &quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;                &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;             &lt;/span&gt;}&lt;span style=&quot;&quot;&gt;            &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;            &lt;/span&gt;window.opener.document.forms[0].HdnSelectedUsers.value=UserCode; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;&quot;&gt;           &lt;/span&gt;window.opener.document.forms[0].txtSelectedUsers.value=UserID;&lt;span style=&quot;&quot;&gt;             &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;            &lt;/span&gt;window.close();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;            &lt;/span&gt;return false;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;&amp;lt;/script&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;&amp;lt;/form&amp;gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&amp;lt;/body&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;Codebehind:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;protected&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; Page_Load(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color: teal;&quot;&gt;EventArgs&lt;/span&gt; e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;(!IsPostBack)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;{&lt;span style=&quot;&quot;&gt;            &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;            &lt;/span&gt;btnSubmit.Attributes.Add(&lt;span style=&quot;color: maroon;&quot;&gt;&quot;onclick&quot;&lt;/span&gt;, &lt;span style=&quot;color: maroon;&quot;&gt;&quot;return IsCheck();&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;            &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;( Request.QueryString[&lt;span style=&quot;color: maroon;&quot;&gt;&quot;CompanyId&quot;&lt;/span&gt;] != &lt;span style=&quot;color: blue;&quot;&gt;null&lt;/span&gt; &amp;amp;&amp;amp; Request.QueryString[&lt;span style=&quot;color: maroon;&quot;&gt;&quot;CompanyId&quot;&lt;/span&gt;] != &lt;span style=&quot;color: maroon;&quot;&gt;&quot;&quot;&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;&quot;&gt;         &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;                &lt;/span&gt;FillUsers(Request.QueryString[&lt;span style=&quot;color: maroon;&quot;&gt;&quot;CompanyId&quot;&lt;/span&gt;]);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;            &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; FillUsers(&lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; CompanyID)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;BLLPopUpUser&lt;/span&gt; ObjPopUpUser = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: teal;&quot;&gt;BLLPopUpUser&lt;/span&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;DataSet&lt;/span&gt; ds = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: teal;&quot;&gt;DataSet&lt;/span&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;ds = ObjPopUpUser.GetUserListfromCompany(CompanyID);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;ChkBoxListUsers.DataSource = ds;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;ChkBoxListUsers.DataTextField = &lt;span style=&quot;color: maroon;&quot;&gt;&quot;CU_UserID&quot;&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;ChkBoxListUsers.DataValueField = &lt;span style=&quot;color: maroon;&quot;&gt;&quot;CU_UserCode&quot;&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;ChkBoxListUsers.DataBind();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; ChkBoxListUsers_DataBound(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color: teal;&quot;&gt;EventArgs&lt;/span&gt; e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;CheckBoxList&lt;/span&gt; chkList = (&lt;span style=&quot;color: teal;&quot;&gt;CheckBoxList&lt;/span&gt;)(sender);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (Request.QueryString[&lt;span style=&quot;color: maroon;&quot;&gt;&quot;Users&quot;&lt;/span&gt;] != &lt;span style=&quot;color: blue;&quot;&gt;null&lt;/span&gt; &amp;amp;&amp;amp; Request.QueryString[&lt;span style=&quot;color: maroon;&quot;&gt;&quot;Users&quot;&lt;/span&gt;].ToString() != &lt;span style=&quot;color: maroon;&quot;&gt;&quot;&quot;&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt;[] users = Request.QueryString[&lt;span style=&quot;color: maroon;&quot;&gt;&quot;Users&quot;&lt;/span&gt;].ToString().Split(&lt;span style=&quot;color: maroon;&quot;&gt;&#39;,&#39;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; i = 0; i &amp;lt; users.Length; i++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;            &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;                &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (chkList.Items.FindByText(users[i]) != &lt;span style=&quot;color: blue;&quot;&gt;null&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;                &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;                    &lt;/span&gt;chkList.Items.FindByText(users[i]).Selected = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;                &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;            &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;}&lt;span style=&quot;&quot;&gt;                    &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;foreach&lt;/span&gt; (&lt;span style=&quot;color: teal;&quot;&gt;ListItem&lt;/span&gt; item &lt;span style=&quot;color: blue;&quot;&gt;in&lt;/span&gt; chkList.Items)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;         &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;               &lt;/span&gt;item.Attributes.Add(&lt;span style=&quot;color: maroon;&quot;&gt;&quot;title&quot;&lt;/span&gt;, item.Value);&lt;span style=&quot;&quot;&gt;                &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;         &lt;/span&gt;}&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;  &lt;div class=&quot;blogger-post-footer&quot;&gt;FeedBurner&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dflorence25.blogspot.com/feeds/1214521383462804041/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1084787999077704213/1214521383462804041' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/1214521383462804041'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/1214521383462804041'/><link rel='alternate' type='text/html' href='http://dflorence25.blogspot.com/2009/05/get-checkboxlist-values-using.html' title='Get the Checkboxlist values using javascript:'/><author><name>Flor</name><uri>http://www.blogger.com/profile/04517282987785226840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZYDSF-y7Vt7gRkup1yqg7Bn4ZODIz5NU2tDOUW10ZJaIM1D6fsTwAnmqU8WoJ88bq-dw_3l8jGR540YHTwHjr6NuJv-MBT47BwaJPkF2d2BNnV22Q5ddqbc9W3ut75w/s220/Flor.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1084787999077704213.post-3414584570249386052</id><published>2009-04-05T22:03:00.000-07:00</published><updated>2009-04-05T22:10:33.471-07:00</updated><title type='text'>Popup reminder on particular time in asp.net</title><content type='html'>Question::&lt;br /&gt;Hi ,&lt;br /&gt;&lt;br /&gt;     I have a implementation on reminders scenario on my webpage .It should work like outlook reminders with snooze functionality.i dont no how to starwith it Can any one guide me on this.  I am using VS2005 &amp;amp; SQL2005.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Answer 1 :&lt;br /&gt;&lt;br /&gt;The delegate is used when you need to access private variables in a method called by an event handler.  The bennefit is one javascript that can be attached to multiple elements and each element has its own life cycle and private data.&lt;br /&gt;&lt;br /&gt;setTimeout only runs once after a delay miliseconds.&lt;br /&gt;&lt;br /&gt;I&#39;m not that great with javascript.  I&#39;m great with using the javascript client libraries ( microsoft.ajax.js   jquery.js ...)   and implementing the ajaxextender control pattern in my own custom controls.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhy6foI9AKuXk3bbW_CVsu-nFw0vVkZBcQIftDalI_RJ7ZeGjE002Ji93j8k8DUJSIzZtL1ifyMwMqF85pdn2N9xrkMKR5eKOYsOVQORTeZd-O57qZ_3lG3P87v4GQSwTrZd8PDOYwP/s1600-h/scriptforreminder.JPG&quot;&gt;&lt;img style=&quot;cursor: pointer; width: 400px; height: 376px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhy6foI9AKuXk3bbW_CVsu-nFw0vVkZBcQIftDalI_RJ7ZeGjE002Ji93j8k8DUJSIzZtL1ifyMwMqF85pdn2N9xrkMKR5eKOYsOVQORTeZd-O57qZ_3lG3P87v4GQSwTrZd8PDOYwP/s400/scriptforreminder.JPG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5321441255517853042&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;Answer 2:&lt;br /&gt;&lt;br /&gt;USe Timer and run it for certain interval .. Store the time in database .for every interval check the time . on time show the pop up..&lt;br /&gt;&lt;br /&gt;Or use windows services.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.c-sharpcorner.com/UploadFile/mahesh/window_service11262005045007AM/window_service.aspx&quot;&gt;http://www.c-sharpcorner.com/UploadFile/mahesh/window_service11262005045007AM/window_service.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;this link has the basic to create a windows service ..&lt;br /&gt;&lt;br /&gt;In on_start event you can  create a timer which will help to do ur work&lt;div class=&quot;blogger-post-footer&quot;&gt;FeedBurner&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dflorence25.blogspot.com/feeds/3414584570249386052/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1084787999077704213/3414584570249386052' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/3414584570249386052'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/3414584570249386052'/><link rel='alternate' type='text/html' href='http://dflorence25.blogspot.com/2009/04/popup-reminder-on-particular-time-in.html' title='Popup reminder on particular time in asp.net'/><author><name>Flor</name><uri>http://www.blogger.com/profile/04517282987785226840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZYDSF-y7Vt7gRkup1yqg7Bn4ZODIz5NU2tDOUW10ZJaIM1D6fsTwAnmqU8WoJ88bq-dw_3l8jGR540YHTwHjr6NuJv-MBT47BwaJPkF2d2BNnV22Q5ddqbc9W3ut75w/s220/Flor.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhy6foI9AKuXk3bbW_CVsu-nFw0vVkZBcQIftDalI_RJ7ZeGjE002Ji93j8k8DUJSIzZtL1ifyMwMqF85pdn2N9xrkMKR5eKOYsOVQORTeZd-O57qZ_3lG3P87v4GQSwTrZd8PDOYwP/s72-c/scriptforreminder.JPG" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1084787999077704213.post-5469374122726273818</id><published>2009-03-16T01:21:00.000-07:00</published><updated>2009-03-16T01:23:53.303-07:00</updated><title type='text'>saving TreeView&#39;s state</title><content type='html'>I write a general routine that does the state caching, but it was for leaving a page and coming back to it.  (i.e., select a node, then click &quot;Edit&quot; -- which shoots you to an &quot;Edit&quot; page that&#39;s not in a hidden panel on the same page... after you&#39;re done editing, you get Response.Redirect-ed back to the TreeView page and the expand/collapse/selected-node state is all gone... that&#39;s the issue this addresses.)&lt;br /&gt;&lt;br /&gt;It&#39;s implemented in two static methods that I popped into a &quot;TreeViewHelper&quot; static class.  Whenever you need to leave the page, call the &quot;StoreTreeViewStateToSession&quot; method.  In your method to bind data to your TreeView, call RestoreTreeViewStateFromSession.  If there&#39;s no stored state, it just returns silently.  If there is stored state, it&#39;ll restore it (which nodes are expanded and collapsed, and which node is selected).&lt;br /&gt;&lt;br /&gt;They use Session state, which seems appropriate since it&#39;s obviously by-user, and cross-page.  But the Session variable key has the page name embedded in it, which would cause it *not* to work in your solution (since it&#39;s a different page trying to restore the state).  A minor tweak to this routine would remedy that issue, however.  Store as the variable name suffix a &quot;key&quot; common to your PageA, PageB, etc., instead of Request.ServerVariables[&quot;path_info&quot;].&lt;br /&gt;&lt;br /&gt;Here&#39;s the code.  I&#39;ve just recently adapted it from the IEWebControls TreeView add-on (circa .NET 1.0) and updated it to work with the ASP.NET 2.0 TreeView control.  It seems to work like a charm:&lt;br /&gt;&lt;br /&gt;     &lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;public static void StoreTreeViewStateToSession(TreeView tvIn)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;      {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;         // Takes the TreeView&#39;s state and saves it in a Session variable&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;         // Call this method before leaving the page if we expect to be back&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;         string strVarName;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;         string strList = &quot;&quot;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;         strVarName = &quot;tv_&quot; + HttpContext.Current.Request.ServerVariables[&quot;path_info&quot;];&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;         if (HttpContext.Current.Session[strVarName] + &quot;&quot; != &quot;&quot;)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;         {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;            HttpContext.Current.Session.Remove(strVarName);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;         }&lt;/span&gt;&lt;br /&gt;         &lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;         StoreTreeViewStateToSession_Recurse(tvIn.Nodes[0], ref strList);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;         strList = tvIn.SelectedNode.ValuePath + strList;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;         HttpContext.Current.Session.Add(strVarName, strList);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;      }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;      private static void StoreTreeViewStateToSession_Recurse(TreeNode tnIn, ref string strList)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;      {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;         if (tnIn.Expanded == true)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;         {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;            strList = &quot;,&quot; + tnIn.ValuePath + strList;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;         }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;         foreach (TreeNode tnCurrent in tnIn.ChildNodes)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;         {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;            StoreTreeViewStateToSession_Recurse(tnCurrent, ref strList);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;         }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;      }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;      public static void RestoreTreeViewStateFromSession(TreeView tvIn)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;      {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;         // Takes the Session-stored TreeView state and restores it&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;         // to the passed-in TreeView control.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;         // Call this method on entry to the page.  Nothing will&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;         // happen if the variable doesn&#39;t exist.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;         string strVarName;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;         // See if stored data exists for this treeview&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;         strVarName = &quot;tv_&quot; + HttpContext.Current.Request.ServerVariables[&quot;path_info&quot;];&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;         if (HttpContext.Current.Session[strVarName] + &quot;&quot; != &quot;&quot;)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;         {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;            string strSelectedNodeIndex = &quot;&quot;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;            foreach (string strCurrent in HttpContext.Current.Session[strVarName].ToString().Split(&#39;,&#39;))&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;               if (strSelectedNodeIndex == &quot;&quot;) // First element in list is selected node&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;               {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;                  strSelectedNodeIndex = strCurrent;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;               }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;               else&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;               {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;                  try&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;                  {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;                     tvIn.FindNode(strCurrent).Expanded = true;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;                  }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;                  catch&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;                  {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;                     //eat exception&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;                  }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;               }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;            try&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;               // Verify that node exists before setting SelectedNodeIndex&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;               TreeNode tnTest = tvIn.FindNode(strSelectedNodeIndex);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;               // Select the node (will only happen if it exists)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;               tvIn.FindNode(strSelectedNodeIndex).Select();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;               // Ensure the selected node&#39;s parent is expanded&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;               ((TreeNode)tvIn.FindNode(tvIn.SelectedNode.ValuePath).Parent).Expanded = true;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;            catch&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;               // eat exception&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;            HttpContext.Current.Session.Remove(strVarName);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;         }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 204, 204);&quot;&gt;      }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;... Hope that helps!!!  See my other post on client-side node selection without forcing PostBack (http://forums.asp.net/thread/1452479.aspx) if you&#39;re interested in another of my TreeViewHelper tools, which I&#39;m pretty pleased with lately.  Microsoft so needs to hire me.  ;-)&lt;div class=&quot;blogger-post-footer&quot;&gt;FeedBurner&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dflorence25.blogspot.com/feeds/5469374122726273818/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1084787999077704213/5469374122726273818' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/5469374122726273818'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/5469374122726273818'/><link rel='alternate' type='text/html' href='http://dflorence25.blogspot.com/2009/03/saving-treeviews-state.html' title='saving TreeView&#39;s state'/><author><name>Flor</name><uri>http://www.blogger.com/profile/04517282987785226840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZYDSF-y7Vt7gRkup1yqg7Bn4ZODIz5NU2tDOUW10ZJaIM1D6fsTwAnmqU8WoJ88bq-dw_3l8jGR540YHTwHjr6NuJv-MBT47BwaJPkF2d2BNnV22Q5ddqbc9W3ut75w/s220/Flor.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1084787999077704213.post-4114214544478510803</id><published>2009-03-13T01:15:00.000-07:00</published><updated>2009-03-13T01:29:50.569-07:00</updated><title type='text'>Ajax PageMethods using JSON (JavaScript Object Notation)</title><content type='html'>&lt;h3&gt;Page Methods&lt;/h3&gt;&lt;p&gt;Page methods allow ASP.NET AJAX pages to directly execute &lt;a href=&quot;http://encosia.com/2008/04/16/why-do-aspnet-ajax-page-methods-have-to-be-static/&quot;&gt;a page’s static methods&lt;/a&gt;, using &lt;a href=&quot;http://json.org/&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;JSON&lt;/a&gt; (JavaScript Object Notation). JSON is basically a minimalistic version of SOAP, which is perfectly suited for light weight communication between client and server. For more information about how to implement page methods and JSON, take a look at Microsoft’s &lt;a href=&quot;http://ajax.asp.net/docs/tutorials/ExposingWebServicesToAJAXTutorial.aspx&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;Exposing Web Services to Client Script in ASP.NET AJAX&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Instead of posting back and then receiving HTML markup to completely replace our UpdatePanel’s contents, we can use a web method to request only the information that we’re interested in:&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;h3&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguIUH8YkTN1rTls6OmUomhFDmIm1ieVMZy1ViK6fhBj2NYK9vzGy0wJsud60axNAwxO7gjPolvGsZoW2AAN4h2extQS9JwdL5obSxaTIhAExbpYI3gx-ZHwmgq7MelLE6lMp6lQtkW/s1600-h/code.GIF&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 290px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguIUH8YkTN1rTls6OmUomhFDmIm1ieVMZy1ViK6fhBj2NYK9vzGy0wJsud60axNAwxO7gjPolvGsZoW2AAN4h2extQS9JwdL5obSxaTIhAExbpYI3gx-ZHwmgq7MelLE6lMp6lQtkW/s400/code.GIF&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5312585997596704578&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/h3&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 102, 0);&quot;&gt;[WebMethod]&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 102, 0);&quot;&gt;public static string GetCurrentDate()&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 102, 0);&quot;&gt;{&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 102, 0);&quot;&gt;  return DateTime.Now.ToLongDateString();&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 102, 0);&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;Using JSON, the entire HTTP round trip is 24 bytes, as compared to 872 bytes for the UpdatePanel. That’s roughly a 4,000% improvement, which will only continue to increase with the complexity of the page.&lt;/p&gt; &lt;p&gt;Not only has this reduced our network footprint dramatically, but it eliminates the necessity for the server to instantiate the UpdatePanel’s controls and take them through their life cycles to render the HTML sent back to the browser.&lt;/p&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;FeedBurner&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dflorence25.blogspot.com/feeds/4114214544478510803/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1084787999077704213/4114214544478510803' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/4114214544478510803'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/4114214544478510803'/><link rel='alternate' type='text/html' href='http://dflorence25.blogspot.com/2009/03/ajax-pagemethods-using-json-javascript.html' title='Ajax PageMethods using JSON (JavaScript Object Notation)'/><author><name>Flor</name><uri>http://www.blogger.com/profile/04517282987785226840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZYDSF-y7Vt7gRkup1yqg7Bn4ZODIz5NU2tDOUW10ZJaIM1D6fsTwAnmqU8WoJ88bq-dw_3l8jGR540YHTwHjr6NuJv-MBT47BwaJPkF2d2BNnV22Q5ddqbc9W3ut75w/s220/Flor.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguIUH8YkTN1rTls6OmUomhFDmIm1ieVMZy1ViK6fhBj2NYK9vzGy0wJsud60axNAwxO7gjPolvGsZoW2AAN4h2extQS9JwdL5obSxaTIhAExbpYI3gx-ZHwmgq7MelLE6lMp6lQtkW/s72-c/code.GIF" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1084787999077704213.post-7911686509807002779</id><published>2008-12-18T01:44:00.000-08:00</published><updated>2008-12-18T01:44:52.864-08:00</updated><title type='text'>Florence Blogspot about asp.net tutorials and web design and web development: Preventing Caching of htm and images being stored in Client Machine</title><content type='html'>&lt;a href=&quot;http://dflorence25.blogspot.com/2008/12/preventing-caching-of-htm-and-images.html&quot;&gt;Florence Blogspot about asp.net tutorials and web design and web development: Preventing Caching of htm and images being stored in Client Machine&lt;/a&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;FeedBurner&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dflorence25.blogspot.com/feeds/7911686509807002779/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1084787999077704213/7911686509807002779' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/7911686509807002779'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/7911686509807002779'/><link rel='alternate' type='text/html' href='http://dflorence25.blogspot.com/2008/12/florence-blogspot-about-aspnet.html' title='Florence Blogspot about asp.net tutorials and web design and web development: Preventing Caching of htm and images being stored in Client Machine'/><author><name>Flor</name><uri>http://www.blogger.com/profile/04517282987785226840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZYDSF-y7Vt7gRkup1yqg7Bn4ZODIz5NU2tDOUW10ZJaIM1D6fsTwAnmqU8WoJ88bq-dw_3l8jGR540YHTwHjr6NuJv-MBT47BwaJPkF2d2BNnV22Q5ddqbc9W3ut75w/s220/Flor.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1084787999077704213.post-526082986360040134</id><published>2008-12-18T01:26:00.000-08:00</published><updated>2008-12-18T01:41:54.482-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Preventing Caching of htm and images being stored in Client Machine"/><title type='text'>Preventing Caching of htm and images being stored in Client Machine</title><content type='html'>&lt;strong&gt;&lt;span style=&quot;font-size:180%;color:#ff6600;&quot;&gt;Preventing Caching of htm and images being stored in Client Machine in Temporaray Internet Files.&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#ff6600;&quot;&gt;Open IIS by:&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#ff6600;&quot;&gt;1. Go to START--&gt;RUN--&gt;Type inetmgr&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#ff6600;&quot;&gt;2. Click Website/Default Web Site.&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#ff6600;&quot;&gt;3.Select Properties by Right Clicking your Virtual Directory Ex: TestApp.&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#ff6600;&quot;&gt;4.In the Properties Dialog Box, Select HTTP Header Tab.&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#ff6600;&quot;&gt;5.In the Custom HTTP Header Column, Click Add Button.&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#ff6600;&quot;&gt;6. It will open another dialog box.&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#ff6600;&quot;&gt;7. In the Add/Edit Custom HTTP Header.&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#ff6600;&quot;&gt;1.Type &quot;cache-control&quot; in Header Name and&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#ff6600;&quot;&gt;2.Type &quot;no-cache&quot; in Header Value&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#ff6600;&quot;&gt;3.Click Ok&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#ff6600;&quot;&gt;8.Again In the Add/Edit Custom HTTP Header.&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#ff6600;&quot;&gt;1.Type &quot;programa&quot; in Header Name and&lt;br /&gt;2.Type &quot;no-cache&quot; in Header Value&lt;br /&gt;3.Click Ok&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#ff6600;&quot;&gt;9.Click ok in all dialog boxes and exit from IIS.&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#ff6600;&quot;&gt;Now check your cache in Temporary Internet Files folder.&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#ff6600;&quot;&gt;No no no no no cache..................rit...........&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#ff6600;&quot;&gt;How is it!!!!!!!!&lt;/span&gt;&lt;/strong&gt; Coo000000000l............&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#ff6600;&quot;&gt;&lt;/span&gt;&lt;/strong&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;FeedBurner&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dflorence25.blogspot.com/feeds/526082986360040134/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1084787999077704213/526082986360040134' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/526082986360040134'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/526082986360040134'/><link rel='alternate' type='text/html' href='http://dflorence25.blogspot.com/2008/12/preventing-caching-of-htm-and-images.html' title='Preventing Caching of htm and images being stored in Client Machine'/><author><name>Flor</name><uri>http://www.blogger.com/profile/04517282987785226840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZYDSF-y7Vt7gRkup1yqg7Bn4ZODIz5NU2tDOUW10ZJaIM1D6fsTwAnmqU8WoJ88bq-dw_3l8jGR540YHTwHjr6NuJv-MBT47BwaJPkF2d2BNnV22Q5ddqbc9W3ut75w/s220/Flor.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1084787999077704213.post-6987530210170486738</id><published>2008-11-23T21:01:00.000-08:00</published><updated>2008-11-23T21:06:55.895-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Generating pdf report using asp.net"/><title type='text'>Generating pdf report using asp.net</title><content type='html'>&lt;div align=&quot;left&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color:#3333ff;&quot;&gt;                               PDF analysis by Florence.D&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I have found some free components for generating pdf report using asp.net&lt;br /&gt;&lt;br /&gt;iTextSharp.dll&lt;br /&gt;&lt;br /&gt;ghtml2Pdf.exe&lt;br /&gt;&lt;br /&gt;PDFSharp.dll&lt;br /&gt;&lt;br /&gt;ApacheFop.net.dll&lt;br /&gt;&lt;br /&gt;But I found some difficulty in the above components :&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#cc0000;&quot;&gt;iTextSharp.dll: &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In iTextSharp,&lt;br /&gt;&lt;br /&gt;we can use 2 methods here&lt;br /&gt;&lt;br /&gt;By passing the whole html script as string&lt;br /&gt;&lt;br /&gt;by create a table in the code behind.&lt;br /&gt;&lt;br /&gt;Our requirement is to generate the 1000 lines of html script into pdf.&lt;br /&gt;&lt;br /&gt;So it is high risk to pass the 1000 lines of html script into string and also in the code behind it is not possible to create a each table in the code behind because every time the script generated may vary..&lt;br /&gt;Only we can create a simple pdf not complex html scripts.&lt;br /&gt;&lt;br /&gt;We cannot write the 1000 lines of html script into iTextSharp.dll.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#cc0000;&quot;&gt;ghtml2Pdf.exe:&lt;br /&gt;&lt;/span&gt;Here we are using the exe component to generate the pdf file by passing the html file.&lt;br /&gt;We have to generate the html file first and then pass that file into ghtml2Pdf.exe.&lt;br /&gt;It is high riskable in the dotnet framework. Morever the we cannot use this in our whole servers.&lt;br /&gt;It has the rights to work in only limited number of computers.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#cc0000;&quot;&gt;PDFSharp.dll&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Here again we cannot use the html scripts to generate the pdf.&lt;br /&gt;We have to create our own design in the codebehind. Again the same problem that every time the design or the html script may vary according to the report generated.&lt;br /&gt;&lt;span style=&quot;color:#ff0000;&quot;&gt;ApacheFop.net.dll&lt;br /&gt;&lt;/span&gt;This is the good method to generate the pdf in dotnet using java classes.&lt;br /&gt;Also we need vjslib.dll to work with the Java classess.&lt;br /&gt;The process is some wat critical.&lt;br /&gt;First we have to create a xml file to store the datas needed.&lt;br /&gt;Then we have to create a design pattern like stylesheet using xsl.&lt;br /&gt;After creating the xml and xsl, we have to transform these two and need to generate the fo file ie Formatted object file.&lt;br /&gt;After the fo file created , we can generate the pdf from the fo file.&lt;br /&gt;This is the structure.&lt;br /&gt;But this requires some amount of time.&lt;br /&gt;&lt;span style=&quot;color:#009900;&quot;&gt;Using Java:&lt;/span&gt;&lt;br /&gt;&lt;a href=&quot;http://www.javaworld.com/javaworld/jw-04-2006/jw-0410-html.html&quot;&gt;http://www.javaworld.com/javaworld/jw-04-2006/jw-0410-html.html&lt;/a&gt;&lt;br /&gt;Here is the link where I read article for generating pdf using java.&lt;br /&gt;It is a difficult process same as the above one.&lt;br /&gt;&lt;span style=&quot;color:#009900;&quot;&gt;Conclusion.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;I have found lot of premium shareware components to generate the pdf from html.&lt;br /&gt;&lt;br /&gt;It average costs from 600 to 1000 $.&lt;br /&gt;The best is &lt;/div&gt;&lt;div align=&quot;left&quot;&gt; &lt;a href=&quot;http://www.winnovative-software.com/&quot;&gt;www.winnovative-software.com&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;http://www.winnovative-software.com/Buy.aspx#redistributable&quot;&gt;http://www.winnovative-software.com/Buy.aspx#redistributable&lt;/a&gt;&lt;br /&gt;cost for redistributable pacakage is&lt;br /&gt;&lt;br /&gt;INR 33938.41&lt;br /&gt;&lt;br /&gt;Some other premium components&lt;br /&gt;&lt;a href=&quot;http://www.html-to-pdf.net/Pricing.aspx&quot;&gt;http://www.html-to-pdf.net/Pricing.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Hope all got some knowledge anyone who started creating pdf. &lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;FeedBurner&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dflorence25.blogspot.com/feeds/6987530210170486738/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1084787999077704213/6987530210170486738' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/6987530210170486738'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/6987530210170486738'/><link rel='alternate' type='text/html' href='http://dflorence25.blogspot.com/2008/11/generating-pdf-report-using-aspnet.html' title='Generating pdf report using asp.net'/><author><name>Flor</name><uri>http://www.blogger.com/profile/04517282987785226840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZYDSF-y7Vt7gRkup1yqg7Bn4ZODIz5NU2tDOUW10ZJaIM1D6fsTwAnmqU8WoJ88bq-dw_3l8jGR540YHTwHjr6NuJv-MBT47BwaJPkF2d2BNnV22Q5ddqbc9W3ut75w/s220/Flor.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1084787999077704213.post-5043524115432215667</id><published>2008-11-23T20:20:00.000-08:00</published><updated>2008-11-23T20:49:46.363-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Exporting WebPage to Excel using Javascript"/><title type='text'>Exporting WebPage to Excel using Javascript.</title><content type='html'>&lt;div&gt;Refered from : &lt;a Href=&quot;http://www.activewidgets.com/javascript.forum.6068.17/client-side-grid-export-to.html&quot;&gt; Javascript&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5272080020455493554&quot; style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 368px; CURSOR: hand; HEIGHT: 400px; TEXT-ALIGN: center&quot; alt=&quot;Export2Excelinjavascript&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhja1AQJlmlLb37g51tDijx1CcZiUmid4__mtZx7iW0FeyYcR5eE4NCsPoFPNnsDfYOYOpgcHzrWn-RYxXVaeyRBCK_qOU7sPTK5Pea39WnMRirB7hnAFZWEBd9YeLameLXJ1amJwJD/s400/export2excel.JPG&quot; border=&quot;0&quot; /&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;FeedBurner&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dflorence25.blogspot.com/feeds/5043524115432215667/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1084787999077704213/5043524115432215667' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/5043524115432215667'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/5043524115432215667'/><link rel='alternate' type='text/html' href='http://dflorence25.blogspot.com/2008/11/exporting-webpage-to-excel-using.html' title='Exporting WebPage to Excel using Javascript.'/><author><name>Flor</name><uri>http://www.blogger.com/profile/04517282987785226840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZYDSF-y7Vt7gRkup1yqg7Bn4ZODIz5NU2tDOUW10ZJaIM1D6fsTwAnmqU8WoJ88bq-dw_3l8jGR540YHTwHjr6NuJv-MBT47BwaJPkF2d2BNnV22Q5ddqbc9W3ut75w/s220/Flor.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhja1AQJlmlLb37g51tDijx1CcZiUmid4__mtZx7iW0FeyYcR5eE4NCsPoFPNnsDfYOYOpgcHzrWn-RYxXVaeyRBCK_qOU7sPTK5Pea39WnMRirB7hnAFZWEBd9YeLameLXJ1amJwJD/s72-c/export2excel.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1084787999077704213.post-2374921596829890395</id><published>2008-08-11T03:57:00.000-07:00</published><updated>2008-09-22T04:17:59.529-07:00</updated><title type='text'>Yahoo contacts!!! import class in C#</title><content type='html'>I tried to find free Yahoo! Contact import code for .NET platform. I found only paid packages for 300+$.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I&#39;ve implemented importing and you can use it for free.&lt;br /&gt;(But you need to make some change in code to compile it)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;&lt;br /&gt;using System.Collections.Specialized;&lt;br /&gt;&lt;br /&gt;using System.Net;&lt;br /&gt;&lt;br /&gt;using System.Text;&lt;br /&gt;&lt;br /&gt;using System.Text.RegularExpressions;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;namespace Gnilly.Syndication.Mail&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;public class YahooExtract&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;private const string _addressBookUrl = &quot;&lt;a href=&quot;http://address.yahoo.com/yab/us/Yahoo_ab.csv?loc=us&amp;amp;.rand=1671497644&amp;amp;A=H&amp;amp;Yahoo_ab.csv&quot;&gt;http://address.yahoo.com/yab/us/Yahoo_ab.csv?loc=us&amp;amp;.rand=1671497644&amp;amp;A=H&amp;amp;Yahoo_ab.csv&lt;/a&gt;&quot;;&lt;br /&gt;&lt;br /&gt;private const string _authUrl = &quot;&lt;a href=&quot;https://login.yahoo.com/config/login&quot;&gt;https://login.yahoo.com/config/login&lt;/a&gt;?&quot;; private const string _loginPage = &quot;&lt;a href=&quot;https://login.yahoo.com/config/login&quot;&gt;https://login.yahoo.com/config/login&lt;/a&gt;&quot;;&lt;br /&gt;&lt;br /&gt;private const string _userAgent = &quot;Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3&quot;;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public bool Extract( NetworkCredential credential, out MailContactList list )&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;bool result = false;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;list = new MailContactList();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;try&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;WebClient webClient = new WebClient(); webClient.Headers[ HttpRequestHeader.UserAgent ] = _userAgent; webClient.Encoding = Encoding.UTF8;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;byte[] firstResponse = webClient.DownloadData( _loginPage );&lt;br /&gt;&lt;br /&gt;string firstRes = Encoding.UTF8.GetString( firstResponse );&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;NameValueCollection postToLogin = new NameValueCollection();&lt;br /&gt;&lt;br /&gt;Regex regex = new Regex( &quot;type=\&quot;hidden\&quot; name=\&quot;(.*?)\&quot; value=\&quot;(.*?)\&quot;&quot;, RegexOptions.IgnoreCase );&lt;br /&gt;&lt;br /&gt;Match match = regex.Match( firstRes );&lt;br /&gt;&lt;br /&gt;while ( match.Success )&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;if ( match.Groups[ 0 ].Value.Length &amp;gt; 0 )&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;postToLogin.Add( match.Groups[ 1 ].Value, match.Groups[ 2 ].Value );&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;match = regex.Match( firstRes, match.Index + match.Length );&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;postToLogin.Add( &quot;.save&quot;, &quot;Sign In&quot; );&lt;br /&gt;&lt;br /&gt;postToLogin.Add( &quot;.persistent&quot;, &quot;y&quot; );&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;string login = credential.UserName.Split( &lt;a href=&quot;mailto:&quot;&gt;&#39;@&#39;&lt;/a&gt; )[ 0 ];&lt;br /&gt;&lt;br /&gt;postToLogin.Add( &quot;login&quot;, login );&lt;br /&gt;&lt;br /&gt;postToLogin.Add( &quot;passwd&quot;, credential.Password );&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;webClient.Headers[ HttpRequestHeader.UserAgent ] = _userAgent;&lt;br /&gt;&lt;br /&gt;webClient.Headers[ HttpRequestHeader.Referer ] = _loginPage;&lt;br /&gt;&lt;br /&gt;webClient.Encoding = Encoding.UTF8;&lt;br /&gt;&lt;br /&gt;webClient.Headers[ HttpRequestHeader.Cookie ] = webClient.ResponseHeaders[ HttpResponseHeader.SetCookie ];&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;webClient.UploadValues( _authUrl, postToLogin );&lt;br /&gt;&lt;br /&gt;string cookie = webClient.ResponseHeaders[ HttpResponseHeader.SetCookie ];&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if ( string.IsNullOrEmpty( cookie ) )&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;return false;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;string newCookie = string.Empty;&lt;br /&gt;&lt;br /&gt;string[] tmp1 = cookie.Split( &#39;,&#39; );&lt;br /&gt;&lt;br /&gt;foreach ( string var in tmp1 )&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;string[] tmp2 = var.Split( &#39;;&#39; );&lt;br /&gt;&lt;br /&gt;newCookie = String.IsNullOrEmpty( newCookie ) ? tmp2[ 0 ] : newCookie + &quot;;&quot; + tmp2[ 0 ];&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// set login cookie&lt;br /&gt;&lt;br /&gt;webClient.Headers[ HttpRequestHeader.Cookie ] = newCookie;&lt;br /&gt;&lt;br /&gt;byte[] thirdResponse = webClient.DownloadData( _addressBookUrl );&lt;br /&gt;&lt;br /&gt;string thirdRes = Encoding.UTF8.GetString( thirdResponse );&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;string crumb = string.Empty;&lt;br /&gt;&lt;br /&gt;Regex regexCrumb = new Regex( &quot;type=\&quot;hidden\&quot; name=\&quot;&lt;a href=&quot;file://.crumb/&quot;&gt;file://.crumb/&lt;/a&gt;&quot; id=\&quot;crumb1\&quot; value=\&quot;(.*?)\&quot;&quot;, RegexOptions.IgnoreCase );&lt;br /&gt;&lt;br /&gt;match = regexCrumb.Match( thirdRes );&lt;br /&gt;&lt;br /&gt;if ( match.Success &amp;amp;&amp;amp; match.Groups[ 0 ].Value.Length &amp;gt;) )&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;crumb = match.Groups[ 1 ].Value;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;NameValueCollection postDataAB = new NameValueCollection();&lt;br /&gt;&lt;br /&gt;postDataAB.Add( &quot;.crumb&quot;, crumb );&lt;br /&gt;&lt;br /&gt;postDataAB.Add( &quot;vcp&quot;, &quot;import_export&quot; );&lt;br /&gt;&lt;br /&gt;postDataAB.Add( &quot;submit[action_export_yahoo]&quot;, &quot;Export Now&quot; );&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;webClient.Headers[ HttpRequestHeader.UserAgent ] = _userAgent;&lt;br /&gt;&lt;br /&gt;webClient.Headers[ HttpRequestHeader.Referer ] = _addressBookUrl;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;byte[] FourResponse = webClient.UploadValues( _addressBookUrl, postDataAB );&lt;br /&gt;&lt;br /&gt;string csvData = Encoding.UTF8.GetString( FourResponse );&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;string[] lines = csvData.Split( &#39;\n&#39; ); foreach ( string line in lines )&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;string[] items = line.Split( &#39;,&#39; );&lt;br /&gt;&lt;br /&gt;if ( items.Length &amp;lt; 5 )&lt;br /&gt;&lt;br /&gt;{ continue;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;string email = items[ 4 ];&lt;br /&gt;&lt;br /&gt;string name = items[ 3 ];&lt;br /&gt;&lt;br /&gt;if ( !string.IsNullOrEmpty( email ) &amp;amp;&amp;amp; !string.IsNullOrEmpty( name ) )&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;email = email.Trim( &#39;\&quot;&#39; );&lt;br /&gt;&lt;br /&gt;name = name.Trim( &#39;\&quot;&#39; );&lt;br /&gt;&lt;br /&gt;if ( !email.Equals( &quot;Email&quot; ) &amp;amp;&amp;amp; !name.Equals( &quot;Nickname&quot; ) )&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;MailContact mailContact = new MailContact();&lt;br /&gt;&lt;br /&gt;mailContact.Name = name;&lt;br /&gt;&lt;br /&gt;mailContact.Email = email;&lt;br /&gt;&lt;br /&gt;list.Add( mailContact );&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;result = true;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;catch&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;return result;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;div class=&quot;blogger-post-footer&quot;&gt;FeedBurner&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dflorence25.blogspot.com/feeds/2374921596829890395/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1084787999077704213/2374921596829890395' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/2374921596829890395'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/2374921596829890395'/><link rel='alternate' type='text/html' href='http://dflorence25.blogspot.com/2008/08/yahoo-contacts-import-class-in-c.html' title='Yahoo contacts!!! import class in C#'/><author><name>Flor</name><uri>http://www.blogger.com/profile/04517282987785226840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZYDSF-y7Vt7gRkup1yqg7Bn4ZODIz5NU2tDOUW10ZJaIM1D6fsTwAnmqU8WoJ88bq-dw_3l8jGR540YHTwHjr6NuJv-MBT47BwaJPkF2d2BNnV22Q5ddqbc9W3ut75w/s220/Flor.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1084787999077704213.post-2420897827642277433</id><published>2008-07-27T22:12:00.000-07:00</published><updated>2008-07-27T22:30:30.503-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Adding GOOGLE MAP into your .NET website in just 15 minutes"/><title type='text'>Adding google MAP into your .NET website in just 15 minutes</title><content type='html'>&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#009900;&quot;&gt;Adding GOOGLE MAP into your .NET website in just 15 minutes by Florence &lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:#009900;&quot;&gt;Ever wanted to add a Google Map to your site but only had 15 minutes to spare? Now you can add a map and still have time to brag to your mates and bask in the worship that (inevitably) comes afterward. Basically, the guys over at subgurim.net have already done all the hard work in writing the .Net wrapper for Google Maps. Problem is, the examples on their site are mostly in spanish &amp;amp; its a bit difficult to find out exactly what is needed to get everything working. But all this is cutting into your bragging time - so lets get started! &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:#009900;&quot;&gt;&lt;em&gt;1. Get a Google Maps API key from here:&lt;/em&gt;&lt;/span&gt;&lt;a href=&quot;http://www.google.com/apis/maps/&quot;&gt;&lt;span style=&quot;color:#009900;&quot;&gt;&lt;em&gt;http://www.google.com/apis/maps/&lt;/em&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color:#009900;&quot;&gt;&lt;em&gt; &lt;/em&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:#009900;&quot;&gt;&lt;em&gt;2. Download the SubGurim wrapper dll from here:&lt;/em&gt;&lt;/span&gt;&lt;a href=&quot;http://en.googlemaps.subgurim.net/descargar.aspx&quot;&gt;&lt;span style=&quot;color:#009900;&quot;&gt;&lt;em&gt;http://en.googlemaps.subgurim.net/descargar.aspx&lt;/em&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color:#009900;&quot;&gt;&lt;em&gt; &lt;/em&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:#009900;&quot;&gt;&lt;em&gt;3. Unzip it, and put it in your \bin directory &lt;/em&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:#009900;&quot;&gt;&lt;em&gt;4. Add it to your toolbox byTools -&gt; Choose Toolbox Items -&gt; Browse -&gt; Select the .dll file -&gt; OKGMap will now be in the ‘Standard’ area of your Toolbox. &lt;/em&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:#009900;&quot;&gt;&lt;em&gt;5. Add a new webpage. 6. Drag the GMap from the toolbox onto the page. A new instance of the GMap will appear on the page, with the name ‘GMap1′ &lt;/em&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:#009900;&quot;&gt;&lt;em&gt;7. Add the following lines to your web.config file: appsettings add value=&quot;YourGoogleMapsAPIKeyHere&quot; key=&quot;googlemaps.subgurim.net&quot; appsettings 8. Add the following code to your Page.Load sub&lt;br /&gt;Dim sStreetAddress As String Dim sMapKey As String = ConfigurationManager.AppSettings(&quot;googlemaps.subgurim.net&quot;) Dim GeoCode As Subgurim.Controles.GeoCode sStreetAddress = &quot;100 Russell St. Melbourne. VIC. 3000. Australia&quot; GeoCode = GMap1.geoCodeRequest(sStreetAddress, sMapKey) Dim gLatLng As New Subgurim.Controles.GLatLng(GeoCode.Placemark.coordinates.lat, GeoCode.Placemark.coordinates.lng) GMap1.setCenter(gLatLng, 16, Subgurim.Controles.GMapType.GTypes.Normal) Dim oMarker As New Subgurim.Controles.GMarker(gLatLng) GMap1.addGMarker(oMarker)&lt;br /&gt;&lt;/em&gt;&lt;strong&gt;Press F5, and start basking in the glory!&lt;/strong&gt; &lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;FeedBurner&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dflorence25.blogspot.com/feeds/2420897827642277433/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1084787999077704213/2420897827642277433' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/2420897827642277433'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/2420897827642277433'/><link rel='alternate' type='text/html' href='http://dflorence25.blogspot.com/2008/07/adding-google-map-into-your-net-website.html' title='Adding google MAP into your .NET website in just 15 minutes'/><author><name>Flor</name><uri>http://www.blogger.com/profile/04517282987785226840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZYDSF-y7Vt7gRkup1yqg7Bn4ZODIz5NU2tDOUW10ZJaIM1D6fsTwAnmqU8WoJ88bq-dw_3l8jGR540YHTwHjr6NuJv-MBT47BwaJPkF2d2BNnV22Q5ddqbc9W3ut75w/s220/Flor.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1084787999077704213.post-7696392764433908686</id><published>2008-07-11T05:11:00.000-07:00</published><updated>2008-07-11T05:11:54.948-07:00</updated><title type='text'>Florence Blogspot about asp.net tutorials and web design and web development</title><content type='html'>&lt;a href=&quot;http://dflorence25.blogspot.com/2008/07/vb.html#links&quot;&gt;Florence Blogspot about asp.net tutorials and web design and web development&lt;/a&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;FeedBurner&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dflorence25.blogspot.com/feeds/7696392764433908686/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1084787999077704213/7696392764433908686' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/7696392764433908686'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/7696392764433908686'/><link rel='alternate' type='text/html' href='http://dflorence25.blogspot.com/2008/07/florence-blogspot-about-aspnet.html' title='Florence Blogspot about asp.net tutorials and web design and web development'/><author><name>Flor</name><uri>http://www.blogger.com/profile/04517282987785226840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZYDSF-y7Vt7gRkup1yqg7Bn4ZODIz5NU2tDOUW10ZJaIM1D6fsTwAnmqU8WoJ88bq-dw_3l8jGR540YHTwHjr6NuJv-MBT47BwaJPkF2d2BNnV22Q5ddqbc9W3ut75w/s220/Flor.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1084787999077704213.post-2194451243549520938</id><published>2008-07-11T04:39:00.000-07:00</published><updated>2008-07-14T04:06:54.192-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="VB.NET and C# Programming Basics"/><title type='text'></title><content type='html'>&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;color:#6600cc;&quot;&gt;&lt;br /&gt;&lt;strong&gt;VB.NET and C# Programming Basics&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;strong&gt;&lt;/strong&gt;&lt;div align=&quot;center&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color:#6600cc;&quot;&gt;VB.NET and C# are great programming languages because they offer a structured way of programming. By structured, I mean that code is separated into modules,&lt;br /&gt;where each module defines classes that can be imported and used in other modules. Both languages are relatively simple to get started with, yet offer features sophisticated enough for complex, large-scale enterprise applications.&lt;br /&gt; &lt;br /&gt;Each language&#39;s ability to support more complex applications (its scalability) stems from the fact that it is an object-oriented programming (OOP) language. But ask seasoned developers what OOP really is, and they&#39;ll start throwing out buzzwords and catchphrases that are sure to confuse you - terms like polymorphism, inheritance, and encapsulation. In this article I&#39;m going to explain the fundamentals of OOP and how good OOP style can help you develop better, more versatile Web applications down the road. This article will provide a basic OOP foundation that targets Web developers. In particular, we&#39;ll cover the following concepts:&lt;br /&gt;Objects&lt;br /&gt;Properties&lt;br /&gt;Methods&lt;br /&gt;Classes&lt;br /&gt;Scope&lt;br /&gt;Events&lt;br /&gt;Inheritance&lt;br /&gt; &lt;br /&gt;Objects&lt;br /&gt;In OOP, one thinks of programming problems in terms of objects, properties, and methods. The best way to get a handle on these terms is to consider a real-world object and show how it might be represented in an OOP program. Many books use the example of a car to introduce OOP. I&#39;ll try to avoid that analogy and use something friendlier: my dog, an Australian Shepherd named Rayne.&lt;br /&gt; &lt;br /&gt;Rayne is your average great, big, friendly, loving, playful mutt. You might describe him in terms of his physical properties: he&#39;s gray, white, brown, and black, stands roughly one and a half feet high, and is about three feet long. You might also describe some methods to make him do things: he sits when he hears the command &quot;Sit,&quot; lies down when he hears the command &quot;Lie down,&quot; and comes when his name is called.&lt;br /&gt; &lt;br /&gt;So, if we were to represent Rayne in an OOP program, we&#39;d probably start by creating a class called Dog. A class describes how certain types of objects look from a programming point of view. When we define a class, we must define the following two things:&lt;br /&gt;Properties. Properties hold specific information relevant to that class of object. You can think of properties as characteristics of the objects that they represent. Our Dog class might have properties such as Color, Height, and Length.&lt;br /&gt;Methods. Methods are actions that objects of the class can be told to perform. Methods are subroutines (if they don&#39;t return a value) or functions (if they do) that are specific to a given class. So the Dog class could have methods such as sit and lie_down.&lt;br /&gt; &lt;br /&gt;Once we&#39;ve defined a class, we can write code that creates objects of that class, using the class a little like a template. This means that objects of a particular class expose (or make available) the methods and properties defined by that class. So, we might create an instance of our Dog class called Rayne, set its properties accordingly, and use the methods defined by the class to interact with Rayne, as shown in Figure 1.&lt;br /&gt; &lt;br /&gt;Figure 1: The methods defined by the class interact with the object.&lt;br /&gt; &lt;br /&gt;This is just a simple example to help you visualize what OOP is all about. In the next few sections, we&#39;ll cover properties and methods in greater detail, and talk about classes and class instances, scope, events, and even inheritance.&lt;br /&gt; &lt;br /&gt;Properties&lt;br /&gt;As we&#39;ve seen, properties are characteristics shared by all objects of a particular class. In the case of our example, the following properties might be used to describe any given dog:&lt;br /&gt;Color&lt;br /&gt;Height&lt;br /&gt;Length&lt;br /&gt; &lt;br /&gt;In the same way, the more useful ASP.NET Button class exposes properties, including:&lt;br /&gt;Width&lt;br /&gt;Height&lt;br /&gt;ID&lt;br /&gt;Text&lt;br /&gt;ForeColor&lt;br /&gt;BackColor&lt;br /&gt; &lt;br /&gt;Unfortunately for me, if I get sick of Rayne&#39;s color, I can&#39;t change it. ASP.NET objects, on the other hand, let us change their properties very easily in the same way that we set variables. For instance, we&#39;ve already used properties when setting text for the Label control, which is actually an object of the Label class in the System.Web.UI.WebControls namespace:&lt;br /&gt; &lt;br /&gt;(VB.NET)&lt;br /&gt;lblMyText.Text = &quot;Hello World&quot;&lt;br /&gt; &lt;br /&gt;(C#)&lt;br /&gt;lblMyText.Text = &quot;Hello World&quot;;&lt;br /&gt; &lt;br /&gt;In this example we&#39;re using a Label control called lblMyText. Remember, ASP.NET is all about controls, and, as it&#39;s built on OOP, all control types are represented as classes. In fact, all interaction with ASP.NET pages is handled via controls. When we place a control on a page, we give it a name through its id attribute, and this ID then serves as the name of the control. Rayne is an object. His name, or ID, is Rayne. Rayne has a height of 18. The same holds true for the Label control. The Label control&#39;s name or ID in the previous example is lblMyText. Next, we use the dot operator (.) to access the Text property that the object exposes and set it to the string &quot;Hello World.&quot;&lt;br /&gt; &lt;br /&gt;Methods&lt;br /&gt;With our dog example, we can make a particular dog do things by calling commands. If I want Rayne to sit, I tell him to sit. If I want Rayne to lie down, I tell him to lie down. In object-oriented terms, I tell him what I want him to do by calling a predefined command or method, and a resulting action is performed. In VB.NET or C#, we would write this as rayne.Sit, or rayne.LieDown.&lt;br /&gt; &lt;br /&gt;As Web developers, we frequently call methods when a given event occurs. For instance, we can take information from an Access database and create an object called objConn to represent the connection to the database. We then open the connection by calling the Open method on that object as follows:&lt;br /&gt; &lt;br /&gt;(VB.NET)&lt;br /&gt;Dim objConn As New OleDbConnection( _&lt;br /&gt;  &quot;Provider=Microsoft.Jet.OLEDB.4.0;&quot; &amp;amp; _&lt;br /&gt;  &quot;Data Source=C:\Database\books.mdb&quot;)&lt;br /&gt;...&lt;br /&gt;objConn.Open()&lt;br /&gt; &lt;br /&gt;We say that the Open method is exposed by the connection object, and that we&#39;re calling the Open method on the OleDbConnection object stored in objConn. We don&#39;t need to know what dark secrets the method uses to do its magic; all we need to know is its name and its purpose.&lt;br /&gt; &lt;br /&gt;Classes&lt;br /&gt;You can think of a class as a template for building as many objects as you like of a particular type. When you create an instance of a class, you are creating an object of that class, and the new object has all the characteristics and behaviors (properties and methods) defined by the class.&lt;br /&gt; &lt;br /&gt;In our dog example, Rayne was an instance of the Dog class, as shown in Figure 2.&lt;br /&gt; &lt;br /&gt;Figure 2: A class serves as the blueprint for an object.&lt;br /&gt; &lt;br /&gt;We see that Rayne is an object of class Dog. In our code, we could create a new instance of the Dog class, call it rayne, and use all the properties and methods exposed by the object.&lt;br /&gt; &lt;br /&gt;In OOP, when we create new instances of a class, we say we&#39;re instantiating that class. For instance (no pun intended!), if we need to programmatically create a new instance of the Button control class, we could write the following code:&lt;br /&gt; &lt;br /&gt;(VB.NET)&lt;br /&gt;Dim myButton As New Button()&lt;br /&gt; &lt;br /&gt;(C#)&lt;br /&gt;Button myButton = new Button();&lt;br /&gt; &lt;br /&gt;As you can see, we&#39;ve essentially created a new object called myButton from the Button class. We can then access the properties and methods that Button exposes through our new instance:&lt;br /&gt; &lt;br /&gt;(VB.NET)&lt;br /&gt;myButton.Text = &quot;Click Me!&quot;&lt;br /&gt; &lt;br /&gt;(C#)&lt;br /&gt;myButton.Text = &quot;Click Me!&quot;;&lt;br /&gt; &lt;br /&gt;Scope&lt;br /&gt;You should now have a concept of programming objects as entities that exist in a program and are manipulated through the methods and properties they expose. However, in some cases, we want to create methods to use inside our class, which are not available when that class is used in code. Let&#39;s return to the Dog class to illustrate this concept.&lt;br /&gt; &lt;br /&gt;Imagine we&#39;re writing the Sit method inside this class, and we realize that before the dog can sit, it has to shuffle its back paws forward a little (bear with me on this one). We could create a method called ShufflePaws, then call that method from inside the Sit method. However, we don&#39;t want code in an ASP.NET page or in some other class to call this method - it&#39;d just be silly. We can prevent this by controlling the scope of that method.&lt;br /&gt; &lt;br /&gt;The two types of scope available in VB.NET and C# that you should know about are:&lt;br /&gt;Public. Defining a property or method of a class as public allows that property or method to be called from outside the class itself. In other words, if an instance of this class is created inside another object (remember, too, that ASP.NET pages themselves are objects), public methods and properties are freely available to the code that created it. This is the default scope in VB.NET and C# classes.&lt;br /&gt;Private. If a property or method of a class is private, it cannot be used from outside the class itself. If an instance of this class is created inside an object of a different class, the creating object has no access to private methods or properties of the created object.&lt;br /&gt; &lt;br /&gt;Events&lt;br /&gt;Events occur when a control object sends a message in response to some change that has happened to it. Generally, these changes occur as the result of user interaction with the control in the browser. For instance, when a button is clicked, a Click event is raised, and we can handle that event to perform some action. The object that triggers the event is referred to as the event sender; the object that receives the event is referred to as the event receiver.&lt;br /&gt; &lt;br /&gt;Understanding Inheritance&lt;br /&gt;Inheritance refers to the ability of one class to use properties and methods exposed by another class. In our dog example, we first created a class named Dog, then created instances of that class to represent individual dogs. However, dogs are types of animals, and many characteristics of dogs are shared by all (or most) animals. For instance, Rayne has four legs, two ears, one nose, two eyes, etc. It might be better, then, for us to create a base class named Animal. When we then define the Dog class, it would inherit from the Animal class, and all public properties and methods of Animal would be available to instances of the Dog class.&lt;br /&gt; &lt;br /&gt;Similarly, we could create a new class based on the Dog class. In programming circles, this is called deriving a subclass from Dog. For instance, we might create a class for Australian Shepherd and one for my other dog Amigo, named Chihuahua, both of which would inherit the properties and methods of the Dog base class, and define new ones specific to each breed.&lt;br /&gt; &lt;br /&gt;Don&#39;t worry too much if this is still a little unclear. The best way to appreciate inheritance is to see it used in a real program. The most obvious use of inheritance in ASP.NET comes with the technique of code-behind.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;FeedBurner&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dflorence25.blogspot.com/feeds/2194451243549520938/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1084787999077704213/2194451243549520938' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/2194451243549520938'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/2194451243549520938'/><link rel='alternate' type='text/html' href='http://dflorence25.blogspot.com/2008/07/vb.html' title=''/><author><name>Flor</name><uri>http://www.blogger.com/profile/04517282987785226840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZYDSF-y7Vt7gRkup1yqg7Bn4ZODIz5NU2tDOUW10ZJaIM1D6fsTwAnmqU8WoJ88bq-dw_3l8jGR540YHTwHjr6NuJv-MBT47BwaJPkF2d2BNnV22Q5ddqbc9W3ut75w/s220/Flor.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1084787999077704213.post-2539698286888389025</id><published>2008-02-06T21:02:00.000-08:00</published><updated>2008-02-06T21:09:31.480-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Using HttpHandlers and HttpModules in your ASP.NET Websites"/><title type='text'>Using HttpHandlers and HttpModules in your ASP.NET Websites</title><content type='html'>&lt;strong&gt; Using HttpHandlers and HttpModules in your ASP.NET Websites&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br /&gt;In this article I would explain about HttpModules and HttpHandlers and how to use it on your Website.Sometimes, just creating dynamic Web pages with the latest languages and databases just does not give you , the developer enough control over an application. At times, you need to be able to dig deeper and create applications that can interact with the Web Server itself. You want to be able to interact with the low level processes such as how the Web Server processes incoming and outgoing HTTP requests.Before ASP.NET, in order to get this level of control using IIS, you were forced to create ISAPI extensions or filters. This proved to be quite daunting and painful task for many developers because creating ISAPI extensions and filters required knowledge of C/C++ and knowledge of how to create native Win32 DLLs. Thankfully, in .NET world, creating these types of low level applications is really no more difficult than most other tasks you would normally perform.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;HttpModules&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;HttpModules are simple classes that can plug themselves into the request processing pipeline. They do this by hooking into a handful events thrown by the application as it processses the HTTP request. To create an HttpModule, you simply create a class that derives from the System.Web.IHttpModule interface. This interface requires you to implement two methods: Init and Dispose. The code snippet below will show you how to implement the methods.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Code in VB.NET&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;Imports Microsoft.VisualBasic&lt;br /&gt;Imports System.Web&lt;br /&gt;Public Class SimpleHttpModule Implements IHttpModule&lt;br /&gt;Public Overridable Sub Init(ByVal context as HttpApplication) _&lt;br /&gt;Implements IHttpModule.Init&lt;br /&gt;End Sub&lt;br /&gt;Public Overridable Sub Dispose() Implements IHttpModule.Dispose&lt;br /&gt;End Sub&lt;br /&gt;End Class&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Code in C# &lt;/strong&gt;&lt;br /&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;using System;&lt;br /&gt;using System.Web;&lt;br /&gt;&lt;br /&gt;public class SimpleHttpModule :IHttpModule {&lt;br /&gt;public void Dispose() {&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void Init(HttpApplication context) {&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;The Init Method is the primary method that you use to implement the functionality. Notice that it has single method parameter named HttpApplication object named context. The parameter gives you access to the current HttpApplication context and it is what you use to wire up the different events that fired during the request processing.&lt;br /&gt;Below is the list of the important EventName that you can use with the HttpApplication object.&lt;br /&gt;&lt;strong&gt;1.  AcquireRequestState.     &lt;/strong&gt;&lt;br /&gt;          Raised when ASP.NET runtime is ready to acquire the SessionState of the current Http request&lt;br /&gt;&lt;strong&gt;2.  AuthenticateRequest.   &lt;/strong&gt;&lt;br /&gt;          Raised when ASP.NET runtime is ready to authenticate the identity of the user.&lt;br /&gt;&lt;strong&gt;3.  AuthorizeRequest  &lt;/strong&gt;&lt;br /&gt;          Raised when ASP.NET runtime is ready to authorize the user for the resources user is trying to         access.&lt;br /&gt;&lt;strong&gt;4.  BeginRequest   &lt;/strong&gt;&lt;br /&gt;          Raised when ASP.NET runtime receivess a new HTTP request.&lt;br /&gt;&lt;strong&gt;5.  End Request   &lt;/strong&gt;&lt;br /&gt;          Raised just before sending the response content to the client&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Simple Example using HTTPModule&lt;br /&gt;&lt;/strong&gt;The example below will showsyou how to modified the HTTP output stream before it get sent to the client. This can be a simple and useful tool if you want to add text to each page served from  your Website but do not want to modify each page.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Code in VB.NET &lt;/strong&gt;&lt;br /&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;Public Class SimpleHTTPModule Implements IHttpModule&lt;br /&gt;Dim WithEvents oApps as HttpApplication = Nothing&lt;br /&gt;Public Overridable Sub Init(ByVal context as HttpApplication) _&lt;br /&gt;Implements IHttpModule.Init&lt;br /&gt;oApps = context&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Public Overridable Sub Dispose() Implements IHttpModule.Dispose&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Public Sub_context_PreSendRequestContent(ByVal sender As Object,_&lt;br /&gt;ByVal e as EventArgs) Handles oApps.PreSendRequestContent&lt;br /&gt;Dim message as String = &quot;&lt;!-- This page is being processed at &quot; &amp;amp; _&lt;br /&gt;System.DateTime.Now.ToString() &amp;amp; &quot; --&gt;&quot;&lt;br /&gt;&lt;br /&gt;oApps.Context.Response.Output.Write(message);&lt;br /&gt;End Sub&lt;br /&gt;End Class&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Code in C# &lt;/strong&gt;&lt;br /&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;public class SimpleHTTPModule : IHttpModule&lt;br /&gt;{&lt;br /&gt;private HttpApplication oApps = null;&lt;br /&gt;public void Dispose() {&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void Init(System.Web.HttpApplication context) {&lt;br /&gt;oApps = context;&lt;br /&gt;context.PreSendRequestContent += new EventHandler&lt;br /&gt;(context_PreSendRequestContent);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void context_PreSendRequestContent(object sender,EventArgs e) {&lt;br /&gt;string message = &quot;&amp;lt;!-- This page is being processed at &quot; +&lt;br /&gt;System.DateTime.Now.ToString() + &quot; --&gt;&quot;&lt;br /&gt;&lt;br /&gt;oApps.Context.Response.Output.Write(message);&lt;br /&gt;}&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You can see from the code snippet above, we are using PreSendRequestContent event. This event fires right before the content is sent to the client and you have the last opportunity to modify it.In the PreSendRequestContent handler method, you simply create a string containing an HTML comment that contains the current time. You take this string and write it to the current HTTP requests output stream. The Http request is then sent back to the client.In order to use this module, you must let ASP.NET know that you want to include this module in the request pipeline. You can add the httpmodule section by modifying your web.config file. &lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;system.web&gt;&lt;br /&gt;&lt;httpmodules&gt;&lt;br /&gt;&lt;add name=&quot;SimpleHTTPModule&quot; type=&quot;SimpleHTTPModule,App_code&quot;&gt;&lt;br /&gt;&lt;/httpmodules&gt;&lt;br /&gt;&lt;/system.web&gt;&lt;br /&gt;&lt;/span&gt;The generic format of the httpModules in your web.config file is &lt;system.web&gt;&lt;br /&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;httpmodules&gt;&lt;br /&gt;&lt;add name=&quot;modulename&quot; type=&quot;namespace.classname,assemblyname&quot;&gt;&lt;br /&gt;&lt;/httpmodules&gt;&lt;br /&gt;&lt;/system.web&gt;&lt;/span&gt;&lt;br /&gt;If you have created your HttpModule in  the App_code directory of an ASP.NET project, you might wonder how you know the assemblyname value should be,considering ASP.NET 2.0 now dynamically compiles your code at runtime. The solution is to use the text App_code as the assembly name. This tells ASP.NET that your module is located in the dynamically located assembly.You can also create HttpModules as a separate class library project in which case you simply use the assembly name of the library.After you have added this section on your web.config file, try to run any file of your web project and view source the generated aspx file. You should be able to see the commented date time as we previously coded in the http modules.&lt;br /&gt;HttpHandlers&lt;br /&gt;HttpHandlers differ from HttpModules not only because of their positions in  the request processing pipeline, but also because they must be mapped to a specific file extensions. HttpHandlers are the last stop for the incoming Http requests and are ultimately the point in the request processing pipeline that is responsible for serving up the requested content, be it in ASPX page,HTML,plain text or an image. Additionally HttpHandlers can offer significant performance gains.In this arcticle, I will demonstrate two different ways to create a simple HttpHanlder that you can use to serve up dynamic images. First you look at creating an HttpHanlder using an ASHX file extension. Then you learn how you get even more control by mapping your HttpHandler to a custom file extension using IIS.Generic HandlersIn Visual Studio 2005, Microsoft has introduced new template specifically for HttpHandler and it ends with .ashx extension. The .ashx extension is the default HttpHander file extension set up by ASP.NET.Remember that HttpHandlers must be mapped to a unique file extensions. But luckily in asp.net 2.0, they have .ashx file extension that specifically created for HttpHandler purpose. This will save you heaps of time configuring and adding new file extension on your web.project&lt;br /&gt;&lt;strong&gt;Outputting an image from HttpHandler&lt;/strong&gt;&lt;br /&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;@ WebHandler Language=&quot;VB&quot; Class=&quot;Handler&quot;/&gt;&lt;br /&gt;Imports System.Web&lt;br /&gt;Public Class Handler:Implements IHttpHandler&lt;br /&gt;Public Sub ProcessRequest(ByVal context as HttpContext) _&lt;br /&gt;Implements IHttpHandler.ProcessRequest&lt;br /&gt;context.Response.ContentType = &quot;image/jpeg&quot;&lt;br /&gt;context.Response.WriteFile(&quot;Sunset.jpg&quot;)&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Public ReadOnly Property IsReusable() As Boolean _&lt;br /&gt;Implements IHttpHandler.IsReusable&lt;br /&gt;Get&lt;br /&gt;Return False&lt;br /&gt;End Get&lt;br /&gt;End Property&lt;br /&gt;End Class&lt;br /&gt;&lt;@ WebHandler Language=&quot;C#&quot; Class=&quot;Handler&quot;/&gt;&lt;br /&gt;using System.Web&lt;br /&gt;public class Handler:IHttpHandler {&lt;br /&gt;public void ProcessRequest(HttpContext context) {&lt;br /&gt;context.Response.ContentType = &quot;image/jpeg&quot;;&lt;br /&gt;context.Response.WriteFile(&quot;Sunset.jpg&quot;);&lt;br /&gt;}&lt;br /&gt;public bool IsReusable {&lt;br /&gt;get{&lt;br /&gt;return false;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;As you can see, simply change the ContentType method to image/jpeg to indicate that you are returning JPEG image, then you use the WriteFile() method to write an image file to the output stream. To use the handler, you can directly called the .ashx file from your html code&lt;img src=&quot;ImageHandler.ashx&quot; /&gt;The above example, shows very basic things you can do with HttpHandler.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Conclusion &lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;The article above is basically an introduction to the HttpHandler and HttpModules. Lots of ASP.NET developers until now never use and never heard about HttpHandlers and HttpModules. The reason is because they keep applying  the old way and old technology from Classic ASP 3.0. You can do the similar thing without the need of using HttpHandler and HttpModules. However using HttpHandler and HttpModules allow your website to be more manageable, extensible and less code written in your presentation layer. You encapsulate all the logic inside the HttpHandler and HttpModules. Thats all for now. Happy  programming !&lt;div class=&quot;blogger-post-footer&quot;&gt;FeedBurner&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dflorence25.blogspot.com/feeds/2539698286888389025/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1084787999077704213/2539698286888389025' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/2539698286888389025'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/2539698286888389025'/><link rel='alternate' type='text/html' href='http://dflorence25.blogspot.com/2008/02/using-httphandlers-and-httpmodules-in.html' title='Using HttpHandlers and HttpModules in your ASP.NET Websites'/><author><name>Flor</name><uri>http://www.blogger.com/profile/04517282987785226840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZYDSF-y7Vt7gRkup1yqg7Bn4ZODIz5NU2tDOUW10ZJaIM1D6fsTwAnmqU8WoJ88bq-dw_3l8jGR540YHTwHjr6NuJv-MBT47BwaJPkF2d2BNnV22Q5ddqbc9W3ut75w/s220/Flor.jpg'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1084787999077704213.post-6297907085315835258</id><published>2008-02-06T20:27:00.000-08:00</published><updated>2008-02-06T20:33:29.679-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Improve your ASP.NET Site performance with Caching"/><title type='text'>Improve your ASP.NET Site performance with Caching</title><content type='html'>&lt;strong&gt;Improve your ASP.NET Site performance with Caching&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;In this article, I would like to share my experience and knowledge about ASP.NET Caching and how it can improve your website performance. As you all might know that performance is key requirement for any application or piece of code that you develop. For mission critical website, Caching is the way to go to significantly enhance your web response times. Caching is the process of storing frequently used data on the server to fulfill subsequent requests.You will discover that grabbing data or objects from memory is much faster than recreating the web pages or items contained in them from scratch.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;When and Why use Caching&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;A Proper use and fine tune of caching approach of caching will result on better performance and scalability of your site. However improper use of caching will actually slow down and consume lots of your server performance and memory usage.&lt;br /&gt;&lt;br /&gt;Good candidate to use caching is if you have infrequent chance of data or static content of web page.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;For example&lt;/strong&gt;, Stock market website displaying 20 minutes delay data can actually use data caching to store the data, so that it can reduce database call every time the user refresh the page.&lt;br /&gt;&lt;br /&gt;Another good example would be using Partial page caching to store some of the infrequent or static content. If you have websites that show lots of information or features, you can actually group the static or infrequent change content into user controls and then set the Caching for that particular user controls. You can set the amount of time when the caching expires so that it will load new data from database.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Type of Caching&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#3333ff;&quot;&gt;1. Output Caching (Page Caching)&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;The most easiest and simple caching that you can implement. Good for caching the static page that is accessed frequently. You can copy and paste the code below on your ASP.NET page.&lt;br /&gt;&lt;br /&gt;Duration attribute specifies how long in seconds that the page will be held in the memory. When the cache expired, the asp.net engine will automatically reload and refreshes the page again. If the page never change, you can actually set the duration to very long period.&lt;br /&gt;&lt;br /&gt;Valid Parameters for OutputCaching&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;1. VaryByParam&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;The VaryByParam attribute is for caching different type of page based on the HTTP Post or HTTP Get Protocol&lt;br /&gt;e.g You can cache dynamic content based on different query string provided.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In this case, asp.net engine will cache the dynamic page based on the different query string provided. If your page is generating different content based on the query string, then you need to put that in the output cache directive or else all your users will see the same content.&lt;br /&gt;&lt;br /&gt;If you want to cache a new version of the page based on any differences in the Query String parameters, use VaryByParam = &quot;*&quot; as in the following code.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.VaryByControl&lt;/strong&gt;&lt;br /&gt;VaryByControl can be used to cache the usercontrol inside your page. For example you can cache a user control that contains ComboBox that render all the country name in the world. And perhaps those country data is retrieved from database, this will make significant performance for page loading time.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;3.VaryByCustom&lt;br /&gt;&lt;/strong&gt;To make the Cache object even more flexible, Microsoft built in the ability to cache the page based on a string, which is then controlled from the actual code of the application&lt;br /&gt;&lt;br /&gt;It does have one &quot;out of the box&quot; property, Browser. When VaryByCustom is set to Browser the page is cached every time a different browser agent and major version number requests the page.&lt;br /&gt;&lt;br /&gt;If you like to have your own set of Caching rule ,then you might need to tweak some of the code in global .aspx&lt;br /&gt;For e.g You might need to differentiate caching content for different set of users based on cookies called Language. Then you need to copy and paste the following code in your global.asax file.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Code in VB.NET&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;Overrides Function GetVaryByCustomString(ByVal context as HttpContext,_&lt;br /&gt;ByVal arg as String) As String&lt;br /&gt;If arg.ToLower() = &quot;cookies&quot; Then&lt;br /&gt;Dim cookie as HttpCookie = context.Request.Cookies(&quot;Language&quot;)&lt;br /&gt;If cookie isNot nothing Then&lt;br /&gt;Return cookie.Value&lt;br /&gt;End if&lt;br /&gt;End If&lt;br /&gt;Return MyBase.GetVaryByCustomString(context,arg)&lt;br /&gt;End Function&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Code in C#&lt;/strong&gt;&lt;br /&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;public override string GetVaryByCustomString(HttpContext context, string arg)&lt;br /&gt;{&lt;br /&gt;if (arg.ToLower() == &quot;cookies&quot;)&lt;br /&gt;{&lt;br /&gt;HttpCookie cookie = context.Request.Cookies[&quot;Language&quot;];&lt;br /&gt;if (cookie != null)&lt;br /&gt;{&lt;br /&gt;return cookie.Value;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;return base.GetVaryByCustomString(context, arg);&lt;br /&gt;} &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;After that , set the VaryByCustom attribute to &quot;cookies&quot; in your OutputCache directives.&lt;br /&gt;By doing that you will generate different set of caching based on the Client languages cookies. This is just one of the example of doing VaryByCustom caching, you can actually create your own set of caching rules by differentiating caching based on user logged on, and etc.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;4.VaryByHeader&lt;br /&gt;&lt;/strong&gt;Varies cache entries based on variations in a specified header&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2. Partial Page (UserControl) Caching.&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;Similar to output Caching, partial page caching allows you to cache certain blocks of your website.You can for example only cache the center of the page. Partial page is achieved with the caching of the user controls. You can build your ASP.NET pages consisting of numerous user controls and then apply output caching on the user controls you select. This will caches only parts of the page that you want and leaving other parts of page outside the reach of caching.&lt;br /&gt;This is very nice feature and if it done correctly, it can lead to pages that perform better.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Note :&lt;/strong&gt;&lt;br /&gt;Typically UserControls are placed on multiple pages to maximize reuse. However, when these UserControls (ASCX Files) are cached with the @OutputCache Directive , they are cached on per page basis.That means even if a User Control outputs the identical HTML when placed on pageA.aspx as it does placed on pageB.aspx,its output is cached twice.&lt;br /&gt;You can prevent this to happen by adding Shared = true in the output cache directive.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;By putting Shared attributed, the memory savings can be surprisingly large.&lt;br /&gt;If you have an ASCX User control using the OutputCache directive,remember that User Control exists only for the first request.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;3. Data Caching&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Output Caching and Partial Page caching is useful if you want to cache the output of the page. However if you like to cache DataSet object or any Collections object, you can use Data Caching to implement that.&lt;br /&gt;&lt;br /&gt;ASP.NET has one class called Cache Object to start caching specific data items for later use on particular page or group of pages. The cache object enables you to store everything from simple name/value pairs to more complex objects like datasets and entire .aspx pages.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;VB.NET&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;Cache(&quot;MyDataSet&quot;) = myDataSet;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;Cache(&quot;MyDataSet&quot;) = myDataSet;To retrieve the data from the cache, you can use the code below.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;VB.NET&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;Dim ds as New DataSet&lt;br /&gt;ds = CType(Cache(&quot;MyDataSet&quot;),DataSet)&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;br /&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;DataSet ds = new DataSet();&lt;br /&gt;ds = (DataSet) Cache[&quot;MyDataSet&quot;];&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br /&gt;As we&#39;ve just seen, caching Web pages with ASP.NET is amazingly easy, accomplished with a simple line. With this glimpse of ASP.NET&#39;s caching abilities, you can improve your Web application&#39;s performance. But remember Caching in ASP.net is a trade off between CPU and memory. How hard is it to make this page versus whether you can afford to hold 200 versions of it. If it&#39;s only 5KB of HTML, a potential megabyte of memory could pay off handsomely versus thousands and thousands of database access. Every page of request served from the cache saves you a trip to the database.&lt;div class=&quot;blogger-post-footer&quot;&gt;FeedBurner&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dflorence25.blogspot.com/feeds/6297907085315835258/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1084787999077704213/6297907085315835258' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/6297907085315835258'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/6297907085315835258'/><link rel='alternate' type='text/html' href='http://dflorence25.blogspot.com/2008/02/improve-your-aspnet-site-performance.html' title='Improve your ASP.NET Site performance with Caching'/><author><name>Flor</name><uri>http://www.blogger.com/profile/04517282987785226840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZYDSF-y7Vt7gRkup1yqg7Bn4ZODIz5NU2tDOUW10ZJaIM1D6fsTwAnmqU8WoJ88bq-dw_3l8jGR540YHTwHjr6NuJv-MBT47BwaJPkF2d2BNnV22Q5ddqbc9W3ut75w/s220/Flor.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1084787999077704213.post-1035462278317364713</id><published>2008-02-05T23:26:00.000-08:00</published><updated>2008-02-05T23:37:37.819-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Master Pages in ASP.Net 2.0"/><title type='text'>Master Pages in ASP.Net 2.0</title><content type='html'>&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;One of the new features of ASP.Net 2.0 is Master Pages. Master Pages enables us to apply the same page layout to multiple pages in a Web Application. A page that uses a master page is known as the content page.&lt;br /&gt;&lt;br /&gt;Using Master Pages we can create a consistent look and feel for our websites. Pages in a web application have the standard elements such as logos, menus, copyright notices, etc. that are repeated on each and every page. And usually a web-site has a single layout design that each page corresponds to. Using master pages, we can place all these elements and define the layout and design in a master page. And when we base a content page on this master page, then all of the content pages will automatically include all of the standard elements and will define whatever layout you defined in the master page.&lt;br /&gt;&lt;br /&gt;In this article, I&#39;ll spin through a small sample application to help you in understanding the advantages of master pages and how can work with them. I&#39;ll also explore some of the advanced features of Master Pages, such as modifying header element from the content page, so that if each content page needs to display a different Title Header, you can easily have it done. I will also take a look at loading the master page at run-time, and use of Nested Master pages.&lt;br /&gt;Prerequisites&lt;br /&gt;&lt;br /&gt;This tutorial assumes that you own a copy of Visual Studio 2005 or Visual Web Developer Express. It also assumes that you are familiar with ASP.Net 2.0 basics.&lt;br /&gt;Creating the Website&lt;br /&gt;&lt;br /&gt;If you have an existing web site, you can skip this section. Otherwise, you can create a new web site and page by following these steps.&lt;br /&gt;&lt;br /&gt;To create a file system Web site:&lt;br /&gt;- Open Visual Studio 2005.&lt;br /&gt;- On the File menu, open New and click on Web Site.&lt;br /&gt;&lt;br /&gt;The New Web Site dialog box appears.&lt;br /&gt;- Under Visual Studio installed templates, click ASP.NET Web Site.&lt;br /&gt;- In the Location box, enter the name of the folder where you want to keep the pages of your Web site.&lt;br /&gt;&lt;br /&gt;For example, type the folder name C:\WebSites\mySite.&lt;br /&gt;- In the Language list, click Visual Basic (or the language you prefer to work with).&lt;br /&gt;- Click OK.&lt;br /&gt;&lt;br /&gt;Visual Web Developer creates the folder and a new page named Default.aspx.&lt;br /&gt;Creating a Simple Master Page&lt;br /&gt;Right-click in the solution explorer and select Add New Item. Select Master Page from the template and provide a name for the page. In this example I am using myMaster.master (where .master is the extension of the file). Click Add.&lt;br /&gt;This will add the .master file to the project. Which is our master page.&lt;br /&gt;&lt;br /&gt;A Master Page can contain the same Web controls, User controls, HTML content, and scripts that can be added to a standard ASP.NET page. There are three important differences between a Master Page and a normal ASP.NET page.&lt;br /&gt;&lt;br /&gt;First, unlike a normal ASP.NET page, the name of a Master Page must end with the special extension .master. This extension marks the page as a Master Page. Furthermore, an ASP.NET application is configured so that you cannot request pages with the .master extension.&lt;br /&gt;Second, a Master Page includes a &lt;%@ Master %&gt; directive instead of the normal &lt;%@ Page %&gt; directive. The &lt;%@ Master %&gt; directive supports many of the same attributes as the &lt;%@ Page %&gt; directive. For example, you can specify the programming language of the page with the directive &lt;%@ Master Language=&quot;vb&quot; %&gt;.&lt;br /&gt;&lt;br /&gt;The final difference between a Master Page and a normal ASP.NET page is that a Master Page can contain zero or more ContentPlaceHolder controls. A ContentPlaceHolder control can be used only within a Master Page. This control marks an area of a Master Page that can be overridden by a particular content page.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;The HTML code for this is:&lt;/strong&gt;&lt;br /&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;&lt;bdody&gt;&gt;&lt;br /&gt;    &lt;form id=&quot;form1&quot; runat=&quot;server&quot;&gt;&lt;br /&gt;    &lt;div&gt;&lt;br /&gt;        &lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;width: 100%; height: 100%&quot;&gt;&lt;br /&gt;            &lt;tr&gt;&lt;br /&gt;                &lt;td colspan=&quot;2&quot; style=&quot;height: 50px; background-color: royalblue&quot; align=&quot;left&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;                    &lt;asp:Label ID=&quot;Label1&quot; runat=&quot;server&quot; Font-Names=&quot;Verdana&quot; Font-Size=&quot;X-Large&quot; Font-Underline=&quot;True&quot;&lt;br /&gt;                        ForeColor=&quot;WhiteSmoke&quot; Text=&quot;Welcome to the Master/Content Tutorial&quot;&gt;&lt;/asp:Label&gt;&lt;br /&gt;&lt;br /&gt;                    &lt;asp:Label ID=&quot;Label2&quot; runat=&quot;server&quot; Font-Names=&quot;Verdana&quot; ForeColor=&quot;WhiteSmoke&quot;&lt;br /&gt;                        Text=&quot;Writer: M.Salman Khalid.&quot;&gt;&lt;/asp:Label&gt;&lt;/td&gt;&lt;br /&gt;            &lt;/tr&gt;&lt;br /&gt;            &lt;tr&gt;&lt;br /&gt;                &lt;td style=&quot;width: 75px; background-color: royalblue&quot;&gt;&lt;br /&gt;                &lt;/td&gt;&lt;br /&gt;                &lt;td&gt;&lt;br /&gt;                    &lt;asp:contentplaceholder id=&quot;ContentPlaceHolder1&quot; runat=&quot;server&quot;&gt;&lt;br /&gt;                    &lt;/asp:contentplaceholder&gt;&lt;br /&gt;                &lt;/td&gt;&lt;br /&gt;            &lt;/tr&gt;&lt;br /&gt;            &lt;tr&gt;&lt;br /&gt;                &lt;td colspan=&quot;2&quot; style=&quot;height: 50px; background-color: royalblue&quot; align=&quot;center&quot;&gt;&lt;br /&gt;                     &lt;asp:linkbutton id=&quot;LinkButton2&quot; runat=&quot;server&quot; forecolor=&quot;WhiteSmoke&quot;&gt;Microsoft&lt;/asp:LinkButton&gt;&lt;br /&gt;                    &lt;asp:label id=&quot;Label3&quot; runat=&quot;server&quot; forecolor=&quot;WhiteSmoke&quot; text=&quot;*&quot; width=&quot;3px&quot;&gt;&lt;/asp:Label&gt;&lt;br /&gt;                    &lt;asp:linkbutton id=&quot;LinkButton3&quot; runat=&quot;server&quot; forecolor=&quot;WhiteSmoke&quot;&gt;MSDN&lt;/asp:LinkButton&gt;&lt;br /&gt;                    &lt;asp:label id=&quot;Label4&quot; runat=&quot;server&quot; forecolor=&quot;WhiteSmoke&quot; text=&quot;*&quot; width=&quot;3px&quot;&gt;&lt;/asp:Label&gt;&lt;br /&gt;                    &lt;asp:linkbutton id=&quot;LinkButton4&quot; runat=&quot;server&quot; forecolor=&quot;WhiteSmoke&quot;&gt;Channel 9&lt;/asp:LinkButton&gt;&lt;br /&gt;                    &lt;asp:label id=&quot;Label5&quot; runat=&quot;server&quot; forecolor=&quot;WhiteSmoke&quot; text=&quot;*&quot; width=&quot;3px&quot;&gt;&lt;/asp:Label&gt;&lt;br /&gt;                    &lt;asp:linkbutton id=&quot;LinkButton1&quot; runat=&quot;server&quot; forecolor=&quot;WhiteSmoke&quot;&gt;Code Project&lt;/asp:LinkButton&gt;&lt;/td&gt;&lt;br /&gt;            &lt;/tr&gt;&lt;br /&gt;        &lt;/table&gt;&lt;br /&gt;        &lt;br /&gt;    &lt;/div&gt;&lt;br /&gt;    &lt;/form&gt;&lt;br /&gt;&lt;/.body&gt;&lt;/span&gt;&lt;br /&gt;In the above HTML code, the ContentPlaceHolder control is what identifies the area where the content place data will come. With Master/Content pages, you can have multiple ContentPlaceHolder controls in the Master Page.&lt;br /&gt;Creating a Content Page&lt;br /&gt;Right-click the project in the solution explorer and select Add New Item. Select Web Page from the template and check Select Master Page. Click on Add. This will open the Select Master Page dialog box, listing all the master pages defined in the project. Select the master page myMaster.master and click OK.&lt;br /&gt;The HTML code for the new content page is:&lt;br /&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;%@ Page Language=&quot;VB&quot; MasterPageFile=&quot;~/myMaster.master&quot; AutoEventWireup=&quot;false&quot; CodeFile=&quot;Default.aspx.vb&quot; Inherits=&quot;_Default&quot; title=&quot;Untitled Page&quot; %&gt;&lt;br /&gt;&lt;asp:content id=&quot;Content1&quot; contentplaceholderid=&quot;ContentPlaceHolder1&quot; runat=&quot;Server&quot;&gt;&lt;br /&gt;&lt;/asp:Content&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;/span&gt;&lt;br /&gt;We&#39;ve looked at how one can create a single Master Page and base a content page on the Master Page.&lt;br /&gt;Furthermore, if you have the need, you can even nest multiple Master Pages. For example, you can create one Master Page for the entire Web site and then nest Master Pages below the site Master Page for individual sections.&lt;br /&gt;Visual Studio/Visual Web Developer does not provide designer support for doing this. So, if you want to nest Master Pages, you&#39;ll need to stick to either source code view or build your pages using Notepad.&lt;br /&gt;For example, following could be used for a Site Master Page. This Master Page contains the opening and closing HTML and Form tags and a single ContentPlaceHolder control.&lt;br /&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;%@ Master %&gt;&lt;br /&gt;&lt;.html&gt;&lt;br /&gt;&lt;.head&gt;&lt;br /&gt;    &lt;.title&gt;Site Master&lt;/.title&gt;&lt;br /&gt;&lt;./head&gt;&lt;br /&gt;&lt;.body bgcolor=&quot;LightGreen&quot;&gt;&lt;br /&gt;    &lt;form id=&quot;form1&quot; runat=&quot;server&quot;&gt;&lt;br /&gt;        &lt;h1&gt;Site Master Page&lt;/h1&gt;&lt;br /&gt;        &lt;asp:contentplaceholder&lt;br /&gt;            id=&quot;SiteContentPlaceHolder&quot;&lt;br /&gt;            runat=&quot;server&quot; /&gt;&lt;br /&gt;    &lt;/form&gt;&lt;br /&gt;&lt;/.body&gt;&lt;br /&gt;&lt;/.html&gt;&lt;/span&gt;&lt;br /&gt;And the following could be the nested master page. This Master Page overrides the content in the Site Master Page. Notice that the &lt;%@ Master %&gt; directive refers to the SiteMaster.master Master Page.&lt;br /&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;%@ Master  MasterPageFile=&quot;~/SiteMaster.master&quot; %&gt;&lt;br /&gt;&lt;asp:content ID=&quot;Content1&quot;&lt;br /&gt;    ContentPlaceHolderID=&quot;SiteContentPlaceHolder&quot;&lt;br /&gt;    runat=&quot;server&quot;&gt;&lt;br /&gt;    &lt;table width=&quot;100%&quot; bgcolor=&quot;LightYellow&quot;&gt;&lt;br /&gt;    &lt;tr&gt;&lt;br /&gt;        &lt;td colspan=&quot;2&quot;&gt;&lt;br /&gt;        &lt;h1&gt;Section Master Page&lt;/h1&gt;&lt;br /&gt;        &lt;/td&gt;&lt;br /&gt;    &lt;/tr&gt;&lt;br /&gt;    &lt;tr&gt;&lt;br /&gt;        &lt;td&gt;&lt;br /&gt;        &lt;asp:ContentPlaceHolder  &lt;br /&gt;            id=&quot;LeftColumn&quot;&lt;br /&gt;            Runat=&quot;Server&quot; /&gt;            &lt;br /&gt;        &lt;/td&gt;&lt;br /&gt;        &lt;td&gt;&lt;br /&gt;        &lt;asp:ContentPlaceHolder  &lt;br /&gt;            id=&quot;RightColumn&quot;&lt;br /&gt;            Runat=&quot;Server&quot; /&gt;    &lt;br /&gt;        &lt;/td&gt;&lt;br /&gt;    &lt;/tr&gt;&lt;br /&gt;    &lt;/table&gt;&lt;br /&gt;&lt;/asp:content&gt;&lt;/span&gt;&lt;br /&gt;Finally, the content is based on the Section Master Page. Notice that this page overrides the two ContentPlaceHolder controls contained in the Section Master Page.&lt;br /&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;%@ Page MasterPageFile=&quot;~/SectionMaster.master&quot; %&gt;&lt;br /&gt;&lt;asp:Content ID=&quot;Content1&quot;   &lt;br /&gt;    ContentPlaceHolderId=&quot;LeftColumn&quot;&lt;br /&gt;    Runat=&quot;Server&quot;&gt;&lt;br /&gt;    This content appears in the left column&lt;br /&gt;&lt;/asp:Content&gt;&lt;br /&gt;&lt;asp:Content ID=&quot;Content2&quot;  &lt;br /&gt;    ContentPlaceHolderId=&quot;RightColumn&quot;&lt;br /&gt;    Runat=&quot;Server&quot;&gt;&lt;br /&gt;    This content appears in the right column&lt;br /&gt;&lt;/asp:Content&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;/span&gt;&lt;br /&gt;Configuring Master Pages&lt;br /&gt;There is an alternative to associating a content page with a Master Page by using the &lt;%@ Page %&gt; directive. One can associate a Master Page with a content page within the Web application&#39;s configuration file. Using the configuration file makes it easier to maintain large Web sites, since they can change the Master Page associated with many content pages in a single location.&lt;br /&gt;You set the Master Page within the &lt;pages&gt; element of a configuration file. (This element appears in the &lt;system.web&gt; section of a configuration file.) For example, the following &lt;pages&gt; element sets the default Master Page to &quot;myMaster.master&quot;:&lt;br /&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;pages masterpagefile=&quot;myMaster.master&quot;&gt;&lt;/span&gt;&lt;br /&gt;Two major points to be aware of... The first is that if you want to use the Web.Config file to set the Master Pages, then you should not include the MasterPageFile attribute in the content pages. This is because setting a Master Page within a content page takes precedence over any Master Page set in the configuration file.&lt;br /&gt;Second, the application can contain more than one Web.Config file located in different subfolders that set different Master Pages. In other words, one can override the Master Page set in a Web.Config file within a subfolder by creating a new Web.Config file. This is a really useful and important technique.&lt;br /&gt;Overriding Master Page Properties&lt;br /&gt;One issue that can be encountered almost immediately when working with Master Pages is the issue of how to override such properties as the page title and meta tags of a Master Page in individual content pages. It is common to want to display unique titles for each content page, even when the individual content pages are based on a shared Master Page.&lt;br /&gt;There are multiple ways of overriding the content contained in a Master Page within a particular content page. I&#39;ll explore the most common two methods...&lt;br /&gt;If you simply want to change the page title rendered by a Master Page from within a content page, then you can take advantage of the &lt;%@ Page %&gt; directive&#39;s Title attribute. This attribute only takes effect when the Master Page uses a server-side HtmlHead control.&lt;br /&gt;For example, the Master Page Code below contains a server-side HtmlHead control.&lt;br /&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;%@ Master %&gt;&lt;br /&gt;&lt;.html&gt;&lt;br /&gt;&lt;.head id=&quot;Head1&quot; runat=&quot;server&quot;&gt;&lt;br /&gt;    &lt;.title&gt;Master Title&lt;/.title&gt;&lt;br /&gt;&lt;/.head&gt;&lt;br /&gt;&lt;.body&gt;&lt;br /&gt;    &lt;form id=&quot;form1&quot; runat=&quot;server&quot;&gt;&lt;br /&gt;    &lt;asp:contentplaceholder&lt;br /&gt;        id=&quot;ContentPlaceHolder1&quot;&lt;br /&gt;        runat=&quot;server&quot; /&gt;&lt;br /&gt;    &lt;/form&gt;&lt;br /&gt;&lt;/.body&gt;&lt;br /&gt;&lt;/.html&gt;&lt;/span&gt;&lt;br /&gt;Notice that the &lt;.head&gt; tag includes a runat=&quot;server&quot; attribute. This attribute transforms the &lt;.head&gt; tag into a server-side HtmlHead control.&lt;br /&gt;The content page below overrides the page title. Notice that the &lt;%@ Page %&gt; directive at the top of this page has a value for its Title attribute. When the page is rendered, the text &quot;Content Page Title&quot; is displayed as the page title.&lt;br /&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;%@ Page MasterPageFile=&quot;~/TitleMaster.master&quot; Title=&quot;Content Page Title&quot; %&gt;&lt;br /&gt;&lt;asp:Content ID=&quot;Content1&quot;&lt;br /&gt;    ContentPlaceHolderID=&quot;ContentPlaceHolder1&quot;&lt;br /&gt;    Runat=&quot;Server&quot;&gt;&lt;br /&gt;    Here is some content   &lt;br /&gt;&lt;/asp:Content&gt;&lt;br /&gt;&lt;/span&gt;If you need to override other attributes of an HTML header, such as the meta tags or style tags, then you can reference the HtmlHead element directly from a content page. The HtmlHead control implements the IPageHeader interface, which includes the following properties:&lt;br /&gt;LinkedStyleSheets - The external style sheets linked to the HTML page.&lt;br /&gt;Metadata - The collection of Metadata tags.&lt;br /&gt;StyleSheet- Represents the styles applied to the HTML page.&lt;br /&gt;Title- The title of the HTML page.&lt;br /&gt;Any of these properties can be easily modified within a content page.&lt;br /&gt;Dynamically loading Master Pages&lt;br /&gt;In the end, I&#39;ll take a look at an advanced application of Master Pages, that is to dynamically load different Master Pages at run-time.&lt;br /&gt;There are a couple of circumstances in which dynamically loading Master Pages is useful. First, you might need to co-brand your Web site with one or more partner Web sites. When someone links to your Web site from a partner Web site, you might want to automatically load up a Master Page that matches the look and feel of the partner Web site.&lt;br /&gt;Another situation in which you might want to dynamically load Master Pages is when you want the users of your application to be able to pick a page layout. You can provide your users with a set of standard Master Pages. Users of your application can then select their favorite page layout by selecting their favorite Master Page.&lt;br /&gt;You can dynamically load a Master Page by assigning a value to the MasterPageFile property of the Page object. The value assigned to this property should be a relative path to a valid Master Page file.&lt;br /&gt;There is one important restriction that you must be aware of when using the MasterPageFile property. You can only assign a value to this property before or during the Page PreInit event. The PreInit is the earliest event during the page execution lifecycle. If you attempt to assign a value to this property during a later event, such as the Page Load event, then you&#39;ll receive an exception. This restriction makes sense, since different Master Pages will result in different sets of controls being loaded into the page.&lt;br /&gt;To define a Master Page at run-time, simply add the handler for the PreInit even and supply the master page...&lt;br /&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;script runat=&quot;server&quot;&gt;&lt;br /&gt;    Sub Page_PreInit(ByVal sender As Object, ByVal e As EventArgs)&lt;br /&gt;        MasterPageFile = myMaster.Master&lt;br /&gt;    End Sub&lt;br /&gt;&lt;/script&gt;&lt;/span&gt;&lt;br /&gt;And all things must come to an end...&lt;br /&gt;The main emphasis in this article was on ASP.Net 2.0 Master Pages. There is no question that Master Pages are my favorite new feature of ASP.Net 2.0. I hope you found this article interesting and informative. I am open for suggestions and remarks, both negative and positive.&lt;div class=&quot;blogger-post-footer&quot;&gt;FeedBurner&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dflorence25.blogspot.com/feeds/1035462278317364713/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1084787999077704213/1035462278317364713' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/1035462278317364713'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/1035462278317364713'/><link rel='alternate' type='text/html' href='http://dflorence25.blogspot.com/2008/02/master-pages-in-aspnet-20.html' title='Master Pages in ASP.Net 2.0'/><author><name>Flor</name><uri>http://www.blogger.com/profile/04517282987785226840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZYDSF-y7Vt7gRkup1yqg7Bn4ZODIz5NU2tDOUW10ZJaIM1D6fsTwAnmqU8WoJ88bq-dw_3l8jGR540YHTwHjr6NuJv-MBT47BwaJPkF2d2BNnV22Q5ddqbc9W3ut75w/s220/Flor.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1084787999077704213.post-3864326490486706306</id><published>2008-02-05T21:25:00.000-08:00</published><updated>2008-02-05T21:38:46.375-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Encryption and Decryption of a COOKIE"/><title type='text'>Encryption and Decryption of a COOKIE</title><content type='html'>Tracking Visitors with ASP.NET, showed how to use cookies to keep track of site visitors across sessions. I also discussed privacy issues concerning the use of cookie data, particularly if you are storing sensitive information about your visitors/users. It is always a good idea to publish privacy statements to inform your users about how their data is being used and stored on your Web site.&lt;br /&gt;&lt;br /&gt;Cookies can provide a real convenience to both visitors and programmers of a Web-based application. However, cookies are problematic from a security point of view for two reasons. First, unless your site uses SSL, cookie data is passed in the clear in the header of both the HTTP request and response. That means anyone who is clever enough to sniff packets on a particular port of a particular IP address can read cookie data as plain as day. The second problem is that cookie data is stored in nice little unrestricted cookie files in a browser&#39;s cache directory. This means that anyone that has access to your hard drive can see and open your cookies. Figure #1 shows an example of the contents of a cookie file.&lt;br /&gt;&lt;br /&gt;So when your 16 year old finds this &quot;convenient&quot; data and forges off to rack up thousands of dollars in charges on www.HottiesBareAll.com, it will suddenly become clear why cookie security is important.&lt;br /&gt;&lt;br /&gt;If you have never seen the voluminous quantity of cookie data on your machine, try the following. Open Internet Explorer, select Tools and then Internet Options from the menu. From the Internet Options dialog click the Settings button. Then on the Settings dialog click View Files. An Explorer window will display all the cached data your browser has kindly filled your hard drive with. Sort the list alphabetically, then scroll down to the Cs. (C is for &quot;Cookie&quot; :)) On my machine, there are currently 1,850 cookie files.&lt;br /&gt;&lt;br /&gt;So, here is some advice - don&#39;t store sensitive data about users in cookies. If you must, then you have a responsibility to protect that data through encryption.&lt;br /&gt;&lt;br /&gt;In previous versions of ASP, you would have been forced to purchase third party components to handle this encryption, or, if you are a genius, you could have ventured off and created your own components. However, most of us resorted to simple techniques that shift the ASCII values of each character in a string, like Rot13. Unfortunately, these techniques are more than obvious to people that are clever enough to sniff packets in the first place.&lt;br /&gt;&lt;br /&gt;Fortunately, we no longer have to implement our own feeble security algorithms since the .NET Framework provides us with a slew of encryption classes in the System.Security.Cryptography namespace. Take a look for yourself.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemsecuritycryptography.asp?frame=true&quot;&gt;http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemsecuritycryptography.asp?frame=true&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Overview of Cryptography in .NET&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;First, let&#39;s just acknowledge that encryption is really complicated. Frankly, it&#39;s supposed to be complicated because that is what makes it secure. And, by the way, I want to state here that I am in no way an encryption expert. There are probably only a handful of people that fully understand the intricacies of the math involved, and half of them probably wrote the cryptography classes for the .NET Framework.&lt;br /&gt;&lt;br /&gt;Fortunately, we don&#39;t have to understand the intricacies to take advantage of encryption because the .NET Framework gives us a simple way to access the power of the best and most secure algorithms.&lt;br /&gt;Before we begin encrypting our cookie data, we should have a little discussion about the cryptography classes and which ones are appropriate for securing our cookies.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;What Is Encryption Exactly?&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;In the simplest terms, encryption is the process of taking a target string of characters (bytes, more specifically) and converting it into another string of characters so that by examination, the original characters cannot be deciphered. This process is performed with a second string of characters known as a &quot;key&quot;. In technical terms, this key is mathematically &quot;mashed&quot; into the original string over many complex and compounded iterations. In addition, sometimes another string of characters, known as an &quot;initialization vector&quot;, is &quot;mangled&quot; into the target string before the key is mashed. This helps to prevent obvious patterns in the target string from being revealed by mashing alone. Of course, the mashing and mangling is not permanent. If the key and the initialization vector remain intact, then the algorithms can use them in reverse to unmangle and unmash the original data.&lt;br /&gt;&lt;br /&gt;The effectiveness or &quot;strength&quot; of the encryption is determined by the size of the key used. The larger the key, the stronger the encryption. Typical key sizes are 64 bit (8 bytes), 128 bit (16 bytes), 192 bit (24 bytes), 256 bit (32 bytes) and 512 bit (64 bytes). The only way to crack most of these algorithms is by sheer brute force, where an attacker creates a program to test every single possible key combination. For even the 64-bit option, there are 72,057,594,037,927,936 possible combinations (2^56 - 8 bits are held for parity). So basically, unless you have a very powerful computer, you are going to be waiting awhile to crack even the weakest key.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Cryptography Patterns&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;There are two basic approaches for handling data encryption: symmetric (or private key) and asymmetric (or public key). In symmetric cryptography techniques, both sides of the data exchange (the encryptor and decryptor) must have access to a single secret private key.&lt;br /&gt;&lt;br /&gt;In asymmetric encryption, one side (the decryptor) requests a public key from the encryptor. The encryptor creates a public key and sends it to the requestor. Then the encryptor uses the public key to create a second unique private key that it holds on to. This new private key is used to encrypt the message sent to the decryptor, who then uses the public key to decrypt the message. If encrypted data must be sent in the other direction then the other side will create a new public key and sends it along in a reciprocal fashion. This asymmetric technique is used by SSL to secure HTTP transmissions.&lt;br /&gt;&lt;br /&gt;For our cookie encryption purposes, we will use the symmetric approach since both the encryption and decryption will take place in the same application on the server; therefore, we only need one private key that we will keep secure in the compiled code of our cryptographic utility class.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Cryptographic Service Providers&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;The .NET Framework provides 4 cryptographic algorithms that extend from the base SymmetricAlgorithm class:&lt;br /&gt;&lt;br /&gt;* System.Security.Cryptography.DES (Data Encryption Standard)&lt;br /&gt;&lt;br /&gt;* System.Security.Cryptography.TripleDES (Triple Data Encryption Standard)&lt;br /&gt;&lt;br /&gt;* System.Security.Cryptography.RC2&lt;br /&gt;&lt;br /&gt;* System.Security.Cryptography.Rijndael&lt;br /&gt;&lt;br /&gt;In our example project, we will demonstrate both the DES and TripleDES algorithms. Each of these algorithms is accessed through wrapper classes categorized as Cryptographic Service Providers (CSP).&lt;br /&gt;All CSP objects have two important methods: CreateEncryptor &amp;amp; CreateDecryptor. Each method has two parameters for our private key and initialization vector. Each method returns an algorithm object with the ICryptoTransform interface. This object will be used by the CryptoStream object(which we will discuss in a minute.)&lt;br /&gt;&lt;br /&gt;For more a in-depth discussion of Cryptography in .NET, visit the following link in the MSDN Library:&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://msdn.microsoft.com/library/en-us/cpguide/html/cpconcryptographyoverview.asp?frame=true&quot;&gt;http://msdn.microsoft.com/library/en-us/cpguide/html/cpconcryptographyoverview.asp?frame=true&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Key Size Considerations&lt;br /&gt;&lt;br /&gt;DES is one of the weaker encryption methods because its key size is limited to 64 bits. However, for our cookie purposes, this level of encryption is probably sufficient. TripleDES, which, believe it or not, performs the encryption three times, also has a larger key size. The length of the key must be either 128 or 192 bits - two to three times larger. TripleDES is significantly more secure.&lt;br /&gt;Deciding which algorithm to use should not only be based on your desire for stronger encryption but also by the size of the cookies you require. You will notice in our example application that encrypted data will grow in size. And of course, the larger the key, the larger the resulting data. This is an important consideration since cookie data is restricted to 4kb.&lt;br /&gt;&lt;br /&gt;An alternative is to store data that you only need to persist temporarily in hidden input tags. Of course, this is exactly what ViewState does in ASP.NET. In addition, ViewState offers some built-in encryption. The ViewState of a Web form, by default, uses hash functions from some of the asymmetric algorithms to garble the content. This is not fully secure. However, you can configure your ASP.NET application or individual pages to use more secure encryption on the ViewState - specifying the same TripleDES algorithm we discussed earlier. Here is an article on MSDN on how to do just that:&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://msdn.microsoft.com/library/en-us/dnaspnet/html/asp11222001.asp?frame=true&quot;&gt;http://msdn.microsoft.com/library/en-us/dnaspnet/html/asp11222001.asp?frame=true&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Of course, if you are carrying that much data around in cookies, you really should reconsider you Web-application design. Remember, each request made of the server will need to pass this cookie blob back, unnecessarily chewing up bandwidth.&lt;br /&gt;&lt;br /&gt;Finally, encryption is a processor intensive activity. The more data you are encrypting/decrypting or the stronger your algorithm, the more server resources you will require, potentially slowing down the entire site.&lt;br /&gt;&lt;br /&gt;The CryptoStream Object&lt;br /&gt;&lt;br /&gt;One of the things you may find hard to understand at first is that all encryption and decryption in .NET is handled through the CryptoStream object. I know you are thinking that all we need to do is convert a few strings. Why do we need to mess with complicated streams. Well, from the broader scope of cryptographic issues and from the design emphasis of the .NET Framework, using streams really makes sense. Nearly all access (IO) to external resources handled by the .NET Framework is done through the use of streams. While it is not in the System.IO namespace, the CryptoStream object inherits from the System.IO.Stream object.&lt;br /&gt;&lt;br /&gt;The major advantage of using streams is that they can be chained together. This is particularly useful when performing file operations or accessing other network services. For instance, you can open a socket to a network service and stream data that is simultaneously being encrypted. The following link provides an example of DES provider encrypting a file through streams.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemSecurityCryptographyDESClassTopic.asp?frame=true&quot;&gt;http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemSecurityCryptographyDESClassTopic.asp?frame=true&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;So, in order to work with strings as a stream, we need to utilize a special class called a MemoryStream. This will allow us to handle strings as streams and flow them through the CryptoStream for processing.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Creating a Simple Cryptography Utility Class&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Well, you have all been waiting patiently, so here is the code for our CryptoUtil class. As with many utility functions, these don&#39;t require state so all our methods are shared (static).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:85%;color:#0000ff;&quot;&gt;&lt;br /&gt;Imports System.Diagnostics&lt;br /&gt;Imports System.Security.Cryptography&lt;br /&gt;Imports System.Text&lt;br /&gt;Imports System.IO&lt;br /&gt;&lt;br /&gt;Public Class CryptoUtil&lt;br /&gt;&lt;br /&gt;&#39;8 bytes randomly selected for both the Key and the Initialization Vector&lt;br /&gt;&#39;the IV is used to encrypt the first block of text so that any repetitive&lt;br /&gt;&#39;patterns are not apparent&lt;br /&gt;Private Shared KEY_64() As Byte = {42, 16, 93, 156, 78, 4, 218, 32}&lt;br /&gt;Private Shared IV_64() As Byte = {55, 103, 246, 79, 36, 99, 167, 3}&lt;br /&gt;&lt;br /&gt;&#39;24 byte or 192 bit key and IV for TripleDES&lt;br /&gt;Private Shared KEY_192() As Byte = {42, 16, 93, 156, 78, 4, 218, 32, _&lt;br /&gt;15, 167, 44, 80, 26, 250, 155, 112, _&lt;br /&gt;2, 94, 11, 204, 119, 35, 184, 197}&lt;br /&gt;Private Shared IV_192() As Byte = {55, 103, 246, 79, 36, 99, 167, 3, _&lt;br /&gt;42, 5, 62, 83, 184, 7, 209, 13, _&lt;br /&gt;145, 23, 200, 58, 173, 10, 121, 222}&lt;br /&gt;&lt;br /&gt;&#39;Standard DES encryption&lt;br /&gt;Public Shared Function Encrypt(ByVal value As String) As String&lt;br /&gt;If value &lt;&gt; &quot;&quot; Then&lt;br /&gt;Dim cryptoProvider As DESCryptoServiceProvider = _&lt;br /&gt;New DESCryptoServiceProvider()&lt;br /&gt;Dim ms As MemoryStream = New MemoryStream()&lt;br /&gt;Dim cs As CryptoStream = _&lt;br /&gt;New CryptoStream(ms, cryptoProvider.CreateEncryptor(KEY_64, IV_64), _&lt;br /&gt;CryptoStreamMode.Write)&lt;br /&gt;Dim sw As StreamWriter = New StreamWriter(cs)&lt;br /&gt;&lt;br /&gt;sw.Write(value)&lt;br /&gt;sw.Flush()&lt;br /&gt;cs.FlushFinalBlock()&lt;br /&gt;ms.Flush()&lt;br /&gt;&lt;br /&gt;&#39;convert back to a string&lt;br /&gt;Return Convert.ToBase64String(ms.GetBuffer(), 0, ms.Length)&lt;br /&gt;End If&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&#39;Standard DES decryption&lt;br /&gt;Public Shared Function Decrypt(ByVal value As String) As String&lt;br /&gt;If value &lt;&gt; &quot;&quot; Then&lt;br /&gt;Dim cryptoProvider As DESCryptoServiceProvider = _&lt;br /&gt;New DESCryptoServiceProvider()&lt;br /&gt;&lt;br /&gt;&#39;convert from string to byte array&lt;br /&gt;Dim buffer As Byte() = Convert.FromBase64String(value)&lt;br /&gt;Dim ms As MemoryStream = New MemoryStream(buffer)&lt;br /&gt;Dim cs As CryptoStream = _&lt;br /&gt;New CryptoStream(ms, cryptoProvider.CreateDecryptor(KEY_64, IV_64), _&lt;br /&gt;CryptoStreamMode.Read)&lt;br /&gt;Dim sr As StreamReader = New StreamReader(cs)&lt;br /&gt;&lt;br /&gt;Return sr.ReadToEnd()&lt;br /&gt;End If&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;&#39;TRIPLE DES encryption&lt;br /&gt;Public Shared Function EncryptTripleDES(ByVal value As String) As String&lt;br /&gt;If value &lt;&gt; &quot;&quot; Then&lt;br /&gt;Dim cryptoProvider As TripleDESCryptoServiceProvider = _&lt;br /&gt;New TripleDESCryptoServiceProvider()&lt;br /&gt;Dim ms As MemoryStream = New MemoryStream()&lt;br /&gt;Dim cs As CryptoStream = _&lt;br /&gt;New CryptoStream(ms, cryptoProvider.CreateEncryptor(KEY_192, IV_192), _&lt;br /&gt;CryptoStreamMode.Write)&lt;br /&gt;Dim sw As StreamWriter = New StreamWriter(cs)&lt;br /&gt;&lt;br /&gt;sw.Write(value)&lt;br /&gt;sw.Flush()&lt;br /&gt;cs.FlushFinalBlock()&lt;br /&gt;ms.Flush()&lt;br /&gt;&lt;br /&gt;&#39;convert back to a string&lt;br /&gt;Return Convert.ToBase64String(ms.GetBuffer(), 0, ms.Length)&lt;br /&gt;End If&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&#39;TRIPLE DES decryption&lt;br /&gt;Public Shared Function DecryptTripleDES(ByVal value As String) As String&lt;br /&gt;If value &lt;&gt; &quot;&quot; Then&lt;br /&gt;Dim cryptoProvider As TripleDESCryptoServiceProvider = _&lt;br /&gt;New TripleDESCryptoServiceProvider()&lt;br /&gt;&lt;br /&gt;&#39;convert from string to byte array&lt;br /&gt;Dim buffer As Byte() = Convert.FromBase64String(value)&lt;br /&gt;Dim ms As MemoryStream = New MemoryStream(buffer)&lt;br /&gt;Dim cs As CryptoStream = _&lt;br /&gt;New CryptoStream(ms, cryptoProvider.CreateDecryptor(KEY_192, IV_192), _&lt;br /&gt;CryptoStreamMode.Read)&lt;br /&gt;Dim sr As StreamReader = New StreamReader(cs)&lt;br /&gt;&lt;br /&gt;Return sr.ReadToEnd()&lt;br /&gt;End If&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;End Class&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Note that our keys are initialized at the top as an array of bytes. Also, note that I am using numeric constants in these arrays. If you choose to do the same, be sure to keep the values greater than or equal to zero and less than or equal to 255. This is the allowable range for a byte value.&lt;br /&gt;&lt;br /&gt;In the class, we have 2 pairs of functions for encrypting and decrypting under both the DES and TripleDES providers. On the encrypt functions, the final byte array in the Memory Stream buffer is converted back to a string using the ToBase64String function. The reverse is done on the decrypt functions with the FromBase64String function.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Creating a Cookie Utility Class&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Our next step is to create a simple class for setting and retrieving either plain cookies or those with encryption on top. Again we use series of shared methods to simplify the setting and getting of cookie data, allowing you to handle cookie data with one line of code.&lt;br /&gt;Imports System.Web&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:85%;color:#0000ff;&quot;&gt;&lt;br /&gt;Public Class CookieUtil&lt;br /&gt;&lt;br /&gt;&#39;SET COOKIE FUNCTIONS *****************************************************&lt;br /&gt;&lt;br /&gt;&#39;SetTripleDESEncryptedCookie - key &amp;amp; value only&lt;br /&gt;Public Shared Sub SetTripleDESEncryptedCookie(ByVal key As String, _&lt;br /&gt;ByVal value As String)&lt;br /&gt;&#39;Convert parts&lt;br /&gt;key = CryptoUtil.EncryptTripleDES(key)&lt;br /&gt;value = CryptoUtil.EncryptTripleDES(value)&lt;br /&gt;&lt;br /&gt;SetCookie(key, value)&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;&#39;SetTripleDESEncryptedCookie - overloaded method with expires parameter&lt;br /&gt;Public Shared Sub SetTripleDESEncryptedCookie(ByVal key As String, _&lt;br /&gt;ByVal value As String, ByVal expires As Date)&lt;br /&gt;&#39;Convert parts&lt;br /&gt;key = CryptoUtil.EncryptTripleDES(key)&lt;br /&gt;value = CryptoUtil.EncryptTripleDES(value)&lt;br /&gt;&lt;br /&gt;SetCookie(key, value, expires)&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&#39;SetEncryptedCookie - key &amp;amp; value only&lt;br /&gt;Public Shared Sub SetEncryptedCookie(ByVal key As String, _&lt;br /&gt;ByVal value As String)&lt;br /&gt;&#39;Convert parts&lt;br /&gt;key = CryptoUtil.Encrypt(key)&lt;br /&gt;value = CryptoUtil.Encrypt(value)&lt;br /&gt;&lt;br /&gt;SetCookie(key, value)&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;&#39;SetEncryptedCookie - overloaded method with expires parameter&lt;br /&gt;Public Shared Sub SetEncryptedCookie(ByVal key As String, _&lt;br /&gt;ByVal value As String, ByVal expires As Date)&lt;br /&gt;&#39;Convert parts&lt;br /&gt;key = CryptoUtil.Encrypt(key)&lt;br /&gt;value = CryptoUtil.Encrypt(value)&lt;br /&gt;&lt;br /&gt;SetCookie(key, value, expires)&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&#39;SetCookie - key &amp;amp; value only&lt;br /&gt;Public Shared Sub SetCookie(ByVal key As String, ByVal value As String)&lt;br /&gt;&#39;Encode Part&lt;br /&gt;key = HttpContext.Current.Server.UrlEncode(key)&lt;br /&gt;value = HttpContext.Current.Server.UrlEncode(value)&lt;br /&gt;&lt;br /&gt;Dim cookie As HttpCookie&lt;br /&gt;cookie = New HttpCookie(key, value)&lt;br /&gt;SetCookie(cookie)&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;&#39;SetCookie - overloaded with expires parameter&lt;br /&gt;Public Shared Sub SetCookie(ByVal key As String, _&lt;br /&gt;ByVal value As String, ByVal expires As Date)&lt;br /&gt;&#39;Encode Parts&lt;br /&gt;key = HttpContext.Current.Server.UrlEncode(key)&lt;br /&gt;value = HttpContext.Current.Server.UrlEncode(value)&lt;br /&gt;&lt;br /&gt;Dim cookie As HttpCookie&lt;br /&gt;cookie = New HttpCookie(key, value)&lt;br /&gt;cookie.Expires = expires&lt;br /&gt;SetCookie(cookie)&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;&#39;SetCookie - HttpCookie only&lt;br /&gt;&#39;final step to set the cookie to the response clause&lt;br /&gt;Public Shared Sub SetCookie(ByVal cookie As HttpCookie)&lt;br /&gt;HttpContext.Current.Response.Cookies.Set(cookie)&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;&#39;GET COOKIE FUNCTIONS *****************************************************&lt;br /&gt;&lt;br /&gt;Public Shared Function GetTripleDESEncryptedCookieValue(ByVal key As String) _ As String&lt;br /&gt;&#39;encrypt key only - encoding done in GetCookieValue&lt;br /&gt;key = CryptoUtil.EncryptTripleDES(key)&lt;br /&gt;&lt;br /&gt;&#39;get value&lt;br /&gt;Dim value As String&lt;br /&gt;value = GetCookieValue(key)&lt;br /&gt;&#39;decrypt value&lt;br /&gt;value = CryptoUtil.DecryptTripleDES(value)&lt;br /&gt;Return value&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;Public Shared Function GetEncryptedCookieValue(ByVal key As String) As String&lt;br /&gt;&#39;encrypt key only - encoding done in GetCookieValue&lt;br /&gt;key = CryptoUtil.Encrypt(key)&lt;br /&gt;&lt;br /&gt;&#39;get value&lt;br /&gt;Dim value As String&lt;br /&gt;value = GetCookieValue(key)&lt;br /&gt;&#39;decrypt value&lt;br /&gt;value = CryptoUtil.Decrypt(value)&lt;br /&gt;Return value&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;Public Shared Function GetCookie(ByVal key As String) As HttpCookie&lt;br /&gt;&#39;encode key for retrieval&lt;br /&gt;key = HttpContext.Current.Server.UrlEncode(key)&lt;br /&gt;Return HttpContext.Current.Request.Cookies.Get(key)&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;Public Shared Function GetCookieValue(ByVal key As String) As String&lt;br /&gt;Try&lt;br /&gt;&#39;don&#39;t encode key for retrieval here&lt;br /&gt;&#39;done in the GetCookie function&lt;br /&gt;&lt;br /&gt;&#39;get value&lt;br /&gt;Dim value As String&lt;br /&gt;value = GetCookie(key).Value&lt;br /&gt;&#39;decode stored value&lt;br /&gt;value = HttpContext.Current.Server.UrlDecode(value)&lt;br /&gt;Return value&lt;br /&gt;Catch&lt;br /&gt;End Try&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;End Class&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You&#39;ll notice most of the set functions are overloaded to provide an addition parameter for a cookie expiration date. Not setting the expiration will keep the cookie only for the browser session in memory. To set a permanent cookie, set an expiration date for a point in the future.&lt;br /&gt;&lt;br /&gt;Also, note that the encryption functions handle the encryption of both the data and the key. It is important to encrypt the key as well since that can expose information about the nature of the data. For instance, if your key was &quot;UserID&quot;, then it might be safe to assume that your encrypted value is a numeric string, giving an attacker an advantage.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Encoding Cookies&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Note that our standard cookie functions encode and decode the keys and values of the cookies. The reason for this is that cookies fall under the same restrictions as URLs. Specifically, the characters &#39;=&#39; and &#39;;&#39; are reserved and must be escaped; this is especially important when saving encrypted data because the encryption algorithm will append &quot;=&quot; to fill the block with the allocated block size.&lt;br /&gt;&lt;br /&gt;The Sample Project&lt;br /&gt;&lt;br /&gt;Our sample project is actually two projects: EncryptingCookies (view demo) and Plourdenet.Com.WebTools. EncryptingCookies is the Web-application project that contains our Web forms and utilizes the utility classes. Plourdenet.Com.WebTools is a class library project housing the utility classes. Placing the utility classes in a separate project makes it easy for us to eventually deploy the assembly to be shared with multiple Web projects.&lt;br /&gt;&lt;br /&gt;Figure #2 - Solution Explorer for the Sample Projects&lt;br /&gt;&lt;br /&gt;There are two thing to remember when setting up a structure like this. First, you must add a reference to System.Web in your class library. Second, you must add a reference to your utility project in your Web application. In addition, all the code that references the utility project should provide an Imports statement as such:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:85%;color:#0000ff;&quot;&gt;&lt;br /&gt;Imports Plourdenet.Com.WebTools&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Creating Web Forms To Set Cookies&lt;br /&gt;&lt;br /&gt;In our sample application, I have two forms. The first (and the default form) is SetCookies.aspx, and the second is GetCookies.aspx&lt;br /&gt;&lt;br /&gt;SetCookies.aspx Web Form&lt;br /&gt;&lt;br /&gt;The set cookies form is quite simple. We have a single text box and a button to post the value back to the server.&lt;br /&gt;&lt;br /&gt;Figure #3 - The SetCookies.aspx Web Form&lt;br /&gt;&lt;br /&gt;When the Save Cookie button is clicked, the form returns to the server and initiates the following server-side event:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:85%;color:#0000ff;&quot;&gt;&lt;br /&gt;Protected Const COOKIE_KEYNAME = &quot;MyKey&quot;&lt;br /&gt;&lt;br /&gt;Private Sub btnSaveCookie_Click(ByVal sender As System.Object, _&lt;br /&gt;ByVal e As System.EventArgs) Handles btnSaveCookie.Click&lt;br /&gt;CookieUtil.SetCookie(COOKIE_KEYNAME, _&lt;br /&gt;txtCookieValue.Text, Now.AddDays(30))&lt;br /&gt;CookieUtil.SetEncryptedCookie(COOKIE_KEYNAME, _&lt;br /&gt;txtCookieValue.Text, Now.AddDays(30))&lt;br /&gt;CookieUtil.SetTripleDESEncryptedCookie(COOKIE_KEYNAME, _&lt;br /&gt;txtCookieValue.Text, Now.AddDays(30))&lt;br /&gt;Response.Redirect(&quot;GetCookies.aspx&quot;)&lt;br /&gt;End Sub&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Using a constant for the cookie key name and the value submitted in the text box, we set three cookies. First, a standard unencrypted cookie. Second, a cookie encrypted with DES, and third, a cookie encrypted with Triple DES.&lt;br /&gt;&lt;br /&gt;GetCookies.aspx Web Form&lt;br /&gt;&lt;br /&gt;The Get Cookies Web Form is doing a little more work behind the scene to show you what happens to your cookie data.&lt;br /&gt;&lt;br /&gt;Figure #4 - The GetCookies.aspx Web Form&lt;br /&gt;&lt;br /&gt;In the Page_Load event, we retrieve the cookie data using our CookieUtil accessor functions. Then, finally we dump out the contents of the entire cookie collection, just to prove there was no funny business.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:85%;color:#0000ff;&quot;&gt;&lt;br /&gt;Protected Const COOKIE_KEYNAME = &quot;MyKey&quot;&lt;br /&gt;&lt;br /&gt;Private Sub Page_Load(ByVal sender As System.Object, _&lt;br /&gt;ByVal e As System.EventArgs) Handles MyBase.Load&lt;br /&gt;&#39;Put user code to initialize the page here&lt;br /&gt;Dim DESCookieKey As String = CryptoUtil.Encrypt(COOKIE_KEYNAME)&lt;br /&gt;Dim TripleDESCookieKey As String = _&lt;br /&gt;CryptoUtil.EncryptTripleDES(COOKIE_KEYNAME)&lt;br /&gt;&lt;br /&gt;lblCookieName.Text = COOKIE_KEYNAME&lt;br /&gt;lblStandardCookieValue.Text = _&lt;br /&gt;CookieUtil.GetCookieValue(COOKIE_KEYNAME)&lt;br /&gt;lblDESEncryptedValue.Text = _&lt;br /&gt;CookieUtil.GetCookieValue(DESCookieKey)&lt;br /&gt;lblDESDecryptedValue.Text = _&lt;br /&gt;CookieUtil.GetEncryptedCookieValue(COOKIE_KEYNAME)&lt;br /&gt;lblTripleDESEncryptedValue.Text = _&lt;br /&gt;CookieUtil.GetCookieValue(TripleDESCookieKey)&lt;br /&gt;lblTripleDESDecryptedValue.Text = _&lt;br /&gt;CookieUtil.GetTripleDESEncryptedCookieValue(COOKIE_KEYNAME)&lt;br /&gt;&lt;br /&gt;&#39;Start Cookie Dump&lt;br /&gt;Dim cookie As HttpCookie&lt;br /&gt;Dim key As String&lt;br /&gt;lblAllCookies.Text = _&lt;br /&gt;&quot; &lt;table style=&quot;WIDTH: 142px; HEIGHT: 355px&quot; cellspacing=&quot;1&quot; cellpadding=&quot;1&quot; border=&quot;1&quot;&gt;&quot; &amp;amp; vbCrLf&lt;br /&gt;lblAllCookies.Text &amp;amp;= _&lt;br /&gt;&quot; &lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;b&gt;&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;&quot; &amp;amp; vbCrLf&lt;br /&gt;For Each key In Request.Cookies.Keys&lt;br /&gt;cookie = Request.Cookies(key)&lt;br /&gt;lblAllCookies.Text &amp;amp;= _&lt;br /&gt;&quot; &lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&quot; &amp;amp; vbCrLf&lt;br /&gt;Next&lt;br /&gt;lblAllCookies.Text &amp;amp;= &quot;&lt;/tbody&gt;&lt;/table&gt;&quot; &amp;amp; vbCrLf&lt;br /&gt;&lt;br /&gt;End Sub&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Cautions about Cookies&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;So there you have it - a fairly simple yet powerful way to encrypt your cookie data. But before I leave you, I want to review a few issues to watch out for when using cookies.&lt;br /&gt;&lt;br /&gt;* Your entire cookie collection is limited to 4 kilobytes in size. This includes key, the space for key names, and other related data.&lt;br /&gt;&lt;br /&gt;* The size of your cookie data will increase when encrypted. Make sure you do not run over the limit.&lt;br /&gt;&lt;br /&gt;* Cookies are sent to the server every time a request is made to the server. Therefore, if you are lugging large cookies back and forth, you are using additional bandwidth and server processing resources.&lt;br /&gt;&lt;br /&gt;* Encrypting large amounts of data can impact application performance.&lt;br /&gt;&lt;br /&gt;* Any initial values supplied by your user cannot be encrypted unless you use SSL on your site. For instance, in our sample set cookies form, the initial value was passed in the clear to the server.&lt;br /&gt;&lt;br /&gt;* Cookies can be blocked or deleted at anytime by your users. If the use of cookies is critical to the operation of your application, you may need to find ways to work around users that can&#39;t or won&#39;t permit them.&lt;br /&gt;&lt;br /&gt;Good Luck! And let me know when you have baked your first batch of encrypted cookies.&lt;div class=&quot;blogger-post-footer&quot;&gt;FeedBurner&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dflorence25.blogspot.com/feeds/3864326490486706306/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1084787999077704213/3864326490486706306' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/3864326490486706306'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1084787999077704213/posts/default/3864326490486706306'/><link rel='alternate' type='text/html' href='http://dflorence25.blogspot.com/2008/02/tracking-visitors-with-asp.html' title='Encryption and Decryption of a COOKIE'/><author><name>Flor</name><uri>http://www.blogger.com/profile/04517282987785226840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZYDSF-y7Vt7gRkup1yqg7Bn4ZODIz5NU2tDOUW10ZJaIM1D6fsTwAnmqU8WoJ88bq-dw_3l8jGR540YHTwHjr6NuJv-MBT47BwaJPkF2d2BNnV22Q5ddqbc9W3ut75w/s220/Flor.jpg'/></author><thr:total>0</thr:total></entry></feed>