<?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: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-8602939654357884727</id><updated>2012-01-25T07:04:40.211-08:00</updated><category term='MYSQL'/><category term='Unix'/><category term='Python'/><category term='Visual Studio'/><category term='MVC'/><category term='XSD'/><category term='Encoding'/><category term='Stepmania'/><category term='SilverLight'/><category term='Source Control'/><category term='LinqToSQL'/><category term='SQL Server'/><category term='PL/SQL'/><category term='AJAX'/><category term='Misc'/><category term='VB.NET'/><category term='Web Testing'/><category term='Windows'/><category term='Wix'/><category term='Security'/><category term='MSI'/><category term='XAMPP'/><category term='ASP.NET'/><category term='Shell'/><category term='LinqToXML'/><category term='JQuery'/><category term='Flash'/><category term='Virtual Hardware'/><category term='FTP'/><category term='Networking'/><category term='Solaris'/><category term='Application Development Features'/><category term='SSL'/><category term='iOS'/><category term='Apache'/><category term='JSON'/><category term='Unit Testing'/><category term='News'/><category term='Facebook Development'/><category term='Windows 2003 Server'/><category term='VB Script'/><category term='LINQ'/><category term='Continuous Integration'/><category term='VMWare'/><category term='XSLT'/><category term='CSS'/><category term='Web Services'/><category term='UML'/><category term='ASP'/><category term='XML'/><category term='Windows Services'/><category term='F#'/><category term='Perl'/><category term='MSBuild'/><category term='VB 6.0'/><category term='IIS'/><category term='Exception Handling'/><category term='C#'/><category term='SOAP'/><category term='CruiseControl.NET'/><category term='PHP'/><category term='xHTML'/><category term='iPhone'/><category term='SEO'/><category term='Active Directory'/><category term='Hackintosh'/><category term='Sub Version'/><category term='SSRS'/><category term='HTML'/><category term='.NET 1.1'/><category term='T-SQL'/><category term='JavaScript'/><category term='XSS'/><category term='WPF'/><category term='Entity Framework'/><category term='.NET'/><category term='Design and Architecture'/><title type='text'>TutorialGenius.com</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default?start-index=101&amp;max-results=100'/><author><name>TutorialGenius</name><uri>http://www.blogger.com/profile/16984408396121354465</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://4.bp.blogspot.com/_qvTkOBaMdWA/SQosKkjd2wI/AAAAAAAAAAM/ZX5jcQQqXfs/s1600-R/n279201131_2306568_8104.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>191</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-120649628168543060</id><published>2012-01-25T06:59:00.000-08:00</published><updated>2012-01-25T07:04:40.232-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Unix'/><title type='text'>Full path of service and service temporary directory when running</title><content type='html'>Execute the following command to view all processes and do a search of a service name (The service your searching for)&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;ps auxwwwe | grep SERVICENAMEHERE&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This will give you back some info about the service. We are really only interested in the ProcessID (PID). This will be an integer.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Example return&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;root     24466  0.0  0.0   1476   280 ?        S     2009   0:00 supervise sshd&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;PID will be&lt;/span&gt;: &lt;span style="font-weight:bold;"&gt;24466&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;So now navigate to &lt;span style="font-weight:bold;"&gt;/proc&lt;/span&gt; and view the contents. You will see a directory for your PID. View the contents of this directory to see the info for the service.&lt;br /&gt;&lt;br /&gt;The file path is located @ exe in this example: &lt;span style="font-weight:bold;"&gt;exe -&gt; /usr/sbin/servicename&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-120649628168543060?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/120649628168543060/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=120649628168543060' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/120649628168543060'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/120649628168543060'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2012/01/full-path-of-service-and-service.html' title='Full path of service and service temporary directory when running'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-210925243473352947</id><published>2012-01-23T07:34:00.000-08:00</published><updated>2012-01-23T08:46:01.270-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SSL'/><category scheme='http://www.blogger.com/atom/ns#' term='FTP'/><title type='text'>proftpd - Adding FTPS Support</title><content type='html'>&lt;span style="font-weight:bold;"&gt;This guide assumes you have proftpd installed with OpenSSL libs. If not, follow &lt;a href="http://www.troublenow.org/6/howto-setup-a-proftpd-daemon-using-ssl-encryption/" target="_blank"&gt;this guide&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Firstly, I will quickly say....&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;FTPS or SFTP&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;People intend to mix FTPS and SFTP together, but both are actually completely differend.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;FTPS&lt;/span&gt; is a normal FTP server but using SSL encrytion.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;SFTP&lt;/span&gt; is a ftp kind of session over SSH (so everything is encrypted just like in SSH).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Notes&lt;/span&gt;&lt;br /&gt;Users Guide: &lt;a href="http://proftpd.org/localsite/Userguide/linked/userguide.html" target="blank"&gt;http://proftpd.org/localsite/Userguide/linked/userguide.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Steps&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;*** Ensure mod_tls module is available within your proftpd installation.&lt;br /&gt;*** Ensure you are a root user&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;1. Open &lt;span style="font-weight:bold;"&gt;proftpd.conf &lt;/span&gt; and add an include to a config file we are going to create (tls.conf). Add the following line below...&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;br /&gt;&lt;pre class="alt"&gt;Include         /etc/proftpd/tls.conf&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2. Now use &lt;span style="font-weight:bold;"&gt;vi&lt;/span&gt; to create the config file in the specified location...&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;br /&gt;&lt;pre class="alt"&gt;vi /etc/proftpd/tls.conf&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3. Enter the following information into the file (&lt;a href="http://www.eec.com/business/vi.html" target="_blank"&gt;How to use vi&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;# Proftpd sample configuration for FTPS connections.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="rem"&gt;#&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;# Note that FTPS impose some limitations in NAT traversing.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="rem"&gt;# See http://www.castaglia.org/proftpd/doc/contrib/ProFTPD-mini-HOWTO-TLS.html&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;# for more information.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="rem"&gt;#&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&amp;lt;IfModule mod_tls.c&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;TLSEngine                               on&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;TLSLog                                  /var/log/proftpd/tls.log&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;TLSProtocol                             SSLv23&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;TLSRSACertificateFile                   /etc/proftpd/ssl/proftpd.cert.pem&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;TLSRSACertificateKeyFile                /etc/proftpd/ssl/proftpd.key.pem&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;#&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="rem"&gt;# Avoid CA cert and allow client renegotiation (to overcome 1.3.2c bug 3324)&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;#TLSOptions                             NoCertRequest AllowClientRenegotiation&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="rem"&gt;#&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;# Authenticate clients that want to use FTP over TLS?&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="rem"&gt;#&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;TLSVerifyClient                         off&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="rem"&gt;#&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;# Are clients required to use FTP over TLS when talking to this server?&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="rem"&gt;#&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;TLSRequired                             on&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="rem"&gt;#&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;# Allow SSL/TLS renegotiations when the client requests them, but&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="rem"&gt;# do not force the renegotations.  Some clients do not support&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;# SSL/TLS renegotiations; when mod_tls forces a renegotiation, these&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="rem"&gt;# clients will close the data connection, or there will be a timeout&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;# on an idle data connection.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="rem"&gt;#&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;TLSRenegotiate                          required off&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&amp;lt;/IfModule&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;4. Generate certificate using OpenSSL&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;br /&gt;&lt;pre class="alt"&gt;openssl req -new -x509 -days 365 -nodes -out /etc/proftpd/ssl/proftpd.cert.pem -keyout /etc/proftpd/ssl/proftpd.key.pem&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;5. Save and close the file.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;6. Now restart proftpd for the changes to take effect.&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;br /&gt;&lt;pre class="alt"&gt;/etc/init.d/proftpd restart&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;7. Test FTPS connectivity with the server. See below...&lt;br /&gt;Note: if there are any issues with the connection process, check the log file within the tls.conf file we created: &lt;span style="font-style:italic;"&gt;/var/log/proftpd/tls.log&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Testing FTPS with lftp&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1. Execute following command&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;br /&gt;&lt;pre class="alt"&gt;lftp -u USERNAMEHERE -e &lt;span class="str"&gt;'set ftp:ssl-force true,ftp:ssl-protect-data true'&lt;/span&gt; SERVERNAMEHERE&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2. Enter password for user.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3. Perform a simple command. I.e. &lt;span style="font-style:italic;"&gt;ls -l&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-210925243473352947?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/210925243473352947/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=210925243473352947' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/210925243473352947'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/210925243473352947'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2012/01/proftpd-adding-ftps-support.html' title='proftpd - Adding FTPS Support'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-7511277564606741536</id><published>2012-01-17T07:51:00.000-08:00</published><updated>2012-01-17T08:21:32.731-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Solaris'/><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><title type='text'>Solaris 9 [SunOS 5.9] - Installing Python [This example uses 2.7.2]</title><content type='html'>This is a simple guide on how to install python on a Solaris 9 system. There are a few gotcha's which I am sharing and writing for future use.&lt;br /&gt;&lt;br /&gt;1. &lt;a href="http://python.org/download/" target="_blank"&gt;Download Python&lt;/a&gt;. I took the compressed source tarball (.tgz). You are essentially compiling the source on your system.&lt;br /&gt;&lt;br /&gt;2. &lt;span style="font-weight:bold;"&gt;Optional&lt;/span&gt;: Transferring it to the server. I had to transfer it to the server to install, so if you need to do that, see my &lt;a href="http://tutorialgenius.blogspot.com/2012/01/transfer-files-from-one-unix-server-to.html" target="_blank"&gt;previous post&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;3. Unzip the package using the following command. It will unzip, then untar.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;gunzip -c PYTHONFILENAME.tgz |tar xvf -&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;4. You now need to configure the source. This will produce a Makefile based on your system. Navigate to the Python source directory, and execute the following command...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;./configure --prefix=/usr/local&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;5. Ensure you are a root user before this step ("su root" - to change). Execute the following command to install Python.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;make -i install&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;6. If everything went well (it probably didn't - see below!). Add Python to your system PATH variable. This way, you don't need to refer to /usr/local everytime you execute a script. See my &lt;a href="http://tutorialgenius.blogspot.com/2012/01/updating-path-environment-variable-in.html" target="_blank"&gt;previous blog post&lt;/a&gt; on how to do this.&lt;br /&gt;&lt;br /&gt;7. Simply execute the following command to check Python has set itself up correctly... Do this outside of the source directory, so you can test the PATH variable aswell.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;python --version&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;8. Get an ice cold beerski in!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Troubleshooting&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;During the install procedure, you receive the following...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;./Parser/asdl_c.py -c ./Python ./Parser/Python.asdl&lt;br /&gt;/usr/bin/env: No such file or directory&lt;br /&gt;make: *** [Python/Python-ast.c] Error 127 &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Simply touch the libraries it requires (see below), and re-try... (Run &lt;span style="font-weight:bold;"&gt;make clean &lt;/span&gt;before re-try)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;touch Include/Python-ast.h Python/Python-ast.c &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;During the install procedure, you receive the following...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;make: ar: Command not found&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You need to add &lt;span style="font-weight:bold;"&gt;ar&lt;/span&gt; to your PATH variable. This is located in /usr/ccs/bin. See my &lt;a href="http://tutorialgenius.blogspot.com/2012/01/updating-path-environment-variable-in.html" target="_blank"&gt;previous blog post&lt;/a&gt; on how to do this.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Note&lt;/span&gt;: If you are receiving an error while re-trying or you wish to remove temporary install files, simply execute the following command... "&lt;span style="font-weight:bold;"&gt;make clean&lt;/span&gt;"&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-7511277564606741536?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/7511277564606741536/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=7511277564606741536' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/7511277564606741536'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/7511277564606741536'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2012/01/solaris-9-sunos-59-installing-python.html' title='Solaris 9 [SunOS 5.9] - Installing Python [This example uses 2.7.2]'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-8508315435757457158</id><published>2012-01-17T07:31:00.000-08:00</published><updated>2012-01-17T07:50:45.832-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Unix'/><category scheme='http://www.blogger.com/atom/ns#' term='Shell'/><title type='text'>Bash/sh/csh/tcsh - Updating PATH environment variable in session and on logon</title><content type='html'>When updating your PATH varible, it's usually because an installation requires programs and utilities within a directory, and the knowledge of the full path is not known. Either that, or you would like to refer to a command program within specifying the full path. You will usually receive the following error message if a program cannot be found...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;xxx: Command not found&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;So lets check our current PATH using the following command...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;echo $PATH&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We can now view the current directories included in our PATH variable.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Example&lt;/span&gt;: /usr/sysmgr/bin:/bin:/usr/sbin:/usr/bin:/usr/ucb:/usr/sysmg/bin:/etc:/usr/local/bin:.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For example, we may wish to install a program, and it requires the &lt;span style="font-weight:bold;"&gt;&lt;a href="http://en.wikipedia.org/wiki/Ar_%28Unix%29" target="_blank"&gt;ar&lt;/a&gt;&lt;/span&gt; tool (A tool to aid archiving). It is unaware of the full system path, so we need to add the directory it resides in to our environment variable.&lt;br /&gt;&lt;br /&gt;We can either do this temporarily or permanently... It also depends on which shell you are using.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Note&lt;/span&gt;: To find out which shell you are using, execute the following command.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;echo $SHELL&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Temporarily&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;tcsh/csh Shell&lt;/span&gt; (Seperate by spaces and use set command)&lt;br /&gt;set path=(/usr/sysmgr/bin /bin /usr/sbin /usr/bin /usr/ucb /usr/sysmg/bin /etc /usr/local/bin .)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;bath/sh Shell&lt;/span&gt; (Seperate by colon and use export command)&lt;br /&gt;export PATH=$PATH:/path/to/dir1:/path/to/dir2&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Permanently&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Bash Shell&lt;/span&gt; (Edit /.bash_profile or /.bash_profile files)&lt;br /&gt;&lt;a href="http://www.cyberciti.biz/faq/change-bash-profile/" target="_blank"&gt;http://www.cyberciti.biz/faq/change-bash-profile/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;tcsh/csh Shell&lt;/span&gt; (Edit /.login or /.cshrc files)&lt;br /&gt;&lt;a href="http://osr507doc.sco.com/en/OSUserG/_The_C-shell_login_and_cshrc.html" target="_blank"&gt;http://osr507doc.sco.com/en/OSUserG/_The_C-shell_login_and_cshrc.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;In both cases, you are simply adding the command into a login/shell startup script to that the variable is always set with the extra paths. To edit these files, I recommend using &lt;span style="font-weight:bold;"&gt;vi&lt;/span&gt; (text editor). &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;vi Help&lt;/span&gt;&lt;br /&gt;&lt;a href="http://www.dummies.com/how-to/content/using-the-vi-text-editor-in-solaris-9.html" target="_blank"&gt;vi in Solaris help&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.eng.hawaii.edu/Tutor/vi.html" target="_blank"&gt;vi in Unix help&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-8508315435757457158?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/8508315435757457158/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=8508315435757457158' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/8508315435757457158'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/8508315435757457158'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2012/01/updating-path-environment-variable-in.html' title='Bash/sh/csh/tcsh - Updating PATH environment variable in session and on logon'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-1717739789668148760</id><published>2012-01-17T03:56:00.000-08:00</published><updated>2012-01-17T03:58:31.332-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Unix'/><title type='text'>Transfer Files From One UNIX Server To Another using ssh scp</title><content type='html'>In Unix, you can use the scp command to copy files and directories securely between remote hosts without starting an FTP session or logging into the remote systems explicitly. The scp command uses SSH to transfer data, so it requires a password or passphrase for authentication. Unlike rcp or FTP, scp encrypts both the file and any passwords exchanged so that anyone snooping on the network can't view them.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Warning&lt;/span&gt;: Be careful when copying between hosts files that have the same names; you may accidently overwrite them.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;From Server to Local&lt;/span&gt;&lt;br /&gt;scp -r user@server1:/directory/files /localDirectory&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;From Local to Server&lt;/span&gt;&lt;br /&gt;scp -r /localDirectory user@server1:/directory/files&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-1717739789668148760?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/1717739789668148760/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=1717739789668148760' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/1717739789668148760'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/1717739789668148760'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2012/01/transfer-files-from-one-unix-server-to.html' title='Transfer Files From One UNIX Server To Another using ssh scp'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-3786984447413028508</id><published>2012-01-04T08:52:00.000-08:00</published><updated>2012-01-04T09:16:06.733-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SOAP'/><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><title type='text'>Python SUDS (SOAP API) full example with WSSE and complex types</title><content type='html'>I began this task in Perl originally, then decided to switch to Python and have an easier ride. I will upload the Perl example when I sort out a few minor issues with the SOAP::Lite library.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Anyway, in this example, you can specify a WSDL and WSSE (Web Service Security Extensions) username and password (sent in clear text btw), and it will send a SOAP request out and get a sample response back.&lt;br /&gt;&lt;br /&gt;I have purposely consumed a service that has some complex types available (basically not just strings and ints). You can see how it is to work with the library and consume your own methods with this example.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Here are some useful things to note&lt;/span&gt;&lt;br /&gt;- There have been problems with SUDS generating empty tags for optional properties for complex types. If this is the case, you will receive this error in your SOAP Body's response... "Server was unable to read request. ---&amp;gt; There is an error in the XML document. ---&amp;gt; Instance validation error: '' is not a valid value for PROPERTY_HERE."... To get around this, simply specify those properties (example below)&lt;br /&gt;&lt;br /&gt;- client.factory.create() is used to let Python know about the complex types.&lt;br /&gt;&lt;br /&gt;- "print client" (Using the example below) will tell you everything you need to know about your service (namespaces, types, methods, properties etc).&lt;br /&gt;&lt;br /&gt;- The logger is your friend! Don't be a hero! Start out small and go big! The technique is to analyze the SOAP response and query the errors. If you can get a hold of what the correct SOAP envelope should look like, then compare this against the SOAP request you are sending out. This is the easiest way to solve any problems.&lt;br /&gt;&lt;br /&gt;- Coming from a .NET background, I added a service reference and made a simple call with C#. You can then write more code to analyze the SOAP Request, or simply install Fiddler2 (If you haven't got it already, only 600kb and very useful!) to get the correct SOAP envelope to compare against.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;The code&lt;/span&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;br /&gt;&lt;span class="rem"&gt;#!/usr/bin/python&lt;/span&gt;&lt;br /&gt;&lt;span class="rem"&gt;#&lt;/span&gt;&lt;br /&gt;&lt;span class="rem"&gt;# Sean Greasley. TutorialGenius.com 2012.&lt;/span&gt;&lt;br /&gt;&lt;span class="rem"&gt;#&lt;/span&gt;&lt;br /&gt;&lt;span class="rem"&gt;# Creates a portfolio object using the exacttarget SOAP API. An image must exist at the specified URN&lt;/span&gt;&lt;br /&gt;&lt;span class="rem"&gt;# before alerting the system that the image is ready to be processed,&lt;/span&gt;&lt;br /&gt;&lt;span class="rem"&gt;#&lt;/span&gt;&lt;br /&gt;&lt;span class="rem"&gt;# USAGE:&lt;/span&gt;&lt;br /&gt;&lt;span class="rem"&gt;#    -portfolio &amp;lt;Display Name&amp;gt; &amp;lt;URN&amp;gt; &amp;lt;File Name&amp;gt; &amp;lt;Optional: CustomerKey&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="rem"&gt;#    -portfoliowsdl &amp;lt;WSDL Address&amp;gt; &amp;lt;WSSE Username&amp;gt; &amp;lt;WSSE Password&amp;gt; &amp;lt;Display Name&amp;gt; &amp;lt;URN&amp;gt; &amp;lt;File Name&amp;gt; &amp;lt;Optional: CustomerKey&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="rem"&gt;#&lt;/span&gt;&lt;br /&gt;&lt;span class="rem"&gt;#&lt;/span&gt;&lt;br /&gt;&lt;span class="rem"&gt;# Imports&lt;/span&gt;&lt;br /&gt;from suds.client import Client&lt;br /&gt;from suds.wsse import *&lt;br /&gt;&lt;br /&gt;&lt;span class="rem"&gt;# Logging Options&lt;/span&gt;&lt;br /&gt;import logging&lt;br /&gt;logging.basicConfig(level=logging.INFO)&lt;br /&gt;logging.getLogger(&lt;span class="str"&gt;'suds.client'&lt;/span&gt;).setLevel(logging.DEBUG)&lt;br /&gt;logging.getLogger(&lt;span class="str"&gt;'suds.wsdl'&lt;/span&gt;).setLevel(logging.DEBUG)&lt;br /&gt;logging.getLogger(&lt;span class="str"&gt;'suds.wsse'&lt;/span&gt;).setLevel(logging.DEBUG)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="rem"&gt;# Define usage options&lt;/span&gt;&lt;br /&gt;def printUsage():&lt;br /&gt;    print &lt;span class="str"&gt;""&lt;/span&gt;&lt;br /&gt;    print &lt;span class="str"&gt;"[USAGE]"&lt;/span&gt;&lt;br /&gt;    print &lt;span class="str"&gt;"------------------------------------------------------------------------"&lt;/span&gt;&lt;br /&gt;    print &lt;span class="str"&gt;"    "&lt;/span&gt; + sys.argv[0] + &lt;span class="str"&gt;" -portfolio &amp;lt;Display Name&amp;gt; &amp;lt;URN&amp;gt; &amp;lt;File Name&amp;gt; &amp;lt;Optional: CustomerKey&amp;gt;"&lt;/span&gt;&lt;br /&gt;    print &lt;span class="str"&gt;"    "&lt;/span&gt; + sys.argv[0] + &lt;span class="str"&gt;" -portfoliowsdl &amp;lt;WSDL Address&amp;gt; &amp;lt;WSSE Username&amp;gt; &amp;lt;WSSE Password&amp;gt; &amp;lt;Display Name&amp;gt; &amp;lt;URN&amp;gt; &amp;lt;File Name&amp;gt; &amp;lt;Optional: CustomerKey&amp;gt;"&lt;/span&gt;&lt;br /&gt;    print &lt;span class="str"&gt;""&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;return&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="rem"&gt;# Validate argument input&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;if&lt;/span&gt; (len(sys.argv) &amp;lt;= 1):&lt;br /&gt;    print &lt;span class="str"&gt;"Invalid usage options..."&lt;/span&gt;&lt;br /&gt;    printUsage()&lt;br /&gt;    sys.exit(1)&lt;br /&gt;elif (sys.argv[1] == &lt;span class="str"&gt;"-portfolio"&lt;/span&gt; and (len(sys.argv) == 5 or len(sys.argv) == 6)):&lt;br /&gt;    print &lt;span class="str"&gt;"Setting up a portfolio"&lt;/span&gt;&lt;br /&gt;elif (sys.argv[1] == &lt;span class="str"&gt;"-portfoliowsdl"&lt;/span&gt; and (len(sys.argv) == 8 or len(sys.argv) == 9)):&lt;br /&gt;    print &lt;span class="str"&gt;"Setting up a portfolio with WSDL options"&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;else&lt;/span&gt;:&lt;br /&gt;    print &lt;span class="str"&gt;"Invalid usage options..."&lt;/span&gt;&lt;br /&gt;    printUsage()&lt;br /&gt;    sys.exit(1)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="rem"&gt;# Setup variables&lt;/span&gt;&lt;br /&gt;WSDL_URL = &lt;span class="str"&gt;"https://webservice.s4.exacttarget.com/etframework.wsdl"&lt;/span&gt;&lt;br /&gt;WSSE_USERNAME = &lt;span class="str"&gt;"Username here!"&lt;/span&gt;&lt;br /&gt;WSSE_PASSWORD = &lt;span class="str"&gt;"Password here!"&lt;/span&gt;&lt;br /&gt;PORTFOLIO_DISPLAYNAME = &lt;span class="str"&gt;"Test Sean Display Name1"&lt;/span&gt;&lt;br /&gt;PORTFOLIO_URN = &lt;span class="str"&gt;"http://www.ct4me.net/images/dmbtest.gif"&lt;/span&gt;&lt;br /&gt;PORTFOLIO_FILENAME = &lt;span class="str"&gt;"dmbtest.gif"&lt;/span&gt;&lt;br /&gt;PORTFOLIO_CUSTOMERKEY = &lt;span class="str"&gt;""&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;if&lt;/span&gt; (sys.argv[1] == &lt;span class="str"&gt;"-portfoliowsdl"&lt;/span&gt;):&lt;br /&gt;    WSDL_URL = sys.argv[2]&lt;br /&gt;    WSSE_USERNAME = sys.argv[3]&lt;br /&gt;    WSSE_PASSWORD = sys.argv[4]&lt;br /&gt;    PORTFOLIO_DISPLAYNAME = sys.argv[5]&lt;br /&gt;    PORTFOLIO_URN = sys.argv[6]&lt;br /&gt;    PORTFOLIO_FILENAME = sys.argv[7]&lt;br /&gt;    &lt;br /&gt;    try:&lt;br /&gt;        PORTFOLIO_CUSTOMERKEY = sys.argv[8]&lt;br /&gt;    except:&lt;br /&gt;        print &lt;span class="str"&gt;"No Customer key specified. Using default..."&lt;/span&gt;&lt;br /&gt;elif (sys.argv[1] == &lt;span class="str"&gt;"-portfolio"&lt;/span&gt;):&lt;br /&gt;    PORTFOLIO_DISPLAYNAME = sys.argv[2]&lt;br /&gt;    PORTFOLIO_URN = sys.argv[3]&lt;br /&gt;    PORTFOLIO_FILENAME = sys.argv[4]&lt;br /&gt;    &lt;br /&gt;    try:&lt;br /&gt;        PORTFOLIO_CUSTOMERKEY = sys.argv[5]&lt;br /&gt;    except:&lt;br /&gt;        print &lt;span class="str"&gt;"No Customer key specified. Using default..."&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="rem"&gt;# URL Detail&lt;/span&gt;&lt;br /&gt;client = Client(WSDL_URL)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="rem"&gt;# WSSE Security&lt;/span&gt;&lt;br /&gt;security = Security()&lt;br /&gt;token = UsernameToken(WSSE_USERNAME, WSSE_PASSWORD)&lt;br /&gt;security.tokens.append(token)&lt;br /&gt;client.set_options(wsse=security)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="rem"&gt;# Build up portfolio&lt;/span&gt;&lt;br /&gt;&lt;span class="rem"&gt;# 'Portfolio' is a complex type... so we use the create method to expose the properties to us. We can then populate the properties as normal.&lt;/span&gt;&lt;br /&gt;portfolio = client.factory.create(&lt;span class="str"&gt;'Portfolio'&lt;/span&gt;)&lt;br /&gt;portfolio.DisplayName = PORTFOLIO_DISPLAYNAME&lt;br /&gt;portfolio.CustomerKey = PORTFOLIO_CUSTOMERKEY&lt;br /&gt;portfolio.Source = client.factory.create(&lt;span class="str"&gt;'ResourceSpecification'&lt;/span&gt;)&lt;br /&gt;portfolio.Source.URN = PORTFOLIO_URN&lt;br /&gt;portfolio.FileName = PORTFOLIO_FILENAME&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="rem"&gt;# For some reason the SUDS library tends to generate empty SOAP tags for optional properties. Here I have manually specified the defaults here. Just be aware of that! &lt;/span&gt;&lt;br /&gt;createOptions = client.factory.create(&lt;span class="str"&gt;'CreateOptions'&lt;/span&gt;)&lt;br /&gt;createOptions.RequestType = &lt;span class="str"&gt;"Synchronous"&lt;/span&gt;&lt;br /&gt;createOptions.QueuePriority= &lt;span class="str"&gt;"High"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="rem"&gt;# Attach Portfolio to array - Need to set at pos 0, as it returns 1 by default.&lt;/span&gt;&lt;br /&gt;apiObject = [client.factory.create(&lt;span class="str"&gt;'APIObject'&lt;/span&gt;)]  &lt;span class="rem"&gt;# Remember [ ], its an array!&lt;/span&gt;&lt;br /&gt;apiObject[0] = portfolio&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="rem"&gt;# Create portfolio&lt;/span&gt;&lt;br /&gt;&lt;span class="rem"&gt;# This method also had 'out' parameters exposed&lt;/span&gt;&lt;br /&gt;print client.service.Create(createOptions, apiObject)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="rem"&gt;# Uncomment this next line to find out useful information about your service.&lt;/span&gt;&lt;br /&gt;# print client&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-3786984447413028508?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/3786984447413028508/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=3786984447413028508' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/3786984447413028508'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/3786984447413028508'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2012/01/python-suds-soap-api-full-example-with.html' title='Python SUDS (SOAP API) full example with WSSE and complex types'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-3319983150488522939</id><published>2011-12-23T03:56:00.000-08:00</published><updated>2011-12-23T03:58:48.829-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SOAP'/><category scheme='http://www.blogger.com/atom/ns#' term='Web Testing'/><category scheme='http://www.blogger.com/atom/ns#' term='Web Services'/><title type='text'>WSDL and SOAP: Test and Invoke WSDL online!</title><content type='html'>Really good website for service discovery&lt;br /&gt;&lt;a href="http://www.service-repository.com/" target="_blank"&gt;http://www.service-repository.com&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;They also have a WSDL tester and invoker... displays the SOAP messages and response. It also builds the HTML forms dynamically. Great stuff!&lt;br /&gt;&lt;a href="http://www.service-repository.com/client/start" target="_blank"&gt;http://www.service-repository.com/client/start&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-3319983150488522939?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/3319983150488522939/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=3319983150488522939' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/3319983150488522939'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/3319983150488522939'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/12/wsdl-and-soap-test-and-invoke-wsdl.html' title='WSDL and SOAP: Test and Invoke WSDL online!'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-495550687325545311</id><published>2011-12-22T04:37:00.000-08:00</published><updated>2011-12-22T04:44:04.031-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Perl'/><category scheme='http://www.blogger.com/atom/ns#' term='Web Services'/><title type='text'>Perl: SOAP::Lite - 500 Can't connect to webservice.service.com:443 (Invalid argument) https</title><content type='html'>I had a problem recently with trying to call a HTTPS Web Service using Perl's SOAP::Lite library, and I was receiving this error "500 Can't connect to webservice.service.com:443 (Invalid argument)"...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Note&lt;/span&gt;: Port 443 ssl. This is the default port for HTTPS/SSL. This is the encrypted form of HTTP that normally runs over port 80.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Okay, so problem identified... Cannot communicate with service over 443... What next?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We use &lt;span style="font-weight:bold;"&gt;cpan&lt;/span&gt; to install another library called "Crypt::SSLeay"... sounds spooky! But don't worry, it simply provides support for the HTTPS protocol in LWP (Library for WWW in Perl).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;cpan&lt;/span&gt; - what the heck?  &lt;a href="http://tutorialgenius.blogspot.com/2011/12/perl-cant-locate-library-here-in-inc.html" target="_blank"&gt;View my previous post on cpan here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Simply issue this command, and cpan will do the rest...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;sudo perl -MCPAN -e "install Crypt::SSLeay"&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-495550687325545311?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/495550687325545311/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=495550687325545311' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/495550687325545311'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/495550687325545311'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/12/perl-soaplite-500-cant-connect-to.html' title='Perl: SOAP::Lite - 500 Can&apos;t connect to webservice.service.com:443 (Invalid argument) https'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-2958805194709208309</id><published>2011-12-22T04:03:00.001-08:00</published><updated>2011-12-22T04:12:41.616-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Perl'/><category scheme='http://www.blogger.com/atom/ns#' term='Web Services'/><title type='text'>Perl: SOAP::Lite Simple .NET Service Call</title><content type='html'>Ever wondered how to call a .NET web service using the SOAP::Lite library?&lt;br /&gt;I didn't think so, but just incase you did!....&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;#!/usr/bin/perl&lt;br /&gt;use SOAP::Lite 'trace', 'debug';   # adds debug and tracing to view SOAP msgs&lt;br /&gt;use SOAP::WSDL;&lt;br /&gt;use strict;&lt;br /&gt;use warnings;&lt;br /&gt;&lt;br /&gt;my $soap = SOAP::Lite&lt;br /&gt;    -&gt; uri('http://services.aonaware.com/webservices')&lt;br /&gt;    -&gt; on_action( sub {sprintf '%s/%s', @_} )&lt;br /&gt;    -&gt; proxy('http://services.aonaware.com/DictService/DictService.asmx');&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;print $soap-&gt;ServerInfo()-&gt;result;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Key Points to note&lt;/span&gt;&lt;br /&gt;1. Use the tracing and debugging options, this will tell you what is wrong (trust me, it will happen!)&lt;br /&gt;2. URI - This is a reference to the NAMESPACE.... Simple view your WSDL or ASMX service, and view the 'targetNamespace' attribute for the base node.... This references the namespace... This is required when making SOAP calls.&lt;br /&gt;3. PROXY - This is the actual URL to the service or WSDL.&lt;br /&gt;4. on_action - What to do when the action is raised.... similar to an event.... In the example, its simply printing the response. I am also manually printing the response in the code... so you will see output twice.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For reference, there is a really good post &lt;a href="http://www.robertprice.co.uk/robblog/archive/2005/11/Using_SOAP_Lite_With_Perl.shtml" target="_blank"&gt;here&lt;/a&gt; that troubleshoots these issues further.&lt;br /&gt;Microsoft also did a good post &lt;a href="http://msdn.microsoft.com/en-us/library/ms995764.aspx" target="_blank"&gt;here&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-2958805194709208309?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/2958805194709208309/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=2958805194709208309' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/2958805194709208309'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/2958805194709208309'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/12/perl-soaplite-simple-net-service-call.html' title='Perl: SOAP::Lite Simple .NET Service Call'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-518452690952102033</id><published>2011-12-22T02:27:00.000-08:00</published><updated>2011-12-22T02:54:56.113-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Perl'/><title type='text'>Perl: Can't locate [Library Here] in @INC - (CPAN Usage)</title><content type='html'>So i've been looking into Perl this week and I came across an error... quite simple when you know how... this post explains in !English! the options you can take to tackle this... CPAN is utilised and explained in this post.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;The Error&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;SeanMAC:tmp localhome$ perl test.pl&lt;br /&gt;Can't locate SOAP/Lite.pm in @INC (@INC contains: /Library/Perl/Updates/5.8.8/darwin-thread-multi-2level /Library/Perl/Updates/5.8.8 /System/Library/Perl/5.8.8/darwin-thread-multi-2level /System/Library/Perl/5.8.8 /Library/Perl/5.8.8/darwin-thread-multi-2level /Library/Perl/5.8.8 /Library/Perl /Network/Library/Perl/5.8.8/darwin-thread-multi-2level /Network/Library/Perl/5.8.8 /Network/Library/Perl /System/Library/Perl/Extras/5.8.8/darwin-thread-multi-2level /System/Library/Perl/Extras/5.8.8 /Library/Perl/5.8.6 /Library/Perl/5.8.1 .) at test.pl line 17.&lt;br /&gt;BEGIN failed--compilation aborted at test.pl line 17.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;So I created a test script and attempted to execute it. It threw up an error at Line 17 complaining that I didn't have the SOAP::Lite library. I.e. "Can't locate SOAP/Lite.pm"&lt;br /&gt;&lt;br /&gt;In .NET we would probably either Google the library or use NuGet (NuGet.org - NuGet is a Visual Studio extension that makes it easy to install and update open source libraries).&lt;br /&gt;&lt;br /&gt;If we would ever try to compare Perl to the .NET world, we could relate CPAN to NuGet in terms of what it does for us. That is, gets third party libraries, unpacks them and installs them for us.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;CPAN&lt;/span&gt;&lt;br /&gt;CPAN, the Comprehensive Perl Archive Network, is an archive of over 100,000 modules of software written in Perl, as well as documentation for it.&lt;br /&gt;&lt;br /&gt;To use cpan, open up a terminal or command window, and use the following command. This will run cpan as ROOT user. This is sometimes necessary as it requires access to shared library directories.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;perl -MCPAN -e 'shell'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You will then be in the cpan shell. Type 'h' for help....&lt;span style="font-weight:bold"&gt;&lt;br /&gt;&lt;table&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;command&lt;/td&gt;&lt;td&gt;argument&lt;/td&gt;&lt;td&gt;description&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt; a,b,d,m&lt;/td&gt;&lt;td&gt;WORD or /REGEXP/ &lt;/td&gt;&lt;td&gt;about authors, bundles, distributions, modules&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;i&lt;/td&gt;&lt;td&gt;WORD or /REGEXP/ &lt;/td&gt;&lt;td&gt;about anything of above&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;r&lt;/td&gt;&lt;td&gt;NONE&lt;/td&gt;&lt;td&gt;reinstall recommendations&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;ls&lt;/td&gt;&lt;td&gt;AUTHOR&lt;/td&gt;&lt;td&gt;about files in the author's directory&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;get&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;download&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;make&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;make (implies get)&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;test&lt;/td&gt;&lt;td&gt;MODULES&lt;/td&gt;&lt;td&gt;make test (implies make)&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;install&lt;/td&gt;&lt;td&gt;DISTS, BUNDLES&lt;/td&gt;&lt;td&gt;make install (implies test)&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;clean&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;make clean&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;look&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;open subshell in these dists' directories&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;readme&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;display these dists' README files&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;/table&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If we wish to install our library (This includes get/download, make, test and install) then we simply issue the command....&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;install [Library Name]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;with example&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;install SOAP::Lite&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You will be asked a few options, mostly regarding ideal location to download from, connection timeouts etc... You can simply keep hitting enter to use the defaults.&lt;br /&gt;&lt;br /&gt;If all is successful, your library will be installed and included within the @INC array (Containing paths to libraries used by Perl).&lt;br /&gt;&lt;br /&gt;Happy Scripting!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-518452690952102033?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/518452690952102033/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=518452690952102033' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/518452690952102033'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/518452690952102033'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/12/perl-cant-locate-library-here-in-inc.html' title='Perl: Can&apos;t locate [Library Here] in @INC - (CPAN Usage)'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-9212475156654505678</id><published>2011-12-09T07:58:00.000-08:00</published><updated>2012-01-20T01:14:31.373-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iOS'/><title type='text'>iOS - Viewing hidden files and directories</title><content type='html'>Write the following into a terminal window....&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;defaults write com.apple.finder AppleShowAllFiles TRUE&lt;br /&gt;killall Finder&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This will show you all of the hidden files and folders on your operating system. If you want to reverse the command replace TRUE with FALSE.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-9212475156654505678?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/9212475156654505678/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=9212475156654505678' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/9212475156654505678'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/9212475156654505678'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/12/viewing-hidden-files-and-directories.html' title='iOS - Viewing hidden files and directories'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-6645973543627385340</id><published>2011-11-12T05:30:00.000-08:00</published><updated>2011-11-12T05:31:34.210-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Web Services'/><title type='text'>REST Web Services</title><content type='html'>&lt;a href="http://www.xfront.com/REST-Web-Services.html" target="_blank"&gt;Good article on RESTful Web Service Architecture&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-6645973543627385340?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/6645973543627385340/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=6645973543627385340' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/6645973543627385340'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/6645973543627385340'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/11/rest-web-services.html' title='REST Web Services'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-1301784962739786841</id><published>2011-11-09T10:15:00.000-08:00</published><updated>2011-11-09T10:16:20.165-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='LinqToSQL'/><category scheme='http://www.blogger.com/atom/ns#' term='Entity Framework'/><title type='text'>LINQ to SQL vs. ADO.NET Entity Framework</title><content type='html'>LINQ to SQL and the Entity Framework have a lot in common, but each have features targeting different scenarios in the Orcas timeframe.&lt;br /&gt;&lt;br /&gt;LINQ to SQL has features targeting “Rapid Development” against a Microsoft SQL Server database. Think of LINQ to SQL as allowing you to have a strongly-typed view of your existing database schema. LINQ to SQL supports a direct, 1:1 mapping of your existing database schema to classes; a single table can be mapped to a single inheritance hierarchy (i.e. , a table can contain persons, customers, and employees) and foreign keys can be exposed as strongly-typed relationships.  You can build LINQ queries over tables/views/table valued functions and return results as strongly typed objects, and call stored procedures that return strongly typed results through strongly typed methods.&lt;br /&gt;&lt;br /&gt;A key design principle of LINQ to SQL is that it “just work” for the common cases; so, for example, if you access a collection of orders through the Orders property of a customer, and that customer’s orders have not previously been retrieved, LINQ to SQL will automatically get them for you.&lt;br /&gt;&lt;br /&gt;LINQ to SQL relies on convention, for example default insert, update, and delete logic through generated DML can be overwritten by exposing appropriately named methods (for example, “InsertCustomer“, “UpdateCustomer“, “DeleteCustomer“).  These methods may invoke stored procedures or perform other logic in order to process changes.&lt;br /&gt;&lt;br /&gt;The Entity Framework has features targeting “Enterprise Scenarios“.  In an enterprise, the database is typically controlled by a DBA, the schema is generally optimized for storage considerations (performance, consistency, partitioning) rather than exposing a good application model, and may change over time as usage data and usage patterns evolve.  With this in mind, the Entity Framework is designed around exposing an application-oriented data model that is loosely coupled, and may differ significantly, from your existing database schema.  For example, you can map a single class (or “entity”) to multiple tables/views, or map multiple classes to the same table/view. You can map an inheritance hierarchy to a single table/view (as&lt;br /&gt;in LINQ to SQL) or to multiple tables/views (for example, persons, customers, and employees could each be separate tables, where customers and employees contain only the additional columns not present in persons, or repeat the columns from the persons table).  You can group properties into complex (or “composite”) types (for example, a Customer type may have an “Address” property that is an Address type with Street, City, Region, Country and Postal code properties).&lt;br /&gt;&lt;br /&gt;The Entity Framework lets you optionally represent many:many relationships directly, without representing the join table as an entity in your data model, and has a new feature called “Defining Query” that lets you expose any native query against the store as a “table” that can be mapped just as any other table (except that updates must be performed through stored procedures).  This flexible mapping, including the option to use stored procedures to process changes, is specified declaratively in order to account for the schema of the database evolving over time without having to recompile the application.&lt;br /&gt;&lt;br /&gt;The Entity Framework includes LINQ to Entities which exposes many of the same features as LINQ to SQL over your conceptual application data model; you can build queries in LINQ (or in “Entity SQL”, a canonical version of SQL extended to support concepts like strong typing, polymorphism, relationship navigation and complex types), return results as strongly typed CLR objects, execute stored procedures or table valued functions through strongly-typed methods, and process changes by calling a single save method.&lt;br /&gt;&lt;br /&gt;However, the Entity Framework is more than LINQ to Entities; it includes a “Storage Layer” that lets you use the same conceptual application model through low-level ADO.NET Data Provider interfaces using Entity SQL, and efficiently stream results as possibly hierarchical/polymorphic DataReaders, saving the overhead of materializing objects for read-only scenarios where there is no additional business logic.&lt;br /&gt;&lt;br /&gt;The Entity Framework works with Microsoft SQL Server and 3rd party databases through extended ADO.NET Data Providers, providing a common query language against different relational databases through either LINQ to Entities or Entity SQL.&lt;br /&gt;&lt;br /&gt;So while there is a lot of overlap, LINQ to SQL is targeted more toward rapidly developing applications against your existing Microsoft SQL Server schema, while the Entity Framework provides object- and storage-layer access to Microsoft SQL Server and 3rd party databases through a loosely coupled, flexible mapping to existing relational schema.&lt;br /&gt;&lt;br /&gt;I know this is a confusing area, and we’re trying to figure out how best to describe these differences to help customers make the appropriate choices.  Please let me know if this helps, or if there are still areas of confusion…&lt;br /&gt;&lt;br /&gt;Thanks,&lt;br /&gt;Michael Pizzo&lt;br /&gt;Principal Architect&lt;br /&gt;Microsoft Data Programmability&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-1301784962739786841?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/1301784962739786841/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=1301784962739786841' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/1301784962739786841'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/1301784962739786841'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/11/linq-to-sql-vs-adonet-entity-framework.html' title='LINQ to SQL vs. ADO.NET Entity Framework'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-1150894680069386183</id><published>2011-10-25T02:55:00.000-07:00</published><updated>2011-10-25T02:58:53.398-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>I want SQL Management Studio Express (The GUI!!) After installing VS 2010</title><content type='html'>So I re-installed VS 2010 the other day and as usual, it installs about 50 versions of SQL Server with it (urgh!)... after seeing copious amount of SQL Server names in "Add/Remove Programs", I still didn't have the nice GUI to work with (SQL Management Studio Express)... gees!&lt;br /&gt;&lt;br /&gt;So I found a link where a few people have had the same issue,  &lt;a href="http://www.codefrenzy.net/2011/06/03/how-to-install-sql-server-2008-management-studio/" target="_blank"&gt;check it here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;If anybody knows of a minimal version or a better suggestion, please comment!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-1150894680069386183?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/1150894680069386183/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=1150894680069386183' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/1150894680069386183'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/1150894680069386183'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/10/i-want-sql-management-studio-express.html' title='I want SQL Management Studio Express (The GUI!!) After installing VS 2010'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-3514978478401625297</id><published>2011-10-18T15:20:00.000-07:00</published><updated>2011-10-18T16:04:51.982-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone'/><title type='text'>How To: Unlock and Activate iPhone on iOS 5 [teathered]</title><content type='html'>So i spent some time the other day trying to unlock and activate an iPhone 3GS (also works for other models and iPad)... So rather than letting this be forgotten forever (because it took a while!) I'd thought i'd make a blog about my findings.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Preliminaries&lt;/span&gt;&lt;br /&gt;- Latest version of iTunes&lt;br /&gt;- &lt;a href="http://www.idownloadblog.com/iphone-downloads/"&gt;Redsn0w&lt;/a&gt; [&lt;a href="http://www.theiphonewiki.com/wiki/index.php?title=Redsn0w"&gt;Which version?&lt;/a&gt;]&lt;br /&gt;- &lt;a href="http://thefirmwareumbrella.blogspot.com/"&gt;Tiny Umbrella&lt;/a&gt; (Used to find out the firmware version)&lt;br /&gt;- The Target Firmware [&lt;a href="http://www.felixbruns.de/iPod/firmware/"&gt;Files here&lt;/a&gt;]&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;!!Things to note!!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Teathered vs. Unteathered?&lt;/span&gt;&lt;br /&gt;This simply means, weather you need a computer to start your phone. If a release of redsn0w offers a Teathered solution, then &lt;span style="font-style:italic;"&gt;!everytime!&lt;/span&gt; your phone turns off (out of battery, new app install etc.) you will need to plug it into your computer and use redsn0w to boot the phone! The batteries are pretty decent, so you probably don't even care or it's no big deal.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Which firmware shall I get?&lt;/span&gt;&lt;br /&gt;Currently, if you want an UNTEATHERED solution (basically the phone can boot by itself) then firmware 4.3.3 is what you need. Currently there is no unteathered solution for the latest firmware (including: 4.3.4, 4.3.5 and 5).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;I want UNTEATHERED, but, I have later than 4.3.3 on my iPhone!?&lt;/span&gt;&lt;br /&gt;Most website will tell you that you need SHSH Blobs in order to do this. If you don't know what they are or you didn't upgrade your iPhone before, chances are you won;t have them.&lt;br /&gt;Apparently there IS  solution to do this, I have not tried it personally. You can &lt;a href="http://www.limera1n.cc/2011/08/downgrade-435-to-433-without-shsh-blobs.html"&gt;find it here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;OK enough preliminaries, lets do it!....&lt;br /&gt;&lt;br /&gt;1. Ok this guide is for iOS 5 and TEATHERED, so lets get iOS 5 on the iPhone. If your not sure weather you have it already, connect the iPhone to the computer and open TinyUmbrella. This will tell you your current firmware version. If you already have iOS 5, skip steps 3-5.&lt;br /&gt;&lt;br /&gt;2. Put iPhone in DFU mode &lt;a href="http://www.youtube.com/watch?v=ofpinyGlQ8I"&gt;HOWTO VIDEO HERE&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;3. Connect iPhone to computer, and use 'Restore', this will prompt you to install the latest firmware (iOS 5).&lt;br /&gt;&lt;br /&gt;4. You now have the latest and greatest firmware!&lt;br /&gt;&lt;br /&gt;5. Ok, now, lets jailbreak.... download firmware for iOS 5 (links above or &lt;a href="http://www.felixbruns.de/iPod/firmware/"&gt;here&lt;/a&gt;). If you already did an update through iTunes, this will already be in your downloaded directory. See below to find this...&lt;br /&gt;&lt;br /&gt;On Windows XP :&lt;br /&gt;Documents and Settings\&lt;User&gt;\Application Data\Apple Computer\iTunes\iPhone Software Updates&lt;br /&gt;&lt;br /&gt;On Windows Vista/Windows 7:&lt;br /&gt;Users\&lt;User&gt;\AppData\Roaming\Apple Computer\iTunes\iPhone Software Updates&lt;br /&gt;&lt;br /&gt;On Mac:&lt;br /&gt;~/Library/iTunes/iPhone Software Updates&lt;br /&gt;&lt;br /&gt;6. Now you have the firmware handy, open redsn0w for your current firmware version. Currently, 0.9.9b4 for windows or 0.9.9b5 for mac.&lt;br /&gt;&lt;br /&gt;7. Click extras and specify firmware manually. Point to the iOS 5 firmware (*.ispw).&lt;br /&gt;&lt;br /&gt;8. Go back and hit the jailbreak button. Select 'Install Cydia', continue to next dialog which will ask you to put the phone into DFU mode. &lt;a href="http://www.youtube.com/watch?v=ofpinyGlQ8I"&gt;HOWTO VIDEO HERE&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;9. Redsn0w will do all its business, don't touch the iPhone until it finishes, it stops on the spinner (which has probably stopped spinning).&lt;br /&gt;&lt;br /&gt;10. Ok the jailbreak is done, but like I said, its teathered. So open redsn0w, click extras, and we just want to boot the iPhone. Click the button, and prepare to enter DFU mode again. This is a bit trickier with a phone that won't turn off.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Note:&lt;/span&gt; If your jailbreak left you on the crashed spinner, don't worry its fine. Simply hold the power and home buttons for 10secs until the phone does a hard reset. Once the phone resets, proceed with the DFU instructions!&lt;br /&gt;&lt;br /&gt;11. Ok you should see a pineapple logo on the iPhone if done correctly, and the iPhone will boot up. You should be able to use the iPhone to its full extent, unless you need to unlock your iPhone to any network, then only your calls will not work. If you need to unlock as well, follow the rest of this guide....&lt;br /&gt;&lt;br /&gt;12. Next step (for the unlock), you need a WIFI connection! It'll probably say 'No Service' in the top left corner.&lt;br /&gt;&lt;br /&gt;13. Open Cydia (now on dashboard) and search for ultrasn0w. Download and install this and it will ask you to reboot when you are done. (Don't forget you need to boot using redsn0w as its teathered!)&lt;br /&gt;&lt;br /&gt;14. When you re-boot, your iPhone should is unlocked and ready to party!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;OK i've done all of this, but still 'No Service'!?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1. Ok first, disabled 3G (general settings &gt; Network &gt; Enable 3G)&lt;br /&gt;2. Toggle airplane mode (this will refresh the signal).&lt;br /&gt;&lt;br /&gt;If this does not work, then you may need to update your base band (basically a firmware update for your inbuilt modem). We will update this to match the iPad's baseband (currently v06.15.00), works just as well. &lt;a href="http://www.idownloadblog.com/2010/12/03/warning-updating-your-iphone-baseband-to-06-15-00-may-cause-gps-issues/"&gt;There are somethings you should be aware of before doing this though!!&lt;/a&gt; - Personally, I needed to do this myself!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;OK i've decided to update my base band, how do I do this?!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1. First, double check you actually don't already have v06. (Settings &gt; General &gt; About &gt; Modem Firmware).&lt;br /&gt;2. Re-run the jailbreak process again, but when you check 'Install Cydia', also check 'Install iPad base band'... this will do the jailbreak, but also update your modem firmware.&lt;br /&gt;3. Check on iPhone that the modem firmware was updated to v06.&lt;br /&gt;4. Repeat the process above to unlock the phone with ultrasn0w.&lt;br /&gt;5. Awesome!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;OK I DON'T WANT THIS JAILBREAK STUFF ANYMORE, HELP!?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1. Plug into Computer via. USB.&lt;br /&gt;2. Put phone in DFU mode.&lt;br /&gt;3. Click 'Restore' in iTunes.&lt;br /&gt;4. Sorted!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-3514978478401625297?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/3514978478401625297/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=3514978478401625297' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/3514978478401625297'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/3514978478401625297'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/10/how-to-unlock-and-activate-iphone-on.html' title='How To: Unlock and Activate iPhone on iOS 5 [teathered]'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-9176847928234670540</id><published>2011-07-28T09:02:00.000-07:00</published><updated>2011-07-28T09:13:43.012-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MVC'/><title type='text'>MVC3/Razor - Global Error Handling</title><content type='html'>Here is a technique you can use within your MVC application to control global error handling. The technique is quite similar to aspx pages where you populate the Application_Error function within &lt;span style="font-weight:bold;"&gt;Global.asax&lt;/span&gt;, however, the routing is completely new!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Global.asax&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;/// Handle application error on a global level.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;/// Passes handling off to the ErrorController&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Application_Error()&lt;/pre&gt;&lt;pre&gt;{&lt;/pre&gt;&lt;pre class="alt"&gt;    var exception = Server.GetLastError();&lt;/pre&gt;&lt;pre&gt;    var httpException = exception &lt;span class="kwrd"&gt;as&lt;/span&gt; HttpException;&lt;/pre&gt;&lt;pre class="alt"&gt;    Response.Clear();&lt;/pre&gt;&lt;pre&gt;    Server.ClearError();&lt;/pre&gt;&lt;pre class="alt"&gt;    var routeData = &lt;span class="kwrd"&gt;new&lt;/span&gt; RouteData();&lt;/pre&gt;&lt;pre&gt;    routeData.Values[&lt;span class="str"&gt;"controller"&lt;/span&gt;] = &lt;span class="str"&gt;"Errors"&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;    routeData.Values[&lt;span class="str"&gt;"action"&lt;/span&gt;] = &lt;span class="str"&gt;"General"&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;    routeData.Values[&lt;span class="str"&gt;"exception"&lt;/span&gt;] = exception;&lt;/pre&gt;&lt;pre class="alt"&gt;    Response.StatusCode = 500;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;if&lt;/span&gt; (httpException != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre class="alt"&gt;    {&lt;/pre&gt;&lt;pre&gt;        Response.StatusCode = httpException.GetHttpCode();&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;switch&lt;/span&gt; (Response.StatusCode)&lt;/pre&gt;&lt;pre&gt;        {&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;case&lt;/span&gt; 403:&lt;/pre&gt;&lt;pre&gt;                routeData.Values[&lt;span class="str"&gt;"action"&lt;/span&gt;] = &lt;span class="str"&gt;"Http403"&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;case&lt;/span&gt; 404:&lt;/pre&gt;&lt;pre class="alt"&gt;                routeData.Values[&lt;span class="str"&gt;"action"&lt;/span&gt;] = &lt;span class="str"&gt;"Http404"&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;                &lt;span class="kwrd"&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;        }&lt;/pre&gt;&lt;pre&gt;    }&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;    IController errorsController = &lt;span class="kwrd"&gt;new&lt;/span&gt; ErrorController();&lt;/pre&gt;&lt;pre class="alt"&gt;    var rc = &lt;span class="kwrd"&gt;new&lt;/span&gt; RequestContext(&lt;span class="kwrd"&gt;new&lt;/span&gt; HttpContextWrapper(Context), routeData);&lt;/pre&gt;&lt;pre&gt;    errorsController.Execute(rc);&lt;/pre&gt;&lt;pre class="alt"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Note&lt;/span&gt;: This will route our errors to the ErrorController. Lets take a look at the error controller...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;ErrorController.cs&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;// &amp;lt;copyright file="ErrorController.cs" company="GinkoSolutions.com"&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;// Copyright (c) 2011 All Right Reserved&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;// &amp;lt;/copyright&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;// &amp;lt;author&amp;gt;Sean Greasley&amp;lt;/author&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;// &amp;lt;email&amp;gt;sean@ginkosolutions.com/sean@tutorialgenius.com&amp;lt;/email&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;// &amp;lt;summary&amp;gt;Controller for handling errors within the application.&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; MVCEmailExample.Controllers&lt;/pre&gt;&lt;pre&gt;{&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Linq;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Web;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Web.Mvc;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; MVCEmailExample.Models;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// Controller for handling errors within the application.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ErrorController : Controller&lt;/pre&gt;&lt;pre&gt;    {&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; ActionResult General(Exception exception)&lt;/pre&gt;&lt;pre&gt;        {&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; View(&lt;span class="str"&gt;"Error"&lt;/span&gt;, &lt;span class="kwrd"&gt;new&lt;/span&gt; ErrorModel() { ErrorTitle = &lt;span class="str"&gt;"General Error"&lt;/span&gt;, ExceptionDetail = exception });&lt;/pre&gt;&lt;pre&gt;        }&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; ActionResult Http404()&lt;/pre&gt;&lt;pre class="alt"&gt;        {&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; View(&lt;span class="str"&gt;"Error"&lt;/span&gt;, &lt;span class="kwrd"&gt;new&lt;/span&gt; ErrorModel() { ErrorTitle = &lt;span class="str"&gt;"Not found"&lt;/span&gt; });&lt;/pre&gt;&lt;pre class="alt"&gt;        }&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; ActionResult Http403()&lt;/pre&gt;&lt;pre&gt;        {&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; View(&lt;span class="str"&gt;"Error"&lt;/span&gt;, &lt;span class="kwrd"&gt;new&lt;/span&gt; ErrorModel() { ErrorTitle = &lt;span class="str"&gt;"Forbidden"&lt;/span&gt; });&lt;/pre&gt;&lt;pre&gt;        }&lt;/pre&gt;&lt;pre class="alt"&gt;    }&lt;/pre&gt;&lt;pre&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;So now were handling our errors and throwing them out to the &lt;span style="font-weight:bold;"&gt;Error&lt;/span&gt; View (in Views/Shared!). However, were now using a strongly typed view and passing a custom class into it. This custom class contains details of our error!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;ErrorModel.cs (Our custom error class!)&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Linq;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Web;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; MVCEmailExample.Models&lt;/pre&gt;&lt;pre class="alt"&gt;{&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ErrorModel&lt;/pre&gt;&lt;pre class="alt"&gt;    {&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; ErrorTitle { get; set; }&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; Exception ExceptionDetail { get; set; }&lt;/pre&gt;&lt;pre&gt;    }&lt;/pre&gt;&lt;pre class="alt"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Very simple! All it does it holds information really.&lt;br /&gt;Now lets take a look at our error view...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Error View (This will already exist with a new MVC3 application) P.s. I'm using Razor syntax!&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;@using MVCEmailExample.Models&lt;/pre&gt;&lt;pre&gt;@model ErrorModel&lt;/pre&gt;&lt;pre class="alt"&gt;@{&lt;/pre&gt;&lt;pre&gt;    Layout = "~/Views/Shared/_Layout.cshtml";&lt;/pre&gt;&lt;pre class="alt"&gt;}&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;h2&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;@Model.ErrorTitle&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;h2&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;Sorry, an error occurred while processing your request.&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;br&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;@if (Model.ExceptionDetail != null)&lt;/pre&gt;&lt;pre class="alt"&gt;{&lt;/pre&gt;&lt;pre&gt;      @Model.ExceptionDetail.Message&lt;/pre&gt;&lt;pre class="alt"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;This is our strongly typed view (Hint: @model ErrorModel). We simply extract the error info here and display it in a very (unstylish) form!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This sample below is for a sample email application. This uses the code described above. Just hit the button without entering any information and (assuming you don't have  local mail server) u'll see some errors appearing!&lt;br /&gt;&lt;br /&gt;&lt;a href="https://doc-0g-6g-docsviewer.googleusercontent.com/viewer/securedownload/93c8vioplh2aqm4afrc7j9k14bhhi26p/pup1k479iqk4r3g9d3t8dnvp7pcjdd6s/1311867900000/ZXhwbG9yZXI=/AGZ5hq8lCFHJDWK-wjlX5a0vRY5g/MEI2U2ZNQXc2dGZwUk4yWXpOVFl3TjJVdE9HRTVOUzAwWVRZM0xUaGpaVFl0TlRZM1pEa3dOamRtWm1Waw==?a=dl&amp;filename=%5BMVC3%5D+HTML+Email+with+linked+resources+Example.zip&amp;sec=AHSqidYSkZ3x96cnYT42xRCVfgjXmD7IhN6-Yp9lsHcMpzUgRcJc9CfCOl45j04nq7YSpmzrTj7RttMXjIGDRAS4X0W5pKzbQ8bfNj2CbQkVKrbJ6Nqum8DKjjjfrRiodQ3fCMnBstuL67B85mt_Nk_d7WfbUC0iLRYk60w0vYBHuZAqO9WL8SIguo0UoeTlcFWTA8GbBwwW9PijvpFdgerLS3uL0vGf0jtPKWB0GqzfF91rbpPJWoid-LYutW4z_vHd2J0MVzKM7lzmP9-AbsIh-P7pxld-NG2H2hMrQjisp6RWUbIiAKDJqGuvA3NN-nkxXgjXzr60iK72GAVyD7xlcllRqWieluI2XfmbrJvo-lTkQDbAqPZpd-Up4At8RQKDA0cJs1nlXPt59Ui6aQUZMzQdp9U4om3bJk6XeI-tl0pYmmnxaXZATpYfSsAQ2CFjVPhNkSLn&amp;nonce=i7dkhg0vgcaik&amp;user=AGZ5hq8lCFHJDWK-wjlX5a0vRY5g&amp;hash=9kl716p5ao7hsm8c8plvi6bkt85dj46h" target="_blank"&gt;MVC3 Razor - Global Error Handling&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-9176847928234670540?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/9176847928234670540/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=9176847928234670540' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/9176847928234670540'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/9176847928234670540'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/07/mvc3razor-global-error-handling.html' title='MVC3/Razor - Global Error Handling'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-953074341697748584</id><published>2011-07-28T08:23:00.001-07:00</published><updated>2011-07-28T09:12:36.644-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MVC'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>C# - Sending HTML Email template with linked resources and plain text fallback</title><content type='html'>Hi all,&lt;br /&gt;&lt;br /&gt;If your reading this, then chances are you've looked how to create a simple email with C# and added some HTML in there. You might have then looked for including images and the documentation on the internet for this is kinda poor/bad/doesn't work. Well here's how!!&lt;br /&gt;&lt;br /&gt;In this example, I have created a class library that can be used with any C# application. So it doesn't matter what kinda application you have (MVC, ASPX Web App, Client App, Command Line etc...).&lt;br /&gt;&lt;br /&gt;Lets let on with it!! I've created this project in .NET 4.0 at time of writing and included a VS2010 MVC3 Web App with it for full example. I have also included some global MVC3 error handling!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Class Library&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;// &amp;lt;copyright file="EmailHelper.cs" company="GinkoSolutions.com"&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;// Copyright (c) 2011 All Right Reserved&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;// &amp;lt;/copyright&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;// &amp;lt;author&amp;gt;Sean Greasley&amp;lt;/author&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;// &amp;lt;email&amp;gt;sean@ginkosolutions.com/sean@tutorialgenius.com&amp;lt;/email&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;// &amp;lt;summary&amp;gt;Email helper class. Allows sending of html and plain text emails to a target email address.&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; MVCEmailExample.Helpers&lt;/pre&gt;&lt;pre&gt;{&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Specialized;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Configuration;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Linq;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Net.Mail;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Net.Mime;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Web;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Web.UI;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Web.UI.WebControls;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; MVCEmailExample.Exceptions;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; MVCEmailExample.Models;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// Email helper class.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// Allows sending of html and plain text emails to a target email address.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; EmailHelper&lt;/pre&gt;&lt;pre class="alt"&gt;    {&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// Sends an email to a recipient. Provides HTML and plain text views.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// The recipient will receive which one their client supports.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="templateDir"&amp;gt;Directory of where the HTML email template is stored.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="recipient"&amp;gt;Receipient information&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SendEmail(&lt;span class="kwrd"&gt;string&lt;/span&gt; templateDir, Recipient recipient)&lt;/pre&gt;&lt;pre class="alt"&gt;        {&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;try&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            {&lt;/pre&gt;&lt;pre&gt;                &lt;span class="rem"&gt;// Build message&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                MailMessage message = &lt;span class="kwrd"&gt;new&lt;/span&gt; MailMessage();&lt;/pre&gt;&lt;pre&gt;                message.To.Add(&lt;span class="kwrd"&gt;new&lt;/span&gt; MailAddress(recipient.Email));&lt;/pre&gt;&lt;pre class="alt"&gt;                message.Subject = ConfigurationManager.AppSettings[&lt;span class="str"&gt;"EmailSubject"&lt;/span&gt;];&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="rem"&gt;// Create plain text mode for alternative view&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                AlternateView plainView = AlternateView.CreateAlternateViewFromString(ConfigurationManager.AppSettings[&lt;span class="str"&gt;"PlainTextEmail"&lt;/span&gt;], &lt;span class="kwrd"&gt;null&lt;/span&gt;, &lt;span class="str"&gt;"text/plain"&lt;/span&gt;);&lt;/pre&gt;&lt;pre class="alt"&gt;                message.AlternateViews.Add(plainView);&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="rem"&gt;// Create HTML email version&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                MailDefinition mailDef = &lt;span class="kwrd"&gt;new&lt;/span&gt; MailDefinition();&lt;/pre&gt;&lt;pre class="alt"&gt;                mailDef.BodyFileName = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;@"{0}\{1}"&lt;/span&gt;, templateDir, &lt;span class="str"&gt;@"Email.html"&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;                mailDef.IsBodyHtml = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;                mailDef.Subject = ConfigurationManager.AppSettings[&lt;span class="str"&gt;"EmailSubject"&lt;/span&gt;];&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="rem"&gt;// Build replacement collection to replace fields in Email.htm file&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                &lt;span class="rem"&gt;// Use fields anywhere in the template file. I.e.   &amp;lt;%FRIENDNAME%&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                ListDictionary replacements = &lt;span class="kwrd"&gt;new&lt;/span&gt; ListDictionary();&lt;/pre&gt;&lt;pre&gt;                replacements.Add(&lt;span class="str"&gt;"&amp;lt;%NAME%&amp;gt;"&lt;/span&gt;, recipient.Name);&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;                &lt;span class="rem"&gt;// Use dummy control as owner (I.e. new System.Web.UI.Control()) as were in a class library.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="rem"&gt;// It's only use to determine where the access templates from as a relative base.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                MailMessage msgHtml = mailDef.CreateMailMessage(recipient.Email, replacements, &lt;span class="kwrd"&gt;new&lt;/span&gt; System.Web.UI.Control());&lt;/pre&gt;&lt;pre class="alt"&gt;                AlternateView htmlView = AlternateView.CreateAlternateViewFromString(msgHtml.Body, &lt;span class="kwrd"&gt;null&lt;/span&gt;, &lt;span class="str"&gt;"text/html"&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="rem"&gt;// Add linked resources&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                AddLinkedResources(templateDir, &lt;span class="kwrd"&gt;ref&lt;/span&gt; htmlView);&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;/pre&gt;&lt;pre&gt;                &lt;span class="rem"&gt;// Add HTML view&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                message.AlternateViews.Add(htmlView);&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="rem"&gt;// Send message&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                SmtpClient client = &lt;span class="kwrd"&gt;new&lt;/span&gt; SmtpClient();&lt;/pre&gt;&lt;pre class="alt"&gt;                client.Send(message);&lt;/pre&gt;&lt;pre&gt;            }&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;catch&lt;/span&gt; (Exception mailEx) { &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; MailerException(&lt;span class="str"&gt;"Error sending email."&lt;/span&gt;, mailEx); }&lt;/pre&gt;&lt;pre&gt;        }&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// Adds linked resources to the email&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// Email template must contain the resource IDs in the following format: &amp;lt;img src="cid:CONTENTID" /&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="templateDir"&amp;gt;Directory of where the HTML email template images are stored.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="htmlView"&amp;gt;A reference to the HTML view.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; AddLinkedResources(&lt;span class="kwrd"&gt;string&lt;/span&gt; templateDir, &lt;span class="kwrd"&gt;ref&lt;/span&gt; AlternateView htmlView)&lt;/pre&gt;&lt;pre class="alt"&gt;        {&lt;/pre&gt;&lt;pre&gt;            LinkedResource logo1 = &lt;span class="kwrd"&gt;new&lt;/span&gt; LinkedResource(&lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;@"{0}\{1}"&lt;/span&gt;, templateDir, &lt;span class="str"&gt;@"Images\email.jpg"&lt;/span&gt;), MediaTypeNames.Image.Jpeg);&lt;/pre&gt;&lt;pre class="alt"&gt;            logo1.ContentId = &lt;span class="str"&gt;"email"&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;            htmlView.LinkedResources.Add(logo1);&lt;/pre&gt;&lt;pre class="alt"&gt;        }&lt;/pre&gt;&lt;pre&gt;    }&lt;/pre&gt;&lt;pre class="alt"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Note&lt;/span&gt;: This will attempt to send a HTML email with an embedded image (linked resource). If the client does not support HTML, then a plain text email will be used as backup. boom! (I've defined this in the application settings, as well as the email subject and "from" email address).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Configuration - App Settings (Optional, just didn't want to hard code them) [Web/App.config]&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;appSettings&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;&amp;lt;!-- Email App Settings --&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;add&lt;/span&gt; &lt;span class="attr"&gt;key&lt;/span&gt;&lt;span class="kwrd"&gt;="EmailSubject"&lt;/span&gt; &lt;span class="attr"&gt;value&lt;/span&gt;&lt;span class="kwrd"&gt;="GinkoSolutions.com Email Example"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;add&lt;/span&gt; &lt;span class="attr"&gt;key&lt;/span&gt;&lt;span class="kwrd"&gt;="PlainTextEmail"&lt;/span&gt; &lt;span class="attr"&gt;value&lt;/span&gt;&lt;span class="kwrd"&gt;="Hi There, You currently don't support HTML emails, but thats ok! I'm just saying hello anyway!"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;appSettings&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Configuration - Email server [App/Web.config]&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;system.net&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;mailSettings&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;smtp&lt;/span&gt; &lt;span class="attr"&gt;from&lt;/span&gt;&lt;span class="kwrd"&gt;="Admin &amp;amp;lt;admin@ginkosolutions.com&amp;amp;gt;"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;network&lt;/span&gt; &lt;span class="attr"&gt;host&lt;/span&gt;&lt;span class="kwrd"&gt;="localhost"&lt;/span&gt; &lt;span class="attr"&gt;port&lt;/span&gt;&lt;span class="kwrd"&gt;="25"&lt;/span&gt;  &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;smtp&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;mailSettings&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;system.net&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Note&lt;/span&gt;: This won't work unless you have a local email server. Please provide the details to an SMTP email server here.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Create a sample recipient class (Just for storing recipient details)&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Recipient&lt;/pre&gt;&lt;pre&gt;{&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Name { get; set; }&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Email { get; set; }&lt;/pre&gt;&lt;pre class="alt"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Invoke the email static class&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;// Construct recipient from form&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;Recipient recipient = &lt;span class="kwrd"&gt;new&lt;/span&gt; Recipient() { Name = FriendName, Email = FriendEmail };&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;// Send email&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;EmailHelper.SendEmail(Server.MapPath(&lt;span class="str"&gt;"~/EmailTemplate"&lt;/span&gt;), recipient);&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Note&lt;/span&gt;: I have added an email template path as a parameter. This is so that if you execute the email helper from a web application, it knows where to find the templates!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Sample HTML Template File&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;body&lt;/span&gt; &lt;span class="attr"&gt;style&lt;/span&gt;&lt;span class="kwrd"&gt;="background: #000000;"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;Hello &lt;span class="asp"&gt;&amp;lt;%&lt;/span&gt;NAME&lt;span class="asp"&gt;%&amp;gt;&lt;/span&gt;,&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;br&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;br&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;I thought i'd send you a picture of some guy holding an envelope.&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;br&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;br&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;img&lt;/span&gt; &lt;span class="attr"&gt;src&lt;/span&gt;&lt;span class="kwrd"&gt;="cid:email"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;br&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;br&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;I have no idea why though!&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;br&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;br&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;Thanks!&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;body&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Note&lt;/span&gt;: &lt;br /&gt;Notice the &lt;span style="font-weight:bold;"&gt;cid&lt;/span&gt; prefix for the images. This indicates a contentID for a linked resource. If you look in the code for the email helper, you will notice that I am created 1 linked resource and setting the contentID to 'email'. This will simply embed the image.&lt;br /&gt;Again, in this template, you will notice I have used a custom tag for the friend's name called &lt;span style="font-weight:bold;"&gt;NAME&lt;/span&gt;. This is replaced within the email helper when we construct a &lt;span style="font-weight:bold;"&gt;ListDictionary&lt;/span&gt; and add our replacements to it.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;and thats it!!&lt;br /&gt;&lt;br /&gt;If you stuck, or can't get it to compile, then download the full sample here&lt;br /&gt;&lt;br /&gt;&lt;a href="https://doc-0g-6g-docsviewer.googleusercontent.com/viewer/securedownload/93c8vioplh2aqm4afrc7j9k14bhhi26p/pup1k479iqk4r3g9d3t8dnvp7pcjdd6s/1311867900000/ZXhwbG9yZXI=/AGZ5hq8lCFHJDWK-wjlX5a0vRY5g/MEI2U2ZNQXc2dGZwUk4yWXpOVFl3TjJVdE9HRTVOUzAwWVRZM0xUaGpaVFl0TlRZM1pEa3dOamRtWm1Waw==?a=dl&amp;filename=%5BMVC3%5D+HTML+Email+with+linked+resources+Example.zip&amp;sec=AHSqidYSkZ3x96cnYT42xRCVfgjXmD7IhN6-Yp9lsHcMpzUgRcJc9CfCOl45j04nq7YSpmzrTj7RttMXjIGDRAS4X0W5pKzbQ8bfNj2CbQkVKrbJ6Nqum8DKjjjfrRiodQ3fCMnBstuL67B85mt_Nk_d7WfbUC0iLRYk60w0vYBHuZAqO9WL8SIguo0UoeTlcFWTA8GbBwwW9PijvpFdgerLS3uL0vGf0jtPKWB0GqzfF91rbpPJWoid-LYutW4z_vHd2J0MVzKM7lzmP9-AbsIh-P7pxld-NG2H2hMrQjisp6RWUbIiAKDJqGuvA3NN-nkxXgjXzr60iK72GAVyD7xlcllRqWieluI2XfmbrJvo-lTkQDbAqPZpd-Up4At8RQKDA0cJs1nlXPt59Ui6aQUZMzQdp9U4om3bJk6XeI-tl0pYmmnxaXZATpYfSsAQ2CFjVPhNkSLn&amp;nonce=i7dkhg0vgcaik&amp;user=AGZ5hq8lCFHJDWK-wjlX5a0vRY5g&amp;hash=9kl716p5ao7hsm8c8plvi6bkt85dj46h" target="_blank"&gt;MVC3 Web Application - Full Email Example with Fallback&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-953074341697748584?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/953074341697748584/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=953074341697748584' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/953074341697748584'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/953074341697748584'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/07/c-sending-html-email-template-with.html' title='C# - Sending HTML Email template with linked resources and plain text fallback'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-670824935030888286</id><published>2011-07-22T02:19:00.000-07:00</published><updated>2011-07-22T08:54:02.316-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MVC'/><category scheme='http://www.blogger.com/atom/ns#' term='Entity Framework'/><title type='text'>MVC3 JQuery Client Validation using Entity Model Framework 4.1 auto generated classes</title><content type='html'>Hi all,&lt;br /&gt;&lt;br /&gt;This is a quick tutorial on how to perform client validation using the MVC framework with auto generated classes in the backend. You might have these auto-generated classes by using a data modelling framework such as: Entity Framework or Linq-To-Sql.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Prerequisites&lt;/span&gt;&lt;br /&gt;&lt;a href="http://tutorialgenius.blogspot.com/2011/07/creating-mvc3-application-with-entity.html" target="_blank"&gt;Creating an MVC 3 Web Application with the Razor View Engine, HTML5 and IIS Express 7.5&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Creating an entity model using EMF 4.1&lt;/span&gt;&lt;br /&gt;1. Create a new Entity Data Model (.edmx) file within your &lt;span style="font-weight:bold;"&gt;Modules&lt;/span&gt; folder. Right click Modules and add a "ADO.NET Entity Data Model" item. Call this "MembershipModel.edmx"&lt;br /&gt;2. If you have a database already, seelct "Generate from database". This will automatically create entities based on your tables. If not, select "Empty model".&lt;br /&gt;3. Open the entity designer file (.edmx).&lt;br /&gt;4. If you selected "Empty model", Right click the designer &gt; Add &gt; Entity...&lt;br /&gt;5. Name the entity "User"&lt;br /&gt;6. OK to create!&lt;br /&gt;7. Right click the new entity &gt; Add &gt; Scalar Property&lt;br /&gt;8. Call the property "Name"&lt;br /&gt;9. Right click the new entity &gt; Add &gt; Scalar Property&lt;br /&gt;10. Call the property "Email"&lt;br /&gt;11. You can generate your database from your model. Once you have created your entities, right click the designer and select "Generate Database from Model". Don't worry if you need to update these at a later date, EMF does a good job of syncing these later.&lt;br /&gt;12. Setup a new connection to your database&lt;br /&gt;13. You will be presented with an SQL script for your entities, cool huh?&lt;br /&gt;14. Execute this against your datastore.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Note&lt;/span&gt;: If you open the designer oce behind file (MembershipModel.Designer.cs), you can see that the classes have been created for us (one per entity), aswell as some properties and a method to create a new user (in our example). By default, the designer uses a code generater called &lt;span style="font-weight:bold;"&gt;T4&lt;/span&gt; (Text Template Transformation Toolkit). You will notice that all classes using the default template implement the &lt;span style="font-weight:bold;"&gt;EntityObject&lt;/span&gt; base class. These classes provide a lot of functionality, but are quite cumbersome to work with. So we are going to use a different generator! (DbContext Generator)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Using the DbContext Generator&lt;/span&gt;&lt;br /&gt;1. Right click the Entity Model .edmx designer &gt; "Add Code generation"&lt;br /&gt;2. Select "ADO.NET DbContext Generator" from the dialog and name it "Model1.tt".&lt;br /&gt;3. OK to create!&lt;br /&gt;4. You will receive a warning because template can potentially contain harmful content. Just click ok!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Note&lt;/span&gt;: You will notice that two files have been created under the Models folder: &lt;span style="font-weight:bold;"&gt;Model1.tt&lt;/span&gt; and &lt;span style="font-weight:bold;"&gt;Model1.Context.tt&lt;/span&gt;. Underneath the Model1.tt file, you will be a custom class representing your entity "User.cs". This is the class you will be using throughout this sample application to represent users! If you don't see this class here, then you have created your database!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;ok, im a master at EMF, show me the validation already!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;With MVC, a simple way to perform validation is to use the &lt;span style="font-weight:bold;"&gt;[Required]&lt;/span&gt; atrribute for properties of our class. Now the problem lies with the way our classes are generated by the code generator (We cannot change the designer fiels because we'll lose our changes, plus its stupid!). An easy way around this is to use &lt;span style="font-weight:bold;"&gt;Metadatatype&lt;/span&gt;!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Metadatatype and T4 class validation&lt;/span&gt;&lt;br /&gt;1. Right click the Models folder &gt; Add &gt; Class..&lt;br /&gt;2. Call it "UserValidation.cs"&lt;br /&gt;3. Enter the following code...&lt;br /&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.ComponentModel.DataAnnotations;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Linq;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Web;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; MvcApplication1.Models&lt;/pre&gt;&lt;pre&gt;{&lt;/pre&gt;&lt;pre class="alt"&gt;    [MetadataType(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(UserValidation))]&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;partial&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; User&lt;/pre&gt;&lt;pre class="alt"&gt;    {}&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; UserValidation&lt;/pre&gt;&lt;pre&gt;    {&lt;/pre&gt;&lt;pre class="alt"&gt;        [Required(ErrorMessage = &lt;span class="str"&gt;"Your Full Name is required"&lt;/span&gt;)]&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Name { get; set; }&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;        [Required(ErrorMessage = &lt;span class="str"&gt;"Your Email Address is required"&lt;/span&gt;)]&lt;/pre&gt;&lt;pre class="alt"&gt;        [RegularExpression(&lt;span class="str"&gt;@"^[\w-]+(\.[\w-]+)*@([a-z0-9-]+(\.[a-z0-9-]+)*?\.[a-z]{2,6}|(\d{1,3}\.){3}\d{1,3})(:\d{4})?$"&lt;/span&gt;, ErrorMessage = &lt;span class="str"&gt;"Your Email Address is invalid"&lt;/span&gt;)]&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Email { get; set; }&lt;/pre&gt;&lt;pre class="alt"&gt;    }&lt;/pre&gt;&lt;pre&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Note&lt;/span&gt;: You will notice that Metadatatype allows us to specify another class on behalf of an existing partial class, to append attribues to. These attributes will be our validation attributes! I have chosen the Name and the Email properties of our user entity to apply validation to.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Configuring the Controller&lt;/span&gt;&lt;br /&gt;1. Add a new controller. I.e. HomeController&lt;br /&gt;2. In the Index method, return the view with a new copy of the EMF generated User class.&lt;br /&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Linq;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Web;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Web.Mvc;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; MvcApplication1.Models;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; MvcApplication1.Controllers&lt;/pre&gt;&lt;pre class="alt"&gt;{&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; HomeController : Controller&lt;/pre&gt;&lt;pre class="alt"&gt;    {&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;//&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;// GET: /Home/&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; ActionResult Index()&lt;/pre&gt;&lt;pre class="alt"&gt;        {&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; View(&lt;span class="kwrd"&gt;new&lt;/span&gt; User());&lt;/pre&gt;&lt;pre class="alt"&gt;        }&lt;/pre&gt;&lt;pre&gt;    }&lt;/pre&gt;&lt;pre class="alt"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Creating the configuring the view&lt;/span&gt;&lt;br /&gt;1. Right click the Index method in the controller and add the view.&lt;br /&gt;2. Make this strongly typed, or we will have a problem with the dynamic operations we will be using in the view (Example error: CS1963: An expression tree may not contain a dynamic operation)&lt;br /&gt;3. Enter the following form information into the view...&lt;br /&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;@using MvcApplication1.Models&lt;/pre&gt;&lt;pre&gt;@model User&lt;/pre&gt;&lt;pre class="alt"&gt;@{&lt;/pre&gt;&lt;pre&gt;    ViewBag.Title = "Index";&lt;/pre&gt;&lt;pre class="alt"&gt;    Layout = "~/Views/Shared/_Layout.cshtml";&lt;/pre&gt;&lt;pre&gt;}&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;h2&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Sample EMF Class Validation&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;h2&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;@using (Html.BeginForm())&lt;/pre&gt;&lt;pre class="alt"&gt;{&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;fieldset&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;p&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        @Html.LabelFor(Model =&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; Model.Name)&lt;/pre&gt;&lt;pre class="alt"&gt;        @Html.TextBoxFor(Model =&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; Model.Name)&lt;/pre&gt;&lt;pre&gt;        @Html.ValidationMessageFor(Model =&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; Model.Name)&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;p&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;p&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        @Html.LabelFor(Model =&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; Model.Email)&lt;/pre&gt;&lt;pre&gt;        @Html.TextBoxFor(Model =&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; Model.Email)&lt;/pre&gt;&lt;pre class="alt"&gt;        @Html.ValidationMessageFor(Model =&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; Model.Email)&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;p&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;p&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;input&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;="submit"&lt;/span&gt; &lt;span class="attr"&gt;value&lt;/span&gt;&lt;span class="kwrd"&gt;="Submit"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;p&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;fieldset&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;We are almost there, but one more thing!! We need to add a reference to the jquery validation libraries. You can either do this in your view (using sections from the main layout page) or simply add the following into the head on the _Layout.cshtml page...&lt;br /&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt; &lt;span class="attr"&gt;src&lt;/span&gt;&lt;span class="kwrd"&gt;="@Url.Content("&lt;/span&gt;~/&lt;span class="attr"&gt;Scripts&lt;/span&gt;/&lt;span class="attr"&gt;jquery&lt;/span&gt;.&lt;span class="attr"&gt;validate&lt;/span&gt;.&lt;span class="attr"&gt;min&lt;/span&gt;.&lt;span class="attr"&gt;js&lt;/span&gt;&lt;span class="kwrd"&gt;")"&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;="text/javascript"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &amp;lt;script src=&lt;span class="str"&gt;"@Url.Content("&lt;/span&gt;~/Scripts/jquery.validate.unobtrusive.min.js&lt;span class="str"&gt;")"&lt;/span&gt; type=&lt;span class="str"&gt;"text/javascript"&lt;/span&gt;&amp;gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;sphttp://www.blogger.com/img/blank.gifan class="html"&gt;script&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="https://doc-0o-6g-docsviewer.googleusercontent.com/viewer/securedownload/93c8vioplh2aqm4afrc7j9k14bhhi26p/grrn6v7ii5ic5hg5pohl17euspkb9kbr/1311349500000/ZXhwbG9yZXI=/AGZ5hq8lCFHJDWK-wjlX5a0vRY5g/MEI2U2ZNQXc2dGZwUlpEWmpNRFZqTnprdE5HWTRNQzAwTTJKbExUZzJNRE10WkRNMFpqZGxZV015TW1SbA==?a=dl&amp;filename=%5BMVC3%5D+Razor+Client+Side+Validation.zip&amp;sec=AHSqidbM4-Bx8iyHVJ_oxwiPaTlT7X6eWivfzPPefz9AaZgEPa3DWbXLPVV4BGEo2mKeEBEY1j64K5DCRNi5nDBkSpfJ7dqQY8L77Ct4WMneO-VeXGjO9TVCM20nGHRR9JpMuMaEP-gStJdgy15FuV8zi4-4kNSlkC2zhF6nl3S-xWzZX_fMS684yM073hEfh9ZS1D4WIWBcle43dpDxF7gAxO2G2L7O68NbGCYynBEggkeJi8owM8ujDSvs2fLtZtJHlKJD3I3pKXuCQL1Q5VkuK3ecYiOpsS6e4eJmaHGVnV7zeTKpC7aSDe3M64ec30RGUrmbz-uKUK2qYXTvDJowcflrKrRJjymyZ0Jvt2ZjT7zh3-V95gcLjRJ0jwS24rwDXq3BzWVH4TmWlXgVLtgYg6GCGTs3BAPf2xKsoS288R7k1_Lnh2srVd3R7uy6KDH_bWFNBgHD&amp;nonce=hhaq3r8dopdae&amp;user=AGZ5hq8lCFHJDWK-wjlX5a0vRY5g&amp;hash=s27i2k4qaghpaehl133atb86kmh4brsc"&gt;Download Sample Files Here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Enjoy!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-670824935030888286?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/670824935030888286/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=670824935030888286' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/670824935030888286'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/670824935030888286'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/07/mvc3-jquery-client-validation-using.html' title='MVC3 JQuery Client Validation using Entity Model Framework 4.1 auto generated classes'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-6582820983788033893</id><published>2011-07-20T08:46:00.000-07:00</published><updated>2011-07-22T03:35:51.206-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><category scheme='http://www.blogger.com/atom/ns#' term='MVC'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='Entity Framework'/><title type='text'>Creating an MVC 3 Web Application with the Razor View Engine, HTML5 and IIS Express 7.5</title><content type='html'>This was originally going to be a few simple steps, but I decided to go the whole hog. Good first read if your getting started with MVC3! (Rough knowledge required, when I say rough, I mean VS, aspx and O-O knowledge)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Creating new MVC 3 Web Application in VS 2010&lt;/span&gt;&lt;br /&gt;1. Create a new MVC 3 Web Application&lt;br /&gt;2. Select an Empty template from the templates dialog (the others ship with authentication that were not goign to use).&lt;br /&gt;3. View engine, select Razor (This will allow us to use the Razor view engine which has slightly different markup and uses .cshtml files rather than .aspx pages). Note: Razor view can be rendered inside unit tests, something that aspx pages cannot.&lt;br /&gt;4. Use HTML5 semantic markup, check it!&lt;br /&gt;5. OK to create.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Note&lt;/span&gt;: You can see that quite a lot of libraries are included by default. You will also notice that JQuery (JS and CSS) is included as standard and we have a good base setup to begin developing our web application.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;WHAT IS MVC and Order of execution&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Init&lt;/span&gt;&lt;br /&gt;Within an MVC application, you have a list of routes and filters defined when the application starts. These are defined the the Global.asax.cs file (yes it still exists!). The routes are referenced everytime a page is requested (URL is entered that is associated with the application). The routes describe which Controller will serve the view's content.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Controller&lt;/span&gt;&lt;br /&gt;The Controller is responsible for all the business logic. This is the "C" part of &lt;span style="font-weight:bold;"&gt;MVC&lt;/span&gt;. The Controller may utilise the Model ("M" in MVC) to manipulate the datastore is some way (basically ask the database to grab something). The Controller may do some casting or validation on the data, then render the View (may also pass data to the view when rendering).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Model&lt;/span&gt;&lt;br /&gt;The Model is all about the database and the database layer. Usually you will have a framework here for managing access and control to your database. In this example, we are using the entity framework. So we will have our .edmx files and our template files here. Our classes will also be defined here as they will be generated automatically from our database content!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;View&lt;/span&gt;&lt;br /&gt;The "V" in MVC. View's should know nothing about how the data is constructed and how the data works internally. The view should be essentially be dumb and told nothing about the data, other than anything required to display the data to the user. The reason for this aides the seperation of concerns principle of O-O programming. This allows us to clearly seperate are busienss logic. The rewards consist of: Unit testable busienss layer, designers can work with views without worrying about learning C#/VB etc.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Razor View Engine&lt;/span&gt;&lt;br /&gt;I don't want to explain everything in this post or were gonna be writing a novel. Here is a &lt;a href="http://weblogs.asp.net/scottgu/archive/2010/07/02/introducing-razor.aspx" target="_blank"&gt;good link&lt;/a&gt; by ScottGu on the Razor view engine. Either than, or you can just trust me that it's great!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Note about Razor 'master' pages and entry points&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;_ViewStart.cshtml&lt;/span&gt; - Does what it says! This is executed first and initialises the view.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;_Layout.cshtml&lt;/span&gt; - Razor's answer to aspx master pages.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Creating a Controller&lt;/span&gt;&lt;br /&gt;1. Right click the &lt;span style="font-weight:bold;"&gt;Controllers&lt;/span&gt; directory.&lt;br /&gt;2. Add &gt; Controller.&lt;br /&gt;3. Name the controller &lt;span style="font-weight:bold;"&gt;HomeController&lt;/span&gt; (We already have a route defined in the Global.asax as default that points to a Home Controller - So there is no extra work required to link it up yet).&lt;br /&gt;4. Set the template as an empty template&lt;br /&gt;5. OK to create!&lt;br /&gt;6. You will notice that you controller contains an Index method. Will will be executed by default when the user hits the 'Home' directory for your application. I.e. http://localhost/Home&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Creating a View based off the Controller&lt;/span&gt;&lt;br /&gt;1. Each method in our controller can map to its own view page. This is what we will be doing in this example. Once the controller is created, then creating a view is simple!&lt;br /&gt;2. Open the HomeController, and right click on the Index method.&lt;br /&gt;3. Select 'Add View...'&lt;br /&gt;4. The view name will be Index by default. This is fine...&lt;br /&gt;5. THe view engine will be Razor, this again is fine...&lt;br /&gt;6. Creating a strongly typed view just means that this view will only accept classes of a single type. So if you are ALWAYS passing a TEST class to this view, then it should be strongly typed.&lt;br /&gt;7. Partial view can be compared to an aspx user control. It's a partial view, not a complete one! This can be re-used throughout the web application. We are not creatign one of these now...&lt;br /&gt;8. "Use layout or master page". We are using this (as describes before). Set this as the _Layout.cshtml file. It will reside in the Shared folder within Views (~/Views/Shared/_Layout.cshtml).&lt;br /&gt;9. OK to create!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Setting up test server and launching application&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Note&lt;/span&gt;: I recommend using IIS Express (7.5 latest at time of writing) or something different to the visual studio server for this application. MVC uses URL Routing (aka URL rewriting before MVC), so sometimes the routing gets a little confusing with the visual studio development server. IIS7 handles URL routing out of the box (Whereas more steps were requried for IIS 6, and you can't install IIS7 on windows XP). However, IIS Express 7.5 solves all of these problems becaue it performs both nicely!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Setting up IIS Express 7.5&lt;/span&gt;&lt;br /&gt;1. If you don't have it, its a lightweight seperate install. Simply get it via the &lt;a href="http://www.microsoft.com/web/downloads/platform.aspx" target="_blank"&gt;web platform intaller&lt;/a&gt;&lt;br /&gt;2. Right click the web application in Visual Studio &gt; Properties.&lt;br /&gt;3. Web tab&lt;br /&gt;4. Use local IIS Web server&lt;br /&gt;5. Check "Use IIS Express".&lt;br /&gt;6. Click create virtual directory button&lt;br /&gt;7. OK to execute application!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now, simply execute the application and you'll be presented with a very blank dull webpage. Congratulations, you did it! It's the start of something good, trust me!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Reference Links&lt;/span&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/data/gg685489" target="_blank"&gt;Building an MVC 3 App with Database First and Entity Framework 4.1&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.asp.net/mvc/tutorials/creating-a-mvc-3-application-with-razor-and-unobtrusive-javascript" target="_blank"&gt;Creating an MVC3 Application with Razor and JS&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-6582820983788033893?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/6582820983788033893/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=6582820983788033893' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/6582820983788033893'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/6582820983788033893'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/07/creating-mvc3-application-with-entity.html' title='Creating an MVC 3 Web Application with the Razor View Engine, HTML5 and IIS Express 7.5'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-3676577658159046280</id><published>2011-07-11T01:34:00.000-07:00</published><updated>2011-07-11T01:35:22.262-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MVC'/><category scheme='http://www.blogger.com/atom/ns#' term='IIS'/><title type='text'>Deploying an MVC application on IIS 6</title><content type='html'>&lt;a href="http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx" target="_blank"&gt;http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-3676577658159046280?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/3676577658159046280/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=3676577658159046280' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/3676577658159046280'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/3676577658159046280'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/07/deploying-mvc-application-on-iis-6.html' title='Deploying an MVC application on IIS 6'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-6995970653384552662</id><published>2011-06-28T01:12:00.000-07:00</published><updated>2011-06-28T01:16:05.539-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual Studio'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>Visual Studio/SQL Server - Script schema and data in Visual Studio 2008 and onwards</title><content type='html'>&lt;a href="http://blogs.msdn.com/b/webdevtools/archive/2007/10/15/sql-database-publishing-wizard-is-now-in-visual-studio-orcas.aspx" target="_blank"&gt;http://blogs.msdn.com/b/webdevtools/archive/2007/10/15/sql-database-publishing-wizard-is-now-in-visual-studio-orcas.aspx&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-6995970653384552662?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/6995970653384552662/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=6995970653384552662' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/6995970653384552662'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/6995970653384552662'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/06/visual-studiosql-server-script-schema.html' title='Visual Studio/SQL Server - Script schema and data in Visual Studio 2008 and onwards'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-6155658990607444208</id><published>2011-06-24T03:36:00.000-07:00</published><updated>2011-06-24T04:24:42.506-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='XSLT'/><title type='text'>C#/XSLT - Adding custom xml namespaces / extension objects</title><content type='html'>Today I had a bit of a ball ache trying to capture errors that were failing within my XSLT. Whenever I called the &lt;span style="font-weight:bold;"&gt;document()&lt;/span&gt; function with an invalid file path, the document will fail to transform and nothing will be displayed.&lt;br /&gt;&lt;br /&gt;Initially I looked at trying to capture the error using when/otherwise by passing the result of the &lt;span style="font-weight:bold;"&gt;document()&lt;/span&gt; function into a test attribute. This simply does not work, even if you convert the result to a boolean. So after wading through crappy advice, I thought as I'm using C# to do my transformations, I will simply add a custom namespace.&lt;br /&gt;&lt;br /&gt;The following example explains how to check if a file exists using a custom namespace in C#.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;1. Add a custom &lt;span style="font-weight:bold;"&gt;xmlns&lt;/span&gt; reference to your XSL file. The format is as follows: &lt;span style="font-weight:bold;"&gt;xmlns:&amp;lt;tag name&amp;gt;="&amp;lt;namespace&amp;gt;"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Example&lt;/span&gt;:&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:stylesheet&lt;/span&gt; &lt;span class="attr"&gt;version&lt;/span&gt;&lt;span class="kwrd"&gt;="1.0"&lt;/span&gt; &lt;span class="attr"&gt;xmlns:xsl&lt;/span&gt;&lt;span class="kwrd"&gt;="http://www.w3.org/1999/XSL/Transform"&lt;/span&gt; &lt;span class="attr"&gt;xmlns:file&lt;/span&gt;&lt;span class="kwrd"&gt;="urn:schemas-file"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;This will allow me to prefix functions within my &lt;span style="font-weight:bold;"&gt;urn:schemas-file&lt;/span&gt; namespace with the prefix: &lt;span style="font-weight:bold;"&gt;file&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2. Now the XSL has access to this custom library of functions (which we haven't yet coded yet)... we need to actually call one of our functions within the XSL.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Example&lt;/span&gt;:&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;&amp;lt;!-- Sample variable holding a location to a file --&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:variable&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="filePath"&lt;/span&gt; &lt;span class="attr"&gt;select&lt;/span&gt;&lt;span class="kwrd"&gt;="../root/xml/testdocument.xml"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;&amp;lt;!-- Check to see if the file exists --&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:choose&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:when&lt;/span&gt; &lt;span class="attr"&gt;test&lt;/span&gt;&lt;span class="kwrd"&gt;="file:fileExists($filePath)"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    File exists... process the file here and output some stuff!&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;xsl:when&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:otherwise&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    File does not exist. perform fallback operation!&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;xsl:otherwise&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;xsl:choose&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3. Now the XSL knows out our functions and were consuming one of them, we just need to write the namespace itself and apply to to the transformation! Create a class in C# and add some functionality that you wish to make available to your XSL file.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Example&lt;/span&gt;:&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;// &amp;lt;copyright file="XSLFileHelper.cs" company="Ginko Solutions"&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;// Copyright (c) 2011 All Right Reserved&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;// &amp;lt;/copyright&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;// &amp;lt;author&amp;gt;Sean Greasley&amp;lt;/author&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;// &amp;lt;email&amp;gt;sean.greasley@fusedigital.com&amp;lt;/email&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;// &amp;lt;summary&amp;gt;Provides file functionality to support XSL processing&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; RegulationExplorerWebHTML.Helpers&lt;/pre&gt;&lt;pre&gt;{&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.IO;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Web;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// Provides file functionality to support XSL processing&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; XSLFileHelper&lt;/pre&gt;&lt;pre class="alt"&gt;    {&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; fileExists(&lt;span class="kwrd"&gt;string&lt;/span&gt; file)&lt;/pre&gt;&lt;pre class="alt"&gt;        {&lt;/pre&gt;&lt;pre&gt;            &lt;span class="rem"&gt;// Get path&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;string&lt;/span&gt; path = HttpContext.Current.Server.MapPath(file);&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="rem"&gt;// Exists&amp;lt;?&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; File.Exists(path);&lt;/pre&gt;&lt;pre class="alt"&gt;        }&lt;/pre&gt;&lt;pre&gt;    }&lt;/pre&gt;&lt;pre class="alt"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;4. The final step is to apply this class to the transformation process! To do this, will use the &lt;span style="font-weight:bold;"&gt;AddExtensionObject&lt;/span&gt; method of the &lt;span style="font-weight:bold;"&gt;XsltArgumentList&lt;/span&gt; class.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Note&lt;/span&gt;: Please see my &lt;a href="http://tutorialgenius.blogspot.com/2011/06/c-transforming-xml-and-xsl-documents.html" target="_blank"&gt;previous post&lt;/a&gt; about how to do an XML/XSL transformation in C# with parameters and settings.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Example&lt;/span&gt;:&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;XsltArgumentList xslArgs = &lt;span class="kwrd"&gt;new&lt;/span&gt; XsltArgumentList();&lt;/pre&gt;&lt;pre&gt;xslArgs.AddExtensionObject(&lt;span class="str"&gt;"urn:schemas-file"&lt;/span&gt;, &lt;span class="kwrd"&gt;new&lt;/span&gt; XSLFileHelper());&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;5. and thats it!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-6155658990607444208?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/6155658990607444208/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=6155658990607444208' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/6155658990607444208'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/6155658990607444208'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/06/cxslt-adding-custom-xml-namespaces.html' title='C#/XSLT - Adding custom xml namespaces / extension objects'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-5153074143298466782</id><published>2011-06-23T03:24:00.000-07:00</published><updated>2011-06-23T03:46:07.961-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='LinqToSQL'/><title type='text'>Serializing LINQ-to-SQL classes example with deep cloning</title><content type='html'>Serializing Linq-To-Sql classes isn't as straight forward as you might imagine. You may have got as far as attempting to serialize a class and found an error stating &lt;span style="font-weight:bold;"&gt;Linq.EntityRef&lt;/span&gt; cannot be serialized. This post explains to to serialize Linq-To-Sql entities using a cloning example.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For this example, I will be taking a deep clone of a Linq-To-Sql object and all of its associated properties. To do this, I will use serialization and utilise the ICloneable interface.&lt;br /&gt;&lt;br /&gt;This example assumes you already have a Linq-To-Sql classes file (.dbml) with some tables/class information within the designer...&lt;br /&gt;&lt;br /&gt;1. Open the Linq-To-Sql designer (.dbml) and view the main properties. Change the 'Serialzation Mode' to &lt;span style="font-weight:bold;"&gt;Unidirectional&lt;/span&gt;. This decorates our Linq-To-Sql entities with serialization capabilities.&lt;br /&gt;&lt;br /&gt;2. Create a partial class for the Linq-To-Sql class you wish to clone. This allows you to extend the functionality of a Linq-To-Sql class as all classes are partial.&lt;br /&gt;&lt;br /&gt;3. Add the &lt;span style="font-weight:bold;"&gt;[Serializable]&lt;/span&gt; attribute to the header of the class. This marks the class as serializable.&lt;br /&gt;&lt;br /&gt;4. Implement the ICloneable inteferface. We can now override the &lt;span style="font-weight:bold;"&gt;Clone()&lt;/span&gt; method. When this method is called, we need to apply the serialization process to the object we wish to clone.&lt;br /&gt;&lt;br /&gt;5. When serializing a Linq-To-Sql class, we cannot use the &lt;span style="font-weight:bold;"&gt;BinaryFormatter&lt;/span&gt;. Linq-To-Sql classes simply do not support this. Instead, we can utilise the &lt;span style="font-weight:bold;"&gt;NetDataContractSerializer&lt;/span&gt;. This will suit out requirements for the serialization of Linq-To-Sql entities.&lt;br /&gt;&lt;br /&gt;6. and your done!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Serialzation code snippet&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;/// Linq-To-Sql partial class, extends the 'Event' entity/class.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;/// Note: Also changed Serialzation mode in designer to Unidirectional&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;[Serializable]&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;partial&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Event : ICloneable&lt;/pre&gt;&lt;pre class="alt"&gt;{&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// Overrides the Clone method within the IClonable interface&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// to performing object cloning&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;A clone of the incoming object&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; Clone()&lt;/pre&gt;&lt;pre&gt;    {&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;return&lt;/span&gt; CloningFunctions.CloneObject(&lt;span class="kwrd"&gt;this&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;    }&lt;/pre&gt;&lt;pre class="alt"&gt;}&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;/// Provides functions aiding object cloning&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; CloningFunctions&lt;/pre&gt;&lt;pre&gt;{&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// Clones an  object using the NetDataContractSerializer&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;param name="obj"&amp;gt;Incoming object to clone&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;A clone of the incoming object&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; CloneObject(&lt;span class="kwrd"&gt;object&lt;/span&gt; obj)&lt;/pre&gt;&lt;pre class="alt"&gt;    {&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;using&lt;/span&gt; (MemoryStream memStream = &lt;span class="kwrd"&gt;new&lt;/span&gt; MemoryStream())&lt;/pre&gt;&lt;pre class="alt"&gt;        {&lt;/pre&gt;&lt;pre&gt;            NetDataContractSerializer formatter = &lt;span class="kwrd"&gt;new&lt;/span&gt; NetDataContractSerializer(&lt;span class="kwrd"&gt;new&lt;/span&gt; StreamingContext(StreamingContextStates.Clone));&lt;/pre&gt;&lt;pre class="alt"&gt;            formatter.Serialize(memStream, obj);&lt;/pre&gt;&lt;pre&gt;            memStream.Seek(0, SeekOrigin.Begin);&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; formatter.Deserialize(memStream);&lt;/pre&gt;&lt;pre&gt;        }&lt;/pre&gt;&lt;pre class="alt"&gt;    }&lt;/pre&gt;&lt;pre&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-5153074143298466782?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/5153074143298466782/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=5153074143298466782' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/5153074143298466782'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/5153074143298466782'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/06/serializing-linq-to-sql-classes-example.html' title='Serializing LINQ-to-SQL classes example with deep cloning'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-6109120918332032444</id><published>2011-06-22T07:57:00.001-07:00</published><updated>2011-06-22T08:06:14.530-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Security'/><category scheme='http://www.blogger.com/atom/ns#' term='Networking'/><title type='text'>Access computer behind router over the internet</title><content type='html'>Here's a few notes which I find useful for accessing my system over the internet from an external location.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Is the remote system behind a router?&lt;/span&gt;&lt;br /&gt;If so, use the router's IP address. Either go to whatismyip.com, or get the router's IP Address from the router control panel (typically 192.168.1.1). This will be the IP address you will use to access the system.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Enabling remote access&lt;/span&gt;&lt;br /&gt;Enable remote access to the system. For windows, its usually at "Right Click My Computer &gt; Properties &gt; Remote/Remote Settings". Here you can also configure who is allowed to access the system.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Systems behind a router&lt;/span&gt;&lt;br /&gt;Setup port forwarding to the system in question. Find your local IP address (usually 192.168.x.x) and forward the necessary ports to this system. I.e. for HTTP, use port 80. So when you visit the router's IP address over HTTP (http://externalRouterIP), it will forward the request to your machine. Another useful one is 3389 for remote desktop.&lt;br /&gt;Optional: It may be useful to set a static IP for your system. This ensures that your internal IP address stays the same. If your router software does not support this, you can figure your own in Network Settings under the Control Panel in Windows.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-6109120918332032444?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/6109120918332032444/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=6109120918332032444' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/6109120918332032444'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/6109120918332032444'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/06/access-computer-behind-router-over.html' title='Access computer behind router over the internet'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-7367477893792017558</id><published>2011-06-21T03:34:00.000-07:00</published><updated>2011-06-21T03:35:47.215-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Source Control'/><title type='text'>SVN: Setting up SubVersion server on Windows</title><content type='html'>Here is a great article on how to setup SVN server on a windows machine.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.codinghorror.com/blog/2008/04/setting-up-subversion-on-windows.html" target="_blank"&gt;http://www.codinghorror.com/blog/2008/04/setting-up-subversion-on-windows.html&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-7367477893792017558?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/7367477893792017558/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=7367477893792017558' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/7367477893792017558'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/7367477893792017558'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/06/svn-setting-up-subversion-server-on.html' title='SVN: Setting up SubVersion server on Windows'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-8113197562463963030</id><published>2011-06-20T09:30:00.000-07:00</published><updated>2011-06-21T03:46:34.555-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SEO'/><title type='text'>SEO - Search Engine Optimization</title><content type='html'>Here's a good post on hoe to use an SEO tool to crawl your website for SEO improvements.&lt;br /&gt;The tool installs itself into most web servers and is free to download!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Description&lt;/span&gt;&lt;br /&gt;The IIS Search Engine Optimization (SEO) Toolkit helps Web developers, hosting providers, and Web server administrators to improve their Web site’s relevance in search results by recommending how to make the site content more search engine-friendly. The IIS SEO Toolkit includes the Site Analysis module, the Robots Exclusion module, and the Sitemaps and Site Indexes module, which let you perform detailed analysis and offer recommendations and editing tools for managing your Robots and Sitemaps files.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Article and Download&lt;/span&gt;&lt;br /&gt;&lt;a href="http://weblogs.asp.net/scottgu/archive/2009/06/03/iis-search-engine-optimization-toolkit.aspx" target="_blank"&gt;http://weblogs.asp.net/scottgu/archive/2009/06/03/iis-search-engine-optimization-toolkit.aspx&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-8113197562463963030?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/8113197562463963030/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=8113197562463963030' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/8113197562463963030'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/8113197562463963030'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/06/seo-search-engine-optimization.html' title='SEO - Search Engine Optimization'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-5573053781957339370</id><published>2011-06-15T08:15:00.000-07:00</published><updated>2011-06-15T08:30:09.023-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Security'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>C# - Simple TripleDES Encryption with or without hashing</title><content type='html'>This class below enables simple encryption and decryption of text strings. It uses the TripleDES algorithms and you can chose weather to use MD5 hash against the key.&lt;br /&gt;Simply change the value of the &lt;span style="font-weight:bold;"&gt;encryptionKey&lt;/span&gt; to whatever you want the key to be.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;C# Source code&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;// &amp;lt;copyright file="EncryptionHelper.cs" company="GinkoSolutions.com"&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;// Copyright (c) 2011 All Right Reserved&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;// &amp;lt;/copyright&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;// &amp;lt;author&amp;gt;Sean Greasley&amp;lt;/author&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;// &amp;lt;email&amp;gt;sean@ginkosolutions.com&amp;lt;/email&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;// &amp;lt;summary&amp;gt;Enables simple TripleDES encryption with or without hashing&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Text;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Web;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Security.Cryptography;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;/// Enables simple TripleDES encryption with or without hashing&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; EncryptionHelper&lt;/pre&gt;&lt;pre class="alt"&gt;{&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// Encryption key. Used to encrypt and decrypt.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; encryptionKey = &lt;span class="str"&gt;"YOURSECRETKEY"&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; EncryptionHelper() {}&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// Encrypt text string&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;param name="toEncrypt"&amp;gt;The string of data to encrypt&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// &amp;lt;param name="useHashing"&amp;gt;Weather hashing is used or not&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;An encrypted string&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Encrypt(&lt;span class="kwrd"&gt;string&lt;/span&gt; toEncrypt, &lt;span class="kwrd"&gt;bool&lt;/span&gt; useHashing)&lt;/pre&gt;&lt;pre&gt;    {&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;byte&lt;/span&gt;[] keyArray;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;byte&lt;/span&gt;[] toEncryptArray = UTF8Encoding.UTF8.GetBytes(toEncrypt);&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;// If hashing use get hashcode regards to your key&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (useHashing)&lt;/pre&gt;&lt;pre&gt;        {&lt;/pre&gt;&lt;pre class="alt"&gt;            MD5CryptoServiceProvider hashmd5 = &lt;span class="kwrd"&gt;new&lt;/span&gt; MD5CryptoServiceProvider();&lt;/pre&gt;&lt;pre&gt;            keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(encryptionKey));&lt;/pre&gt;&lt;pre class="alt"&gt;            hashmd5.Clear();&lt;/pre&gt;&lt;pre&gt;        }&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            keyArray = UTF8Encoding.UTF8.GetBytes(encryptionKey);&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;// Set the secret key for the tripleDES algorithm&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        TripleDESCryptoServiceProvider tdes = &lt;span class="kwrd"&gt;new&lt;/span&gt; TripleDESCryptoServiceProvider();&lt;/pre&gt;&lt;pre&gt;        tdes.Key = keyArray;&lt;/pre&gt;&lt;pre class="alt"&gt;        tdes.Mode = CipherMode.ECB;&lt;/pre&gt;&lt;pre&gt;        tdes.Padding = PaddingMode.PKCS7;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;// Transform the specified region of bytes array to resultArray&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        ICryptoTransform cTransform = tdes.CreateEncryptor();&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;byte&lt;/span&gt;[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);&lt;/pre&gt;&lt;pre class="alt"&gt;        tdes.Clear();&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;// Return the encrypted data into unreadable string format&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;return&lt;/span&gt; Convert.ToBase64String(resultArray, 0, resultArray.Length);&lt;/pre&gt;&lt;pre class="alt"&gt;    }&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// Decrypts a text string&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;param name="cipherString"&amp;gt;The encrypted string&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// &amp;lt;param name="useHashing"&amp;gt;Weather hashing is used or not&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;Decrypted text string&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Decrypt(&lt;span class="kwrd"&gt;string&lt;/span&gt; cipherString, &lt;span class="kwrd"&gt;bool&lt;/span&gt; useHashing)&lt;/pre&gt;&lt;pre&gt;    {&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;byte&lt;/span&gt;[] keyArray;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;byte&lt;/span&gt;[] toEncryptArray = Convert.FromBase64String(cipherString.Replace(&lt;span class="str"&gt;' '&lt;/span&gt;, &lt;span class="str"&gt;'+'&lt;/span&gt;));&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (useHashing)&lt;/pre&gt;&lt;pre class="alt"&gt;        {&lt;/pre&gt;&lt;pre&gt;            &lt;span class="rem"&gt;// If hashing was used get the hash code with regards to your key&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            MD5CryptoServiceProvider hashmd5 = &lt;span class="kwrd"&gt;new&lt;/span&gt; MD5CryptoServiceProvider();&lt;/pre&gt;&lt;pre&gt;            keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(encryptionKey));&lt;/pre&gt;&lt;pre class="alt"&gt;            hashmd5.Clear();&lt;/pre&gt;&lt;pre&gt;        }&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        {&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="rem"&gt;// If hashing was not implemented get the byte code of the key&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            keyArray = UTF8Encoding.UTF8.GetBytes(encryptionKey);&lt;/pre&gt;&lt;pre class="alt"&gt;        }&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;// Set the secret key for the tripleDES algorithm&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        TripleDESCryptoServiceProvider tdes = &lt;span class="kwrd"&gt;new&lt;/span&gt; TripleDESCryptoServiceProvider();&lt;/pre&gt;&lt;pre class="alt"&gt;        tdes.Key = keyArray;&lt;/pre&gt;&lt;pre&gt;        tdes.Mode = CipherMode.ECB;&lt;/pre&gt;&lt;pre class="alt"&gt;        tdes.Padding = PaddingMode.PKCS7;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        ICryptoTransform cTransform = tdes.CreateDecryptor();&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;byte&lt;/span&gt;[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);&lt;/pre&gt;&lt;pre class="alt"&gt;        tdes.Clear();&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;// Return the Clear decrypted TEXT&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;return&lt;/span&gt; UTF8Encoding.UTF8.GetString(resultArray);&lt;/pre&gt;&lt;pre class="alt"&gt;    }&lt;/pre&gt;&lt;pre&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-5573053781957339370?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/5573053781957339370/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=5573053781957339370' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/5573053781957339370'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/5573053781957339370'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/06/c-simple-tripledes-encryption-with-or.html' title='C# - Simple TripleDES Encryption with or without hashing'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-2124933948117919228</id><published>2011-06-15T07:13:00.000-07:00</published><updated>2011-06-15T07:41:38.464-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><category scheme='http://www.blogger.com/atom/ns#' term='Facebook Development'/><title type='text'>Facebook Connect - Post to wall feed</title><content type='html'>After using Facebook Connect for a while, you can soon find out how shoddy the documentation is. There seem to be about 5000 half-written API's, most out of date and even the Facebook API documentation is barely holding itself together.&lt;br /&gt;&lt;br /&gt;Anyway, here's a small JS snippet on how to post to a user's wall. The user must first allow the application pushing rights, or an error will occur.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://tutorialgenius.blogspot.com/2011/06/aspnet-c-40-facebook-connect-example.html" target="_blank"&gt;I have already written a great blog entry on getting started with Facebook Connect, check it out here!&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Pre-requisites&lt;/span&gt;&lt;br /&gt;- Check out the above link if you have no idea how to get started!&lt;br /&gt;- Allow pushing rights (publish_stream)&lt;br /&gt;- Ensure your already dealing with an authentication session (I have added the code to ensure you already have a valid session in the code below)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Javascript Code&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;FB.getLoginStatus(function (response) {&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;if&lt;/span&gt; (response.session) {&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;        var &lt;span class="kwrd"&gt;params&lt;/span&gt; = {};&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;params&lt;/span&gt;[&lt;span class="str"&gt;'message'&lt;/span&gt;] = &lt;span class="str"&gt;'This is the main message'&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;params&lt;/span&gt;[&lt;span class="str"&gt;'name'&lt;/span&gt;] = &lt;span class="str"&gt;'This is the name of the link'&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;params&lt;/span&gt;[&lt;span class="str"&gt;'description'&lt;/span&gt;] = &lt;span class="str"&gt;'This is the link description'&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;params&lt;/span&gt;[&lt;span class="str"&gt;'link'&lt;/span&gt;] = &lt;span class="str"&gt;'http://www.URLToNavigateTo.com'&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;params&lt;/span&gt;[&lt;span class="str"&gt;'picture'&lt;/span&gt;] = &lt;span class="str"&gt;'http://www.FULLpathtoimage.com/image.png'&lt;/span&gt;; &lt;span class="rem"&gt;// 90x90 px&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;params&lt;/span&gt;[&lt;span class="str"&gt;'caption'&lt;/span&gt;] = &lt;span class="str"&gt;'Small caption appearing under the link'&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        FB.api(&lt;span class="str"&gt;'/me/feed'&lt;/span&gt;, &lt;span class="str"&gt;'post'&lt;/span&gt;, &lt;span class="kwrd"&gt;params&lt;/span&gt;, function (response) {&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (!response || response.error) {&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="rem"&gt;// Error occured posting to the fb wall&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            }&lt;/pre&gt;&lt;pre class="alt"&gt;        });&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;    } &lt;span class="kwrd"&gt;else&lt;/span&gt; {&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;// User isn't authenticated with facebook&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    }&lt;/pre&gt;&lt;pre&gt;});&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;This will produce the following result&lt;/span&gt;...&lt;br /&gt;&lt;img src="http://3.bp.blogspot.com/-WhIO-HkLcOc/TfjDdf-3BFI/AAAAAAAAADA/8fPc-0NLKDs/s1600/facebookfeedresult.png"&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-2124933948117919228?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/2124933948117919228/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=2124933948117919228' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/2124933948117919228'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/2124933948117919228'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/06/facebook-development-post-to-wall-feed.html' title='Facebook Connect - Post to wall feed'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-WhIO-HkLcOc/TfjDdf-3BFI/AAAAAAAAADA/8fPc-0NLKDs/s72-c/facebookfeedresult.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-2684300877739275766</id><published>2011-06-14T09:29:00.001-07:00</published><updated>2011-06-14T09:33:04.539-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Facebook Development'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>ASP.NET C# 4.0 - Facebook Connect Example</title><content type='html'>&lt;span style="font-weight:bold;"&gt;Facebook connect example&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This is a full example written in ASP.NET 4.0 and Javascript. It uses the Facebook Connect client-side library to authenticate and register uses into a database. This minimalist example explains how to easily integrate Facebook Connect into existing or new web applications.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Technologies used&lt;/span&gt;:&lt;br /&gt;- ASP.NET/C#&lt;br /&gt;- Javascript/JQuery&lt;br /&gt;- AJAX&lt;br /&gt;- SQL Server Compact&lt;br /&gt;- Entity Framework&lt;br /&gt;- LINQ&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Setup Instructions&lt;/span&gt;&lt;br /&gt;1. Add the Developer application to your facebook account and create a new facebook application.&lt;br /&gt;&lt;br /&gt;  Make sure you run the server on port "8080"... Facebook won't argue with this.&lt;br /&gt;  (Note: If you use any other port, other than the standard web traffic ports [80/8080],&lt;br /&gt;  then Facebook will throw a blank proxy dialog at you, with no kind of helpful error messages!&lt;br /&gt;  The URL will contain something like "xd_proxy"...so make sure it's set at 8080!&lt;br /&gt;&lt;br /&gt;  The settings you can use are as follows...&lt;br /&gt;  [Web Site] &gt; [Site URL] &gt; http://localhost:8080/&lt;br /&gt;  [Web Site] &gt; [Site Domain] &gt; localhost&lt;br /&gt;  [Facebook Integration] &gt; [Canvas URL] &gt; http://localhost:8080/&lt;br /&gt;  [Facebook Integration] &gt; [Tab URL] &gt; http://localhost:8080/&lt;br /&gt;  [Advanced] &gt; [Sandbox Mode] &gt; Enable [Note: Must only use developer accounts to test with! or you will get errors]&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2. Enter application details into Web.config.&lt;br /&gt;&lt;br /&gt;3. Enjoy!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Download&lt;/span&gt;&lt;br /&gt;&lt;a href="https://docs.google.com/uc?id=0B6SfMAw6tfpRZGM1N2VhZmYtZTE1NC00MmJkLTg4YmEtYThiNTI5NTZiMDM1&amp;export=download&amp;hl=en_US"&gt;Download Source Files Here&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-2684300877739275766?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/2684300877739275766/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=2684300877739275766' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/2684300877739275766'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/2684300877739275766'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/06/aspnet-c-40-facebook-connect-example.html' title='ASP.NET C# 4.0 - Facebook Connect Example'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-1061994702060707730</id><published>2011-06-10T08:22:00.000-07:00</published><updated>2011-06-10T08:28:07.979-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='CSS'/><title type='text'>CSS: Aligning form fields on a page</title><content type='html'>In the following example, I have used ASP.NET controls as I have lifted this from a project I have been working on.&lt;br /&gt;If you are not familiar with ASP.NET, when the browser renders these server controls, the controls are rendered down to simple HTML tags:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;label (asp:Label)&lt;br /&gt;input (asp:TextBox)&lt;br /&gt;span (asp:RequiredFieldValidator))&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;HTML/ASP.NET Code&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;fieldset&lt;/span&gt; &lt;span class="attr"&gt;class&lt;/span&gt;&lt;span class="kwrd"&gt;="regForm"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt; &lt;span class="attr"&gt;class&lt;/span&gt;&lt;span class="kwrd"&gt;="field"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:Label&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;="lblFirstName"&lt;/span&gt; &lt;span class="attr"&gt;AssociatedControlID&lt;/span&gt;&lt;span class="kwrd"&gt;="txtFirstName"&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="Firstname"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:TextBox&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;="txtFirstName"&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:RequiredFieldValidator&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;="rfvFirstName"&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt; &lt;span class="attr"&gt;ControlToValidate&lt;/span&gt;&lt;span class="kwrd"&gt;="txtFirstName"&lt;/span&gt; &lt;span class="attr"&gt;SetFocusOnError&lt;/span&gt;&lt;span class="kwrd"&gt;="True"&lt;/span&gt; &lt;span class="attr"&gt;ValidationGroup&lt;/span&gt;&lt;span class="kwrd"&gt;="vgRegister"&lt;/span&gt; &lt;span class="attr"&gt;ErrorMessage&lt;/span&gt;&lt;span class="kwrd"&gt;="*"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt; &lt;span class="attr"&gt;class&lt;/span&gt;&lt;span class="kwrd"&gt;="field"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:Label&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;="lblSurname"&lt;/span&gt; &lt;span class="attr"&gt;AssociatedControlID&lt;/span&gt;&lt;span class="kwrd"&gt;="txtSurname"&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="Surname"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:TextBox&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;="txtSurname"&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:RequiredFieldValidator&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;="rfvSurname"&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt; &lt;span class="attr"&gt;ControlToValidate&lt;/span&gt;&lt;span class="kwrd"&gt;="txtSurname"&lt;/span&gt; &lt;span class="attr"&gt;SetFocusOnError&lt;/span&gt;&lt;span class="kwrd"&gt;="True"&lt;/span&gt; &lt;span class="attr"&gt;ValidationGroup&lt;/span&gt;&lt;span class="kwrd"&gt;="vgRegister"&lt;/span&gt; &lt;span class="attr"&gt;ErrorMessage&lt;/span&gt;&lt;span class="kwrd"&gt;="*"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt; &lt;span class="attr"&gt;class&lt;/span&gt;&lt;span class="kwrd"&gt;="field"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:Label&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;="lblEmail"&lt;/span&gt; &lt;span class="attr"&gt;AssociatedControlID&lt;/span&gt;&lt;span class="kwrd"&gt;="txtEmailAddress"&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="Email"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:TextBox&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;="txtEmailAddress"&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:RequiredFieldValidator&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;="rfvEmail"&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt; &lt;span class="attr"&gt;ControlToValidate&lt;/span&gt;&lt;span class="kwrd"&gt;="txtEmailAddress"&lt;/span&gt; &lt;span class="attr"&gt;SetFocusOnError&lt;/span&gt;&lt;span class="kwrd"&gt;="True"&lt;/span&gt; &lt;span class="attr"&gt;ValidationGroup&lt;/span&gt;&lt;span class="kwrd"&gt;="vgRegister"&lt;/span&gt; &lt;span class="attr"&gt;ErrorMessage&lt;/span&gt;&lt;span class="kwrd"&gt;="*"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;fieldset&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;CSS Code&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;fieldset.regForm div {&lt;/pre&gt;&lt;pre&gt;    clear: both;&lt;/pre&gt;&lt;pre class="alt"&gt;    padding-top:0.2em;&lt;/pre&gt;&lt;pre&gt;}&lt;/pre&gt;&lt;pre class="alt"&gt;fieldset.regForm label {&lt;/pre&gt;&lt;pre&gt;    display:inline;&lt;/pre&gt;&lt;pre class="alt"&gt;    padding-top:0.2em;&lt;/pre&gt;&lt;pre&gt;    text-align:right;&lt;/pre&gt;&lt;pre class="alt"&gt;    margin-right:0.5em;&lt;/pre&gt;&lt;pre&gt;    float:left;&lt;/pre&gt;&lt;pre class="alt"&gt;    width:25%;&lt;/pre&gt;&lt;pre&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-1061994702060707730?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/1061994702060707730/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=1061994702060707730' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/1061994702060707730'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/1061994702060707730'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/06/css-aligning-form-fields-on-page.html' title='CSS: Aligning form fields on a page'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-4163064154202666886</id><published>2011-06-10T08:16:00.000-07:00</published><updated>2011-06-10T08:20:34.789-07:00</updated><title type='text'>ASP.NET: Quick and simple client-side validation</title><content type='html'>If you have created some server side controls, some ASP.NET validator controls to go with them, but... you would like to validate on the client, then call the function in the code snippet below from javascript.&lt;br /&gt;Just remember to specify a &lt;span style="font-weight:bold;"&gt;ValidationGroup&lt;/span&gt; on your form fields so the JS function knows which controls to validate&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Code Snippet&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;// By leaving the validation group parameter blank, it will&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;// validate the whole page, not just a target group.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;if&lt;/span&gt; (Page_ClientValidate(&lt;span class="str"&gt;"ValidationGroupNameHere"&lt;/span&gt;)) {&lt;/pre&gt;&lt;pre&gt;   &lt;span class="rem"&gt;// JS Code here...&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-4163064154202666886?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/4163064154202666886/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=4163064154202666886' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/4163064154202666886'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/4163064154202666886'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/06/aspnet-quick-and-simple-client-side.html' title='ASP.NET: Quick and simple client-side validation'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-5200495368659327556</id><published>2011-06-10T08:12:00.000-07:00</published><updated>2011-06-10T08:13:34.062-07:00</updated><title type='text'>Javascript: format() string extension for easy formatting!</title><content type='html'>Here's a simple javascript string extension for easy string formatting&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Code Snippet&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;// Example:&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;//&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;//    var testString = "Hey {0}, this is a pretty {1} string formatter. I hope you have {2} with it!".format("guys", "cool", "fun");&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;//    alert(testString);&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;//&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;// String.format extension for easy formatting&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;String.prototype.format = function () {&lt;/pre&gt;&lt;pre&gt;    var s = &lt;span class="kwrd"&gt;this&lt;/span&gt;,&lt;/pre&gt;&lt;pre class="alt"&gt;        i = arguments.length;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;while&lt;/span&gt; (i--) {&lt;/pre&gt;&lt;pre&gt;        s = s.replace(&lt;span class="kwrd"&gt;new&lt;/span&gt; RegExp(&lt;span class="str"&gt;'\\{'&lt;/span&gt; + i + &lt;span class="str"&gt;'\\}'&lt;/span&gt;, &lt;span class="str"&gt;'gm'&lt;/span&gt;), arguments[i]);&lt;/pre&gt;&lt;pre class="alt"&gt;    }&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;return&lt;/span&gt; s;&lt;/pre&gt;&lt;pre class="alt"&gt;};&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-5200495368659327556?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/5200495368659327556/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=5200495368659327556' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/5200495368659327556'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/5200495368659327556'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/06/javascript-format-string-extension-for.html' title='Javascript: format() string extension for easy formatting!'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-437106515361121216</id><published>2011-06-10T08:04:00.000-07:00</published><updated>2011-06-10T08:07:11.383-07:00</updated><title type='text'>JQuery: Dynamically Add/Remove jquery.ui button from dialog</title><content type='html'>When using the dialog widget within the jquery.ui library, it may become necessary to add or remove buttons dynamically.&lt;br /&gt;Invoking the extension methods below will allow you to achieve the desired result.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Code Snippet&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;// Example:&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;//            $('#IDDialogDiv').dialog('addbutton', 'Name of button');&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;//            $('#IDDialogDiv').dialog('removebutton', 'Name of button');&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;//&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;//&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;// Allows simple button addition to a ui dialog&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;$.extend($.ui.dialog.prototype, {&lt;/pre&gt;&lt;pre&gt;    &lt;span class="str"&gt;'addbutton'&lt;/span&gt;: function (buttonName, func) {&lt;/pre&gt;&lt;pre class="alt"&gt;        var buttons = &lt;span class="kwrd"&gt;this&lt;/span&gt;.element.dialog(&lt;span class="str"&gt;'option'&lt;/span&gt;, &lt;span class="str"&gt;'buttons'&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;        buttons[buttonName] = func;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;this&lt;/span&gt;.element.dialog(&lt;span class="str"&gt;'option'&lt;/span&gt;, &lt;span class="str"&gt;'buttons'&lt;/span&gt;, buttons);&lt;/pre&gt;&lt;pre&gt;    }&lt;/pre&gt;&lt;pre class="alt"&gt;});&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;// Allows simple button removal from a ui dialog&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;$.extend($.ui.dialog.prototype, {&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="str"&gt;'removebutton'&lt;/span&gt;: function (buttonName) {&lt;/pre&gt;&lt;pre&gt;        var buttons = &lt;span class="kwrd"&gt;this&lt;/span&gt;.element.dialog(&lt;span class="str"&gt;'option'&lt;/span&gt;, &lt;span class="str"&gt;'buttons'&lt;/span&gt;);&lt;/pre&gt;&lt;pre class="alt"&gt;        delete buttons[buttonName];&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;this&lt;/span&gt;.element.dialog(&lt;span class="str"&gt;'option'&lt;/span&gt;, &lt;span class="str"&gt;'buttons'&lt;/span&gt;, buttons);&lt;/pre&gt;&lt;pre class="alt"&gt;    }&lt;/pre&gt;&lt;pre&gt;});&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-437106515361121216?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/437106515361121216/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=437106515361121216' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/437106515361121216'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/437106515361121216'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/06/jquery-dynamically-addremove-jqueryui.html' title='JQuery: Dynamically Add/Remove jquery.ui button from dialog'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-8506470875914919296</id><published>2011-06-10T05:35:00.000-07:00</published><updated>2011-06-10T05:40:35.489-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><title type='text'>Javascript: Pass parameter into setTimeout</title><content type='html'>Sometimes passing a parameter into a function, specified within a &lt;span style="font-weight:bold;"&gt;setTimeout()&lt;/span&gt; function isn't so straight forward. Different browser garbage collectors operate differently, and your function sometimes won't be executed at all.&lt;br /&gt;&lt;br /&gt;Here is a method that works in all browsers. You need to specify the function within an anonymous function, and set the parameter to null.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Code Sample&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;var foo = &lt;span class="str"&gt;"Hello World"&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;setTimeout(function () { helloWorld(foo); foo = &lt;span class="kwrd"&gt;null&lt;/span&gt; }, 3000);&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;function helloWorld(foo)&lt;/pre&gt;&lt;pre class="alt"&gt;{&lt;/pre&gt;&lt;pre&gt;    alert(foo);&lt;/pre&gt;&lt;pre class="alt"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-8506470875914919296?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/8506470875914919296/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=8506470875914919296' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/8506470875914919296'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/8506470875914919296'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/06/javascript-pass-parameter-into.html' title='Javascript: Pass parameter into setTimeout'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-2737072687131719945</id><published>2011-06-08T01:49:00.000-07:00</published><updated>2011-06-08T01:51:12.271-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='HTML'/><title type='text'>CKEditor - WYSIWYG editor for web pages</title><content type='html'>CKEditor is a text editor to be used inside web pages. It's a WYSIWYG editor, which means that the text being edited on it looks as similar as possible to the results users have when publishing it. It brings to the web common editing features found on desktop editing applications like Microsoft Word and OpenOffice.&lt;br /&gt;&lt;br /&gt;Because CKEditor is licensed under flexible Open Source and commercial licenses, you'll be able to integrate and use it inside any kind of application. This is the ideal editor for developers, created to provide easy and powerful solutions to their users.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://ckeditor.com" target="_blank"&gt;Download Here&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-2737072687131719945?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/2737072687131719945/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=2737072687131719945' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/2737072687131719945'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/2737072687131719945'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/06/ckeditor-wysiwyg-editor-for-web-pages.html' title='CKEditor - WYSIWYG editor for web pages'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-1857740519131960244</id><published>2011-06-08T01:25:00.002-07:00</published><updated>2011-06-08T01:34:16.559-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='LINQ'/><category scheme='http://www.blogger.com/atom/ns#' term='LinqToXML'/><title type='text'>LinqToXML - Safe element and attribute checking [XElement Extension Method]</title><content type='html'>When using LINQ with XML, you may run into issues where nodes do not exist, values are empty, attribute are either missing or empty also.&lt;br /&gt;&lt;br /&gt;By creating two extension methods for the XElement class, we can provide safe checking for these elements and attributes. Consider the following code snippet below...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Invoking the extension method with LINQ&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;XDocument contentXML = XDocument.Load(xmlPath);&lt;/pre&gt;&lt;pre&gt;var res = from x &lt;span class="kwrd"&gt;in&lt;/span&gt; contentXML.Descendants(&lt;span class="str"&gt;"rootNode"&lt;/span&gt;)&lt;/pre&gt;&lt;pre class="alt"&gt;orderby x.Element(&lt;span class="str"&gt;"title"&lt;/span&gt;).ElementValueNull()&lt;/pre&gt;&lt;pre&gt;select &lt;span class="kwrd"&gt;new&lt;/span&gt; TestObject(x.AttributeValueOrDefault(&lt;span class="str"&gt;"id"&lt;/span&gt;), x.Element(&lt;span class="str"&gt;"title"&lt;/span&gt;).ElementValueNull());&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;XElement Extension class&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;// &amp;lt;copyright file="XElementExtensionMethods.cs" company="GinkoSolutions"&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;// Copyright (c) 2011 All Right Reserved&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;// &amp;lt;/copyright&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;// &amp;lt;author&amp;gt;Sean Greasley&amp;lt;/author&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;// &amp;lt;email&amp;gt;sean@ginkosolutions.com&amp;lt;/email&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;// &amp;lt;summary&amp;gt;Extension methods for the XElement class&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; XElementTest&lt;/pre&gt;&lt;pre&gt;{&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Linq;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Xml;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Xml.Linq;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// Extension methods for the XElement class&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; XElementExtensionMethods&lt;/pre&gt;&lt;pre&gt;    {&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// Allows a safe way to retrieve attribute values from an element&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="element"&amp;gt;A reference to the element object&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="attributeName"&amp;gt;The name of the attribute&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;The attribute content or null&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; AttributeValueOrDefault(&lt;span class="kwrd"&gt;this&lt;/span&gt; XElement element, &lt;span class="kwrd"&gt;string&lt;/span&gt; attributeName)&lt;/pre&gt;&lt;pre&gt;        {&lt;/pre&gt;&lt;pre class="alt"&gt;            XAttribute attr = &lt;span class="kwrd"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (element != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre&gt;                attr = element.Attribute(attributeName);&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; attr == &lt;span class="kwrd"&gt;null&lt;/span&gt; ? &lt;span class="kwrd"&gt;null&lt;/span&gt; : attr.Value;&lt;/pre&gt;&lt;pre class="alt"&gt;        }&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// Allows a safe way to retrieve element data&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="element"&amp;gt;A reference to the element object&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;Element content or an empty string&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; ElementValueNull(&lt;span class="kwrd"&gt;this&lt;/span&gt; XElement element)&lt;/pre&gt;&lt;pre class="alt"&gt;        {&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (element != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;return&lt;/span&gt; element.Value;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty;&lt;/pre&gt;&lt;pre&gt;        }&lt;/pre&gt;&lt;pre class="alt"&gt;    }&lt;/pre&gt;&lt;pre&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-1857740519131960244?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/1857740519131960244/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=1857740519131960244' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/1857740519131960244'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/1857740519131960244'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/06/linqtoxml-safe-element-and-attribute.html' title='LinqToXML - Safe element and attribute checking [XElement Extension Method]'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-4543000482180548100</id><published>2011-06-07T09:15:00.000-07:00</published><updated>2011-06-24T03:35:20.570-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MVC'/><category scheme='http://www.blogger.com/atom/ns#' term='XML'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='XSLT'/><title type='text'>C# MVC 3 - Render XSLT using a HTMLHelper Extension</title><content type='html'>This is an example on how to transform XML documents using XSLT, within C# MVC using a HTMLHelper extension and Razor View Syntax.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Method of operation&lt;/span&gt;&lt;br /&gt;1. View is requested&lt;br /&gt;2. Controller is invoked&lt;br /&gt;3. Controller finds the location of the XML and XSL files for the current request. Parameters are also defined here.&lt;br /&gt;4. The view is created and returned by the controller&lt;br /&gt;5. The view invokes the HTMLExtension method (Razor View Syntax) to render the XML (RenderXSLT method).&lt;br /&gt;6. The extension transforms the document and returns the result.&lt;br /&gt;7. The transformation is displayed within the view.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Controller Method&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; ActionResult Index()&lt;/pre&gt;&lt;pre&gt;        {&lt;/pre&gt;&lt;pre class="alt"&gt;            XsltViewModel model = &lt;span class="kwrd"&gt;new&lt;/span&gt; XsltViewModel()&lt;/pre&gt;&lt;pre&gt;            {&lt;/pre&gt;&lt;pre class="alt"&gt;                XmlPath = Server.MapPath(&lt;span class="str"&gt;"~/PathToXMLFileHere.xslt"&lt;/span&gt;)&lt;/pre&gt;&lt;pre&gt;                XsltPath = Server.MapPath(&lt;span class="str"&gt;"~/PathToXSLTFileHere.xslt"&lt;/span&gt;)&lt;/pre&gt;&lt;pre class="alt"&gt;            };&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; View(model);&lt;/pre&gt;&lt;pre&gt;        }&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Code within the view (calls out extension method using the model info)&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;@model RenderXSLTExample.XsltViewModel&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt; &lt;span class="attr"&gt;class&lt;/span&gt;&lt;span class="kwrd"&gt;="xmlResult"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;/pre&gt;&lt;pre class="alt"&gt;    @Html.RenderXslt(Model.XsltPath, Model.XmlPath)&lt;/pre&gt;&lt;pre&gt;        &lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;section&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;XsltViewModel object (holds reference to XML, XSLT and params)&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;// &amp;lt;copyright file="XsltViewModel.cs" company="GinkoSolutions"&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;// Copyright (c) 2011 All Right Reserved&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;// &amp;lt;/copyright&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;// &amp;lt;author&amp;gt;Sean Greasley&amp;lt;/author&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;// &amp;lt;email&amp;gt;sean@ginkosolutions.com&amp;lt;/email&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;// &amp;lt;summary&amp;gt;Manages XSLT and XML information model objects&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; RenderXSLTExample&lt;/pre&gt;&lt;pre&gt;{&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// Manages XSLT and XML information model objects&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; XsltViewModel&lt;/pre&gt;&lt;pre class="alt"&gt;    {&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// Holds a reference to the XSLT path&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; XsltPath { get; set; }&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// Holds a reference to the XML path&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; XmlPath { get; set; }&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// Optional parameters to pass into the XSL file.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; List&amp;lt;KeyValuePair&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;, &lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;&amp;gt; Params { get; set; }&lt;/pre&gt;&lt;pre&gt;    }&lt;/pre&gt;&lt;pre class="alt"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;HTMLHelper Extension class&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;// &amp;lt;copyright file="HtmlHelperExtensions.cs" company="GinkoSolutions"&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;// Copyright (c) 2011 All Right Reserved&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;// &amp;lt;/copyright&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;// &amp;lt;author&amp;gt;Sean Greasley&amp;lt;/author&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;// &amp;lt;email&amp;gt;sean@ginkosolutions.com&amp;lt;/email&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;// &amp;lt;summary&amp;gt;A HTMLExtension method to render XML using XSL&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; RenderXSLTExample&lt;/pre&gt;&lt;pre&gt;{&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.IO;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Linq;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Reflection;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Text;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Web;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Web.Mvc;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Xml;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Xml.Resolvers;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Xml.Xsl;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Xml.XPath;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// A HTMLExtension method to render XML using XSL&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; HtmlHelperExtensions&lt;/pre&gt;&lt;pre&gt;    {&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// Accepts a reference to the XML and XSL files and applies a transformation with optional&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// parameters.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="helper"&amp;gt;A reference to the HtmlHelper object&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="xsltPath"&amp;gt;The path to the XSL file&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="xmlPath"&amp;gt;The path to the XML file&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="parameters"&amp;gt;Optional: A list  of arguments to pass into the XSL file&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;MvcHtmlString representing the transform&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; MvcHtmlString RenderXslt(&lt;span class="kwrd"&gt;this&lt;/span&gt; HtmlHelper helper, &lt;span class="kwrd"&gt;string&lt;/span&gt; xslPath, &lt;span class="kwrd"&gt;string&lt;/span&gt; xmlPath, List&amp;lt;KeyValuePair&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;, &lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;&amp;gt; parameters = &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre class="alt"&gt;        {&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;string&lt;/span&gt; xsltResult = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;try&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            {&lt;/pre&gt;&lt;pre&gt;                &lt;span class="rem"&gt;// XML Settings&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                XmlReaderSettings xmlSettings = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlReaderSettings();&lt;/pre&gt;&lt;pre&gt;                xmlSettings.XmlResolver = &lt;span class="kwrd"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;                xmlSettings.IgnoreComments = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;                xmlSettings.DtdProcessing = DtdProcessing.Ignore;&lt;/pre&gt;&lt;pre class="alt"&gt;                xmlSettings.ValidationType = ValidationType.None;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="rem"&gt;// Attaches an action to the valiation event handler. This will write out error messages in the Output pane.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                &lt;span class="preproc"&gt;#if&lt;/span&gt; DEBUG&lt;/pre&gt;&lt;pre class="alt"&gt;                xmlSettings.ValidationEventHandler += (sender, e) =&amp;gt;&lt;/pre&gt;&lt;pre&gt;                {&lt;/pre&gt;&lt;pre class="alt"&gt;                    Debug.WriteLine(&lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;"{0}({1},{2}): {3} - {4}"&lt;/span&gt;, e.Exception.SourceUri, e.Exception.LineNumber, e.Exception.LinePosition, e.Severity, e.Message));&lt;/pre&gt;&lt;pre&gt;                };&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="preproc"&gt;#endif&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="rem"&gt;// XSLT Settings&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                XmlReaderSettings xsltSettings = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlReaderSettings();&lt;/pre&gt;&lt;pre class="alt"&gt;                xsltSettings.XmlResolver = &lt;span class="kwrd"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;                xsltSettings.DtdProcessing = DtdProcessing.Ignore;&lt;/pre&gt;&lt;pre class="alt"&gt;                xsltSettings.ValidationType = ValidationType.None;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="rem"&gt;// Attaches an action to the valiation event handler. This will write out error messages in the Output pane.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                &lt;span class="preproc"&gt;#if&lt;/span&gt; DEBUG&lt;/pre&gt;&lt;pre class="alt"&gt;                xsltSettings.ValidationEventHandler += (sender, e) =&amp;gt;&lt;/pre&gt;&lt;pre&gt;                {&lt;/pre&gt;&lt;pre class="alt"&gt;                    Debug.WriteLine(&lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;"{0}({1},{2}): {3} - {4}"&lt;/span&gt;, e.Exception.SourceUri, e.Exception.LineNumber, e.Exception.LinePosition, e.Severity, e.Message));&lt;/pre&gt;&lt;pre&gt;                };&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="preproc"&gt;#endif&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="rem"&gt;// Init params&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                XsltArgumentList xslArgs = &lt;span class="kwrd"&gt;new&lt;/span&gt; XsltArgumentList();&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;if&lt;/span&gt; (parameters != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre&gt;                {&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (KeyValuePair&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;, &lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt; param &lt;span class="kwrd"&gt;in&lt;/span&gt; parameters)&lt;/pre&gt;&lt;pre&gt;                        xslArgs.AddParam(param.Key, &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty, param.Value);&lt;/pre&gt;&lt;pre class="alt"&gt;                }&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="rem"&gt;// Load XML&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                &lt;span class="kwrd"&gt;using&lt;/span&gt; (XmlReader reader = XmlReader.Create(xmlPath, settings))&lt;/pre&gt;&lt;pre class="alt"&gt;                {&lt;/pre&gt;&lt;pre&gt;                    &lt;span class="rem"&gt;// Load XSL&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                    XsltSettings xslSettings = &lt;span class="kwrd"&gt;new&lt;/span&gt; XsltSettings(&lt;span class="kwrd"&gt;true&lt;/span&gt;, &lt;span class="kwrd"&gt;true&lt;/span&gt;); &lt;span class="rem"&gt;// Need to enable the document() fucntion&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="kwrd"&gt;using&lt;/span&gt; (XmlReader xslSource = XmlReader.Create(xslPath, xsltSettings))&lt;/pre&gt;&lt;pre&gt;                    {&lt;/pre&gt;&lt;pre class="alt"&gt;                        XslCompiledTransform xsltDoc = &lt;span class="kwrd"&gt;new&lt;/span&gt; XslCompiledTransform();&lt;/pre&gt;&lt;pre&gt;                        xsltDoc.Load(xslSource, xslSettings, &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlUrlResolver());&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;                        &lt;span class="rem"&gt;// Transform&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                        &lt;span class="kwrd"&gt;using&lt;/span&gt; (var sw = &lt;span class="kwrd"&gt;new&lt;/span&gt; UTF8StringWriter())&lt;/pre&gt;&lt;pre&gt;                        {&lt;/pre&gt;&lt;pre class="alt"&gt;                            XmlWriterSettings settings = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlWriterSettings();&lt;/pre&gt;&lt;pre&gt;                            settings.Encoding = Encoding.UTF8;&lt;/pre&gt;&lt;pre class="alt"&gt;                            settings.OmitXmlDeclaration = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;                            &lt;span class="kwrd"&gt;using&lt;/span&gt; (var xw = XmlWriter.Create(sw, settings))&lt;/pre&gt;&lt;pre&gt;                            {&lt;/pre&gt;&lt;pre class="alt"&gt;                                xsltDoc.Transform(reader, xslArgs, sw);&lt;/pre&gt;&lt;pre&gt;                            }&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;                            xsltResult = sw.ToString();&lt;/pre&gt;&lt;pre class="alt"&gt;                        }&lt;/pre&gt;&lt;pre&gt;                    }&lt;/pre&gt;&lt;pre class="alt"&gt;                }&lt;/pre&gt;&lt;pre&gt;            }&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;catch&lt;/span&gt; { } &lt;span class="rem"&gt;// custom error handling here&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="rem"&gt;// Return result&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; MvcHtmlString.Create(xsltResult);&lt;/pre&gt;&lt;pre class="alt"&gt;        }&lt;/pre&gt;&lt;pre&gt;    }&lt;/pre&gt;&lt;pre class="alt"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-4543000482180548100?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/4543000482180548100/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=4543000482180548100' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/4543000482180548100'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/4543000482180548100'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/06/c-mvc-3-render-xslt-htmlhelper.html' title='C# MVC 3 - Render XSLT using a HTMLHelper Extension'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-9202019625159394130</id><published>2011-06-07T09:07:00.000-07:00</published><updated>2011-06-24T03:28:04.978-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='XML'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='XSLT'/><title type='text'>C#.NET 4 - Transforming XML and XSL documents with settings and  parameters</title><content type='html'>This following example takes a path to an XML file, a path to an XSL file and optional parameters to pass to the XSL file. The XSL file will decorate any &lt;span style="font-weight:bold;"&gt;xsl:param&lt;/span&gt; tags with these values.&lt;br /&gt;&lt;br /&gt;The example also includes settings objects to show how settings can be applied to the tranformation and the loading of the XML.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Example C# Code&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;string&lt;/span&gt; xsltResult = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;try&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;{&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;// XML Settings&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    XmlReaderSettings xmlSettings = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlReaderSettings();&lt;/pre&gt;&lt;pre class="alt"&gt;    xmlSettings.XmlResolver = &lt;span class="kwrd"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;    xmlSettings.IgnoreComments = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;    xmlSettings.DtdProcessing = DtdProcessing.Ignore;&lt;/pre&gt;&lt;pre&gt;    xmlSettings.ValidationType = ValidationType.None;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;// Attaches an action to the valiation event handler. This will write out error messages in the Output pane.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="preproc"&gt;#if&lt;/span&gt; DEBUG&lt;/pre&gt;&lt;pre&gt;    xmlSettings.ValidationEventHandler += (sender, e) =&amp;gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    {&lt;/pre&gt;&lt;pre&gt;        Debug.WriteLine(&lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;"{0}({1},{2}): {3} - {4}"&lt;/span&gt;, e.Exception.SourceUri, e.Exception.LineNumber, e.Exception.LinePosition, e.Severity, e.Message));&lt;/pre&gt;&lt;pre class="alt"&gt;    };&lt;/pre&gt;&lt;pre&gt;    &lt;span class="preproc"&gt;#endif&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;// XSLT Settings&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    XmlReaderSettings xsltSettings = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlReaderSettings();&lt;/pre&gt;&lt;pre&gt;    xsltSettings.XmlResolver = &lt;span class="kwrd"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;    xsltSettings.DtdProcessing = DtdProcessing.Ignore;&lt;/pre&gt;&lt;pre&gt;    xsltSettings.ValidationType = ValidationType.None;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;// Attaches an action to the valiation event handler. This will write out error messages in the Output pane.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="preproc"&gt;#if&lt;/span&gt; DEBUG&lt;/pre&gt;&lt;pre&gt;    xsltSettings.ValidationEventHandler += (sender, e) =&amp;gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    {&lt;/pre&gt;&lt;pre&gt;        Debug.WriteLine(&lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;"{0}({1},{2}): {3} - {4}"&lt;/span&gt;, e.Exception.SourceUri, e.Exception.LineNumber, e.Exception.LinePosition, e.Severity, e.Message));&lt;/pre&gt;&lt;pre class="alt"&gt;    };&lt;/pre&gt;&lt;pre&gt;    &lt;span class="preproc"&gt;#endif&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;// Init params&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    XsltArgumentList xslArgs = &lt;span class="kwrd"&gt;new&lt;/span&gt; XsltArgumentList();&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;if&lt;/span&gt; (parameters != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre class="alt"&gt;    {&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (KeyValuePair&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;, &lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt; param &lt;span class="kwrd"&gt;in&lt;/span&gt; parameters)&lt;/pre&gt;&lt;pre class="alt"&gt;            xslArgs.AddParam(param.Key, &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty, param.Value);&lt;/pre&gt;&lt;pre&gt;    }&lt;/pre&gt;&lt;pre class="alt"&gt; &lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;// Load XML&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; (XmlReader reader = XmlReader.Create(xmlPath, settings))&lt;/pre&gt;&lt;pre&gt;    {&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;// Load XSL&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        XsltSettings xslSettings = &lt;span class="kwrd"&gt;new&lt;/span&gt; XsltSettings(&lt;span class="kwrd"&gt;true&lt;/span&gt;, &lt;span class="kwrd"&gt;true&lt;/span&gt;); &lt;span class="rem"&gt;// Need to enable the document() fucntion&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;using&lt;/span&gt;(XmlReader xslSource = XmlReader.Create(xslPath, xsltSettings))&lt;/pre&gt;&lt;pre class="alt"&gt;        {&lt;/pre&gt;&lt;pre&gt;            XslCompiledTransform xsltDoc = &lt;span class="kwrd"&gt;new&lt;/span&gt; XslCompiledTransform();&lt;/pre&gt;&lt;pre class="alt"&gt;            xsltDoc.Load(xslSource, xslSettings, &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlUrlResolver());&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="rem"&gt;// Transform&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;using&lt;/span&gt; (var sw = &lt;span class="kwrd"&gt;new&lt;/span&gt; UTF8StringWriter())&lt;/pre&gt;&lt;pre class="alt"&gt;            {&lt;/pre&gt;&lt;pre&gt;                        XmlWriterSettings settings = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlWriterSettings();&lt;/pre&gt;&lt;pre class="alt"&gt;                        settings.Encoding = Encoding.UTF8;&lt;/pre&gt;&lt;pre&gt;                        settings.OmitXmlDeclaration = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;                &lt;span class="kwrd"&gt;using&lt;/span&gt;(var xw = XmlWriter.Create(sw,settings))&lt;/pre&gt;&lt;pre class="alt"&gt;                {&lt;/pre&gt;&lt;pre&gt;                    xsltDoc.Transform(reader, xslArgs, sw);&lt;/pre&gt;&lt;pre class="alt"&gt;                }&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;                xsltResult = sw.ToString();&lt;/pre&gt;&lt;pre&gt;            }&lt;/pre&gt;&lt;pre class="alt"&gt;        }&lt;/pre&gt;&lt;pre&gt;    }&lt;/pre&gt;&lt;pre class="alt"&gt;}&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;catch&lt;/span&gt; {} // custom error handling here&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-9202019625159394130?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/9202019625159394130/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=9202019625159394130' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/9202019625159394130'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/9202019625159394130'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/06/c-transforming-xml-and-xsl-documents.html' title='C#.NET 4 - Transforming XML and XSL documents with settings and  parameters'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-4987124139814082585</id><published>2011-06-07T09:01:00.000-07:00</published><updated>2011-06-07T09:06:19.920-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='XML'/><category scheme='http://www.blogger.com/atom/ns#' term='XSLT'/><title type='text'>XSLT - Adding an attribute to an element based on XML data</title><content type='html'>Adding an attribute to an element requires us to utilise the &lt;span style="font-weight:bold;"&gt;xsl:attribute&lt;/span&gt; element.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Consider the following example&lt;/span&gt;:&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;img&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:attribute&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="src"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:value-of&lt;/span&gt; &lt;span class="attr"&gt;select&lt;/span&gt;&lt;span class="kwrd"&gt;="imageURL"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;xsl:attribute&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:attribute&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="alt"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:value-of&lt;/span&gt; &lt;span class="attr"&gt;select&lt;/span&gt;&lt;span class="kwrd"&gt;="altText"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;xsl:attribute&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;img&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;This will add an &lt;span style="font-weight:bold;"&gt;src&lt;/span&gt; and an &lt;span style="font-weight:bold;"&gt;alt&lt;/span&gt; attribute to an &lt;span style="font-weight:bold;"&gt;img&lt;/span&gt; element; based on the values within the &lt;span style="font-weight:bold;"&gt;imageURL&lt;/span&gt; and &lt;span style="font-weight:bold;"&gt;altText&lt;/span&gt; elements in the XML in this example.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Note&lt;/span&gt;: You must make sure that the attributes are added within the element itself. I.e. If the &lt;span style="font-weight:bold;"&gt;img&lt;/span&gt; tag is closed before the attributes are added in the above example, then this would be invalid.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-4987124139814082585?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/4987124139814082585/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=4987124139814082585' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/4987124139814082585'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/4987124139814082585'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/06/xslt-adding-attribute-to-element-based.html' title='XSLT - Adding an attribute to an element based on XML data'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-6252420184524267136</id><published>2011-06-07T08:50:00.000-07:00</published><updated>2011-06-07T08:59:59.755-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='XML'/><category scheme='http://www.blogger.com/atom/ns#' term='XSLT'/><title type='text'>XSLT - Displaying HTML content within XML tags</title><content type='html'>Rather then using the &lt;span style="font-weight:bold;"&gt;value-of&lt;/span&gt; tag, utilise the &lt;span style="font-weight:bold;"&gt;copy-of&lt;/span&gt; tag instead.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;XML File&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="html"&gt;xml&lt;/span&gt; &lt;span class="attr"&gt;version&lt;/span&gt;&lt;span class="kwrd"&gt;="1.0"&lt;/span&gt;?&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="html"&gt;xml-stylesheet&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;="text/xml"&lt;/span&gt; &lt;span class="attr"&gt;href&lt;/span&gt;&lt;span class="kwrd"&gt;="stylesheet.xsl"&lt;/span&gt;?&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;test&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;p&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;b&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;This is bold text in a paragraph&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;b&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;p&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;test&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;XSL File&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:stylesheet&lt;/span&gt; &lt;span class="attr"&gt;version&lt;/span&gt;&lt;span class="kwrd"&gt;="2.0"&lt;/span&gt; &lt;span class="attr"&gt;xmlns:xsl&lt;/span&gt;&lt;span class="kwrd"&gt;="http://www.w3.org/1999/XSL/Transform"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:template&lt;/span&gt; &lt;span class="attr"&gt;match&lt;/span&gt;&lt;span class="kwrd"&gt;="/"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:copy-of&lt;/span&gt; &lt;span class="attr"&gt;select&lt;/span&gt;&lt;span class="kwrd"&gt;="test"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:value-of&lt;/span&gt; &lt;span class="attr"&gt;select&lt;/span&gt;&lt;span class="kwrd"&gt;="test"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;xsl:template&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;xsl:stylesheet&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Output&lt;/span&gt;&lt;br /&gt;&lt;p&gt;&lt;b&gt;This is bold text in a paragraph&lt;/b&gt;&lt;/p&gt;&lt;br /&gt;This is bold text in a paragraph&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-6252420184524267136?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/6252420184524267136/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=6252420184524267136' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/6252420184524267136'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/6252420184524267136'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/06/xslt-display-html-content-with-xml-tags.html' title='XSLT - Displaying HTML content within XML tags'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-8378039016336799659</id><published>2011-06-07T08:20:00.000-07:00</published><updated>2011-06-07T08:46:50.590-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='XML'/><category scheme='http://www.blogger.com/atom/ns#' term='XSLT'/><title type='text'>XSLT - Dynamic Grouping Using the Muenchian Method</title><content type='html'>This blog post describes a full example on how to group XML using the Muenchian Method, using: keys, generate-id() and external parameters [xsl:param] passed into the XSL stylesheet.&lt;br /&gt;&lt;br /&gt;My original requirement was to pass in parameters to the XSL file using C# and transform the XML on-the-fly. Therefore, I used xsl:param tags to hold the input values and generate a portion of XML based on this. I had a few problems matching templates and keys based on parameters, as this is not valid.&lt;br /&gt;I therefore, generated by keys based on all the data and filtered the data I required based on the parameters.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The following code describes a full example using: Parameters, Keys and grouping. The aim is to dynamically group events by year and sort them in a descending order.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Grouping.xml&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="html"&gt;xml&lt;/span&gt; &lt;span class="attr"&gt;version&lt;/span&gt;&lt;span class="kwrd"&gt;="1.0"&lt;/span&gt;?&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="html"&gt;xml-stylesheet&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;="text/xml"&lt;/span&gt; &lt;span class="attr"&gt;href&lt;/span&gt;&lt;span class="kwrd"&gt;="stylesheet.xsl"&lt;/span&gt;?&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;theme&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;styles&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;        &lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;style&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="style1"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Test Style 1&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;elements&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;element&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="element1"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Test Element 1&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;    &lt;/pre&gt;&lt;pre&gt;                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;events&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="event11"&lt;/span&gt; &lt;span class="attr"&gt;date&lt;/span&gt;&lt;span class="kwrd"&gt;="2008-10-13"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Test Event 1&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;                        &lt;/pre&gt;&lt;pre&gt;                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="event12"&lt;/span&gt; &lt;span class="attr"&gt;date&lt;/span&gt;&lt;span class="kwrd"&gt;="2009-03-18"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Test Event 2&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="event13"&lt;/span&gt; &lt;span class="attr"&gt;date&lt;/span&gt;&lt;span class="kwrd"&gt;="2009-02-26"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Test Event 3&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="event14"&lt;/span&gt; &lt;span class="attr"&gt;date&lt;/span&gt;&lt;span class="kwrd"&gt;="2011-04-12"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Test Event 4&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="event15"&lt;/span&gt; &lt;span class="attr"&gt;date&lt;/span&gt;&lt;span class="kwrd"&gt;="2010-01-01"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Test Event 5&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="event16"&lt;/span&gt; &lt;span class="attr"&gt;date&lt;/span&gt;&lt;span class="kwrd"&gt;="2010-07-06"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Test Event 6&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;events&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;                                            &lt;/pre&gt;&lt;pre&gt;                &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;element&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;element&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="element2"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Test Element 2&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;    &lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;events&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="event21"&lt;/span&gt; &lt;span class="attr"&gt;date&lt;/span&gt;&lt;span class="kwrd"&gt;="2001-10-13"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Test Event 1&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;                        &lt;/pre&gt;&lt;pre class="alt"&gt;                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="event22"&lt;/span&gt; &lt;span class="attr"&gt;date&lt;/span&gt;&lt;span class="kwrd"&gt;="2001-03-18"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Test Event 2&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="event23"&lt;/span&gt; &lt;span class="attr"&gt;date&lt;/span&gt;&lt;span class="kwrd"&gt;="2007-02-26"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Test Event 3&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="event24"&lt;/span&gt; &lt;span class="attr"&gt;date&lt;/span&gt;&lt;span class="kwrd"&gt;="2008-04-12"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Test Event 4&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="event25"&lt;/span&gt; &lt;span class="attr"&gt;date&lt;/span&gt;&lt;span class="kwrd"&gt;="2010-01-01"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Test Event 5&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="event26"&lt;/span&gt; &lt;span class="attr"&gt;date&lt;/span&gt;&lt;span class="kwrd"&gt;="2010-07-06"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Test Event 6&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;events&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;                                            &lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;element&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;elements&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;                &lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;style&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;style&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="style2"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Test Style 2&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;elements&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;element&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="element3"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Test Element 3&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;    &lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;events&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="event31"&lt;/span&gt; &lt;span class="attr"&gt;date&lt;/span&gt;&lt;span class="kwrd"&gt;="2003-10-13"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Test Event 1&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;                        &lt;/pre&gt;&lt;pre class="alt"&gt;                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="event32"&lt;/span&gt; &lt;span class="attr"&gt;date&lt;/span&gt;&lt;span class="kwrd"&gt;="2007-03-18"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Test Event 2&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="event33"&lt;/span&gt; &lt;span class="attr"&gt;date&lt;/span&gt;&lt;span class="kwrd"&gt;="2007-02-26"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Test Event 3&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="event34"&lt;/span&gt; &lt;span class="attr"&gt;date&lt;/span&gt;&lt;span class="kwrd"&gt;="2010-04-12"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Test Event 4&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="event35"&lt;/span&gt; &lt;span class="attr"&gt;date&lt;/span&gt;&lt;span class="kwrd"&gt;="2010-01-01"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Test Event 5&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="event36"&lt;/span&gt; &lt;span class="attr"&gt;date&lt;/span&gt;&lt;span class="kwrd"&gt;="2010-07-06"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Test Event 6&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;event&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;events&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;                                            &lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;element&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;                &lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;elements&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;                &lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;style&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;styles&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;theme&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Stylesheet.xsl&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:stylesheet&lt;/span&gt; &lt;span class="attr"&gt;version&lt;/span&gt;&lt;span class="kwrd"&gt;="2.0"&lt;/span&gt; &lt;span class="attr"&gt;xmlns:xsl&lt;/span&gt;&lt;span class="kwrd"&gt;="http://www.w3.org/1999/XSL/Transform"&lt;/span&gt; &lt;span class="attr"&gt;xmlns:ms&lt;/span&gt;&lt;span class="kwrd"&gt;="urn:schemas-microsoft-com:xslt"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;  &lt;span class="rem"&gt;&amp;lt;!-- Parameters --&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:param&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="style"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;style1&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;xsl:param&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:param&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="element"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;element1&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;xsl:param&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;  &lt;span class="rem"&gt;&amp;lt;!-- Create a key based on the YYYY portion of the start_date attribute --&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:key&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="keyYear"&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="attr"&gt;match&lt;/span&gt;&lt;span class="kwrd"&gt;="events/event"&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="attr"&gt;use&lt;/span&gt;&lt;span class="kwrd"&gt;="substring(@date, 1, 4)"&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;  &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:key&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="keyEventID"&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="attr"&gt;match&lt;/span&gt;&lt;span class="kwrd"&gt;="events/event"&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="attr"&gt;use&lt;/span&gt;&lt;span class="kwrd"&gt;="@id"&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;  &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;  &lt;span class="rem"&gt;&amp;lt;!-- Match default template --&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:template&lt;/span&gt; &lt;span class="attr"&gt;match&lt;/span&gt;&lt;span class="kwrd"&gt;="/"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:apply-templates&lt;/span&gt; &lt;span class="attr"&gt;select&lt;/span&gt;&lt;span class="kwrd"&gt;="/theme/styles/style[@id=$style]/elements/element[@id=$element]/events"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;xsl:template&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;  &lt;span class="rem"&gt;&amp;lt;!-- matches on events, so only outputs once [per stream] --&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:template&lt;/span&gt; &lt;span class="attr"&gt;match&lt;/span&gt;&lt;span class="kwrd"&gt;="events"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;table&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:for-each&lt;/span&gt; &lt;span class="attr"&gt;select&lt;/span&gt;&lt;span class="kwrd"&gt;="//event[generate-id()=generate-id(key('keyYear', substring(@date, 1, 4))[1])]"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:sort&lt;/span&gt; &lt;span class="attr"&gt;select&lt;/span&gt;&lt;span class="kwrd"&gt;="substring(@date, 1, 4)"&lt;/span&gt; &lt;span class="attr"&gt;order&lt;/span&gt;&lt;span class="kwrd"&gt;="descending"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;&amp;lt;!-- Save the Year to a variable --&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:variable&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="varCurrentYear"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:value-of&lt;/span&gt; &lt;span class="attr"&gt;select&lt;/span&gt;&lt;span class="kwrd"&gt;="substring(@date, 1, 4)"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;xsl:variable&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;&amp;lt;!-- Select all the events belonging to the year --&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:variable&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="lstEventPerYear"&lt;/span&gt; &lt;span class="attr"&gt;select&lt;/span&gt;&lt;span class="kwrd"&gt;="/theme/styles/style[@id=$style]/elements/element[@id=$element]/events/event[substring(@date, 1, 4)=$varCurrentYear]"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;&amp;lt;!-- Store child count --&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:variable&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="varChildCount"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:value-of&lt;/span&gt; &lt;span class="attr"&gt;select&lt;/span&gt;&lt;span class="kwrd"&gt;="count($lstEventPerYear[generate-id(.) = generate-id(key('keyEventID', @id)[1])])"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;xsl:variable&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;&amp;lt;!-- Output year only if there are sub elements --&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:if&lt;/span&gt; &lt;span class="attr"&gt;test&lt;/span&gt;="$&lt;span class="attr"&gt;varChildCount&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; 0"&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;tr&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;h3&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:value-of&lt;/span&gt; &lt;span class="attr"&gt;select&lt;/span&gt;&lt;span class="kwrd"&gt;="$varCurrentYear"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;h3&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;tr&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;          &lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:for-each&lt;/span&gt; &lt;span class="attr"&gt;select&lt;/span&gt;&lt;span class="kwrd"&gt;="$lstEventPerYear[generate-id(.) = generate-id(key('keyEventID', @id)[1])]"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:sort&lt;/span&gt; &lt;span class="attr"&gt;select&lt;/span&gt;&lt;span class="kwrd"&gt;="title"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;     &lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;tr&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;h4&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:value-of&lt;/span&gt; &lt;span class="attr"&gt;select&lt;/span&gt;&lt;span class="kwrd"&gt;="title"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                          &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:text&lt;/span&gt; &lt;span class="attr"&gt;disable-output-escaping&lt;/span&gt;&lt;span class="kwrd"&gt;="yes"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;span class="attr"&gt;&amp;amp;amp;&lt;/span&gt;nbsp;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;xsl:text&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                        [&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xsl:value-of&lt;/span&gt; &lt;span class="attr"&gt;select&lt;/span&gt;&lt;span class="kwrd"&gt;="ms:format-date(@date, 'dd MMM yyyy')"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;]&lt;/pre&gt;&lt;pre&gt;                    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;h4&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;tr&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;             &lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;xsl:for-each&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;xsl:if&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;      &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;xsl:for-each&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;table&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;xsl:template&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;xsl:stylesheet&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-8378039016336799659?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/8378039016336799659/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=8378039016336799659' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/8378039016336799659'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/8378039016336799659'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/06/xslt-dynamic-grouping-using-muenchian.html' title='XSLT - Dynamic Grouping Using the Muenchian Method'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-8022065986335862021</id><published>2011-05-25T02:39:00.000-07:00</published><updated>2011-06-13T08:47:13.737-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Facebook Development'/><category scheme='http://www.blogger.com/atom/ns#' term='Visual Studio'/><title type='text'>Developing Facebook Applications locally</title><content type='html'>&lt;span style="font-weight:bold;"&gt;Hosts File [C:\Windows\System32\drivers\etc]&lt;/span&gt;&lt;br /&gt;1. Edit the windows hosts file&lt;br /&gt;&lt;br /&gt;2. Add an entry to map to localhost (127.0.0.1). This url name can be anything, it’s so that when you re-direct your browser to this url, it will forward directly to localhost. This matches the Facebook canvas URL schema that is required.&lt;br /&gt;&lt;br /&gt;Example: "127.0.0.1 bigblunts.com"   (without quotes)&lt;br /&gt;&lt;br /&gt;3. Save and close the hosts file. If you do not have permissions to do this, open Notepad (or any other text editor) as an Administrator, and try again.&lt;br /&gt;&lt;br /&gt;4. Open your web browser and go to the url you have just added, the browser should be displaying the same as if your went to http://localhost (This should usually be the IIS homepage).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Web Server Configuration&lt;/span&gt;&lt;br /&gt;I personally use .NET and IIS, but you can really use which ever development tools and web servers you like. Just ensure that the application is accessible through the localhost.&lt;br /&gt;&lt;br /&gt;So for example, if you access your application via. http://localhost/FacebookApp (Where 'FacebookApp' is the application configured within your webserver) Then using the settings in your hosts file, this will also work for you: http://bigblunts.com/FacebookApp. This will be the URL that you will be adding within your Facebook application settings.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Facebook Settings&lt;/span&gt;&lt;br /&gt;1. I usually create a new Facebook application and append "staging" to the name. This saves me having to change canvas urls and other things to point to different environments each time I want to deploy something.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The Facebook settings are as follows [as of May 2011]:&lt;br /&gt;Replace the vales with the name of your webserver path...&lt;br /&gt;[Web Site] &gt; [Site URL] &gt; http://bigblunts.com/FacebookApp/&lt;br /&gt;[Web Site] &gt; [Site Domain] &gt; bigblunts.com&lt;br /&gt;[Facebook Integration] &gt; [Canvas URL] &gt; http://bigblunts.com/FacebookApp/&lt;br /&gt;[Facebook Integration] &gt; [Tab URL] &gt; http://bigblunts.com/FacebookApp/ [When integrating with pages, it'll use this as the menu item/tab name]&lt;br /&gt;[Advanced] &gt; [Sandbox Mode] &gt; Enable [Note: Must only use developer accounts to test with! or you will get errors]&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Some of the settings may be irrelevant for your application requirements, but this is where to specify the URLs when these features are required.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;!!!!UPDATE!!!!&lt;/span&gt;&lt;br /&gt;You can also use the visual studio development server to get around this problem (or any other server, just use port 8080!)&lt;br /&gt;&lt;br /&gt;Make sure you run the server on port "8080"... Facebook won't argue with this. (Note: If you use any other port, other than the standard web traffic ports [80/8080], then Facebook will throw a blank proxy dialog at you, with no kind of helpful error messages! The URL will contain something like "xd_proxy"...so make sure it's set at 8080!&lt;br /&gt;&lt;br /&gt;The settings you can use are as follows...&lt;br /&gt;[Web Site] &gt; [Site URL] &gt; http://localhost:8080/&lt;br /&gt;[Web Site] &gt; [Site Domain] &gt; localhost&lt;br /&gt;[Facebook Integration] &gt; [Canvas URL] &gt; http://localhost:8080/&lt;br /&gt;[Facebook Integration] &gt; [Tab URL] &gt; http://localhost:8080/&lt;br /&gt;[Advanced] &gt; [Sandbox Mode] &gt; Enable [Note: Must only use developer accounts to test with! or you will get errors]&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-8022065986335862021?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/8022065986335862021/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=8022065986335862021' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/8022065986335862021'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/8022065986335862021'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/05/developing-facebook-applications.html' title='Developing Facebook Applications locally'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-968919129927074536</id><published>2011-04-08T02:20:00.000-07:00</published><updated>2011-04-08T02:40:59.976-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>C#: DescriptionAttribute with Enums</title><content type='html'>If you've ever created an Enum, usually the entities you define within the enum are not user friendly. I.e. outputting to the console "EnumDescEntityTwo". We would probably prefer it to have whitespaces "Enum Desc Entity Two" or even be called something totally different "Cheese Sandwich".&lt;br /&gt;&lt;br /&gt;So there are a few ways to achieve this without writing a bunch of conditions in the GUI layer.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;1. Map the Enums to database table.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I.e.&lt;br /&gt;- ID (For DB use only)&lt;br /&gt;- EnumID (Maps onto the Enum value)&lt;br /&gt;- EnumDescription (A description representing the enum)&lt;br /&gt;&lt;br /&gt;The only bad thing is that a database call must be made at some point to gather the description. But the good things are that these values will not be hardcoded.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;2. Use Attributes&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Like any attributes in .NET, we can define a custom attribute class by defining a class and inheriting the "System.Attribute" base class. However, .NET already provides a DescriptionAttribute class for cases like these in the "System.ComponentModel" namespace.&lt;br /&gt;&lt;br /&gt;[Example]&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;a) Define your enum&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.ComponentModel;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;enum&lt;/span&gt; FoodItems&lt;/pre&gt;&lt;pre&gt;    {&lt;/pre&gt;&lt;pre class="alt"&gt;        [DescriptionAttribute(&lt;span class="str"&gt;"A Specialist Bacon Roll"&lt;/span&gt;)]&lt;/pre&gt;&lt;pre&gt;        BaconRollWithBurgerSauce = 1,&lt;/pre&gt;&lt;pre class="alt"&gt;        [DescriptionAttribute(&lt;span class="str"&gt;"Burning Hot Chilli"&lt;/span&gt;)]&lt;/pre&gt;&lt;pre&gt;        HotChilliBurningHot = 2,&lt;/pre&gt;&lt;pre class="alt"&gt;        [DescriptionAttribute(&lt;span class="str"&gt;"Sixty Inch Pizza with Everything!"&lt;/span&gt;)]&lt;/pre&gt;&lt;pre&gt;        SixtyInchPizzaWithEverythingOnIt = 3&lt;/pre&gt;&lt;pre class="alt"&gt;    }&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;b) Use reflection to get the description attribute&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;// Get the descrption attribute for the status&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;FoodItem item = FoodItem.BaconRollWithBurgerSauce;&lt;/pre&gt;&lt;pre class="alt"&gt;FieldInfo fi = &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(FoodItem).GetField(Enum.GetName(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(FoodItem), item));&lt;/pre&gt;&lt;pre&gt;DescriptionAttribute da = (DescriptionAttribute)fi.GetCustomAttributes(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(DescriptionAttribute), &lt;span class="kwrd"&gt;false&lt;/span&gt;)[0];&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;string&lt;/span&gt; desc = da.Description;&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-968919129927074536?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/968919129927074536/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=968919129927074536' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/968919129927074536'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/968919129927074536'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/04/c-descriptionattribute-with-enums.html' title='C#: DescriptionAttribute with Enums'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-2743130631018265408</id><published>2011-03-28T04:15:00.001-07:00</published><updated>2011-03-28T04:15:49.427-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PL/SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='T-SQL'/><title type='text'>JOINS - Which is which!?</title><content type='html'>Amazing post about different joins represented by a Venn Diagram.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.codinghorror.com/blog/2007/10/a-visual-explanation-of-sql-joins.html"&gt;http://www.codinghorror.com/blog/2007/10/a-visual-explanation-of-sql-joins.html&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-2743130631018265408?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/2743130631018265408/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=2743130631018265408' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/2743130631018265408'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/2743130631018265408'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/03/joins-which-is-which.html' title='JOINS - Which is which!?'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-206196377603736374</id><published>2011-03-14T03:26:00.000-07:00</published><updated>2011-03-14T03:28:15.662-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='T-SQL'/><title type='text'>T-SQL: How to rename a table or column using T-SQL in Microsoft SQL</title><content type='html'>So yeah, you could use the Microsoft SQL Server Management Studio UI to rename your table or column. But sometimes you need to do the rename in T-SQL. Here’s how.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;How to rename a table:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;EXEC&lt;/span&gt; sp_rename &lt;span class="str"&gt;'OldTableName'&lt;/span&gt;,&lt;span class="str"&gt;'NewTableName'&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;How to rename a column:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;EXEC&lt;/span&gt; sp_rename&lt;br /&gt;    @objname = &lt;span class="str"&gt;'TableName.OldColumnName'&lt;/span&gt;,&lt;br /&gt;    @newname = &lt;span class="str"&gt;'NewColumnName'&lt;/span&gt;,&lt;br /&gt;    @objtype = &lt;span class="str"&gt;'COLUMN'&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;For a more detailed explanation of sp_rename check out this MSDN article: &lt;a href="http://msdn2.microsoft.com/en-us/library/ms188351.aspx"&gt;http://msdn2.microsoft.com/en-us/library/ms188351.aspx&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-206196377603736374?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/206196377603736374/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=206196377603736374' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/206196377603736374'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/206196377603736374'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/03/t-sql-how-to-rename-table-or-column.html' title='T-SQL: How to rename a table or column using T-SQL in Microsoft SQL'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-4187539532781289284</id><published>2011-03-11T01:49:00.001-08:00</published><updated>2011-03-11T01:49:48.635-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Web Services'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><title type='text'>.NET: Take Securing Web Services With Username and Password One Step Further With a Custom SoapExtension</title><content type='html'>Brilliant page and explains everything&lt;br /&gt;&lt;br /&gt;&lt;a href="http://keithelder.net/2007/01/09/"&gt;http://keithelder.net/2007/01/09/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-4187539532781289284?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/4187539532781289284/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=4187539532781289284' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/4187539532781289284'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/4187539532781289284'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/03/net-take-securing-web-services-with.html' title='.NET: Take Securing Web Services With Username and Password One Step Further With a Custom SoapExtension'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-3208629923431506252</id><published>2011-03-09T05:14:00.000-08:00</published><updated>2011-03-09T08:05:14.164-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='LinqToSQL'/><title type='text'>LinqToSql: ForeignKeyReferenceAlreadyHasValueException</title><content type='html'>I recently had an error with a project while attempting to modify a foreign key for a database object. Quite simply, once the foreign key was established, if any chances were made to it, it would throw this exception. This is correct by design! So in theory, the initial insert is fine, but any update made will throw this error.&lt;br /&gt;&lt;br /&gt;The resolve this issue, open up the linq designer file (dbml) and modify the association between the table and its foreign counterpart. If you set 'Child Property' to true, this will allow you to add this association as a property to the database object for your class.&lt;br /&gt;&lt;br /&gt;So in the code, instead of editing the foreign key&lt;br /&gt;&lt;br /&gt;i.e. Object.ForeignKeyID = id;&lt;br /&gt;&lt;br /&gt;You need to make a call using the same data context to retrieve the object, and set it to the property you have just created for your assoication.&lt;br /&gt;&lt;br /&gt;i.e. Object.AssociationName = dataContext.Table.Single(val = val.id == idhere);&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-3208629923431506252?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/3208629923431506252/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=3208629923431506252' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/3208629923431506252'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/3208629923431506252'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/03/linqtosql-foreignkeyreferencealreadyhas.html' title='LinqToSql: ForeignKeyReferenceAlreadyHasValueException'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-8794849893961508807</id><published>2011-02-17T06:54:00.000-08:00</published><updated>2011-02-17T07:00:42.593-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Hackintosh'/><title type='text'>Fix External Display issues (mirrored) with Hackintosh [Dell 10v mini]</title><content type='html'>Hi,&lt;br /&gt;&lt;br /&gt;I recently bought a Hackintosh (Dell 10v Mini with Snow Leopard installed) to do some iPhone development. It almost becomes necessary to attach an external monitor to the system to see all of XCode interfaces.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Warning&lt;/span&gt;: Do not click mirror displays&lt;br /&gt;&lt;br /&gt;If your still reading, that means you have clicked mirrored displays, and you are getting either:&lt;br /&gt;&lt;br /&gt;1. Random lines/bugged image on the notebook screen, and the external monitor either showing the same, on standby or showing signal out of range.&lt;br /&gt;2. Dell mini LCD displays solid white and even when unplugging the monitor, it remains until you do a hard reset.&lt;br /&gt;3. Other annoying things.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;So, you may have noticed you can't turn off mirroring until you have an external display attached, even more annoying right? Initially I located all com.apple.WindowServer* files and set the mirroring property to '0'. This works, but it can take a while.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Heres a better solution!&lt;/span&gt;&lt;br /&gt;&lt;a href="http://www.fabiancanas.com/Projects/MirrorDisplays/"&gt;http://www.fabiancanas.com/Projects/MirrorDisplays/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Just run the application, the terminal window will say it has been processed successfully. Then simply plug in your external monitor. Great!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-8794849893961508807?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/8794849893961508807/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=8794849893961508807' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/8794849893961508807'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/8794849893961508807'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/02/fix-external-display-issues-mirrored.html' title='Fix External Display issues (mirrored) with Hackintosh [Dell 10v mini]'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-6898649799096411922</id><published>2011-01-24T08:49:00.001-08:00</published><updated>2011-01-24T09:04:04.359-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Encoding'/><title type='text'>H.264 FLV to MP4 without Re-Encoding</title><content type='html'>I have had an issue recently where I would like to produce MP4 files for my corresponding FLV files, preferably a batch process (as I have a fair few) without re-encoding. After all, I knew my FLV files were all H.264 and the FLV was only the container; so I didn't see why I needed to re-encode the whole batch and potentially lose further quality.&lt;br /&gt;&lt;br /&gt;This is when I stumbled upon FLV Extract. This is an amazing tool, downloadable source as well, written in C#. This allows me to extract the video and audio streams for a FLV file. This will produce corresponding .264 and .ACC/.MP3 files. Excellent!&lt;br /&gt;&lt;br /&gt;With these files, I now needed a way to generate my MP4 file. This is where MP4Box became quite handy. It will produce a nice MP4 container for .264 and .AAC files, even more amazing!&lt;br /&gt;&lt;br /&gt;I now needed a way to batch this up. I opened up Notepad and drafted a quick batch script. This will search the current directory for all .FLV files, ensure the .264 and .aac/.mp3 files have been produced, run them through MP4Box, and drop the MP4's into a complete directory. It will then clean up the temporary files afterwards.&lt;br /&gt;It works pretty well, I have added some brief instruction, and you can download the full package here.&lt;br /&gt;&lt;br /&gt;For a 100mb video, it can take around ~5-10seconds on an average system.&lt;br /&gt;&lt;br /&gt;&lt;a href="https://docs.google.com/uc?id=0B6SfMAw6tfpRMGFhZmRhYTQtZTA0YS00Y2IwLWFkM2QtYWZmMTU0YzVhMjI2&amp;export=download&amp;hl=en"&gt;H.264 FLV to MP4 (Without Re-encoding) Download Here&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-6898649799096411922?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/6898649799096411922/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=6898649799096411922' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/6898649799096411922'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/6898649799096411922'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2011/01/h264-flv-to-mp4-without-re-encoding.html' title='H.264 FLV to MP4 without Re-Encoding'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-145882906497733563</id><published>2010-12-16T08:35:00.001-08:00</published><updated>2010-12-16T08:36:03.995-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><title type='text'>[ASP.NET] Pass your own arguments to the ClientValidationFunction in a CustomValidator</title><content type='html'>When using a CustomValidator in asp.net you can specify a ClientValidationFunction to run on your client side. This function need to have 2 parameters (sender, args). The sender is the customvalidator control and the args is where you can specify the result of your validation(args.IsValid) and also access to the value of the control attached to you custom validator(args.Value). This is very useful for more complex validation on client side.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://alejandrobog.wordpress.com/2009/09/27/pass-your-own-arguments-to-the-clientvalidationfunction-in-a-customvalidator/"&gt;http://alejandrobog.wordpress.com/2009/09/27/pass-your-own-arguments-to-the-clientvalidationfunction-in-a-customvalidator/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-145882906497733563?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/145882906497733563/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=145882906497733563' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/145882906497733563'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/145882906497733563'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/12/aspnet-pass-your-own-arguments-to.html' title='[ASP.NET] Pass your own arguments to the ClientValidationFunction in a CustomValidator'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-7794083211337489201</id><published>2010-12-16T04:39:00.000-08:00</published><updated>2010-12-17T03:09:32.542-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>[.NET] Determining File Mime Types (Correctly!)</title><content type='html'>If you have used an ASP.NET upload control, you may have been reliant on getting the &lt;span style="font-weight:bold;"&gt;ContentType&lt;/span&gt; property and making security decisions based on the value from that. However, this isn't truly accurate.&lt;br /&gt;What .NET does here is take the uploaded file and look at the file extension. It will then feed the extension into a mime library and generate the relevant content type.&lt;br /&gt;&lt;br /&gt;I.e.&lt;br /&gt;Upload a &lt;span style="font-weight:bold;"&gt;.doc &lt;/span&gt;file - ContentType will read: "&lt;span style="font-weight:bold;"&gt;application/msword&lt;/span&gt;"&lt;br /&gt;&lt;br /&gt;For this to fail, we could rename an executable file (&lt;span style="font-weight:bold;"&gt;.exe&lt;/span&gt;) to a .doc and upload it. The ContentType will still be &lt;span style="font-weight:bold;"&gt;application/msword&lt;/span&gt; as it's based off the extension.&lt;br /&gt;&lt;br /&gt;To overcome this problem, there are two methods we can use. Both of them involve peeking into the file and fetching some data relevant to it's type. So there is a natural trade-off with performance vs. security.&lt;br /&gt;&lt;br /&gt;The first example below uses InterOp, and gives us an accurate mime type for the file. The second example uses feature codes, the only down side to using this is where you wish to accept doc and ppt but not xls. This isn't possible as these all share the same feature code (see below).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Two Examples to make decisions based on file/mime type&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;[System.Runtime.InteropServices.DllImport(&lt;span class="str"&gt;"urlmon.dll"&lt;/span&gt;, CharSet = System.Runtime.InteropServices.CharSet.Unicode, ExactSpelling = &lt;span class="kwrd"&gt;true&lt;/span&gt;, SetLastError = &lt;span class="kwrd"&gt;false&lt;/span&gt;)]&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;extern&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; FindMimeFromData(IntPtr pBC,&lt;/pre&gt;&lt;pre class="alt"&gt;[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)] &lt;span class="kwrd"&gt;string&lt;/span&gt; pwzUrl,&lt;/pre&gt;&lt;pre&gt;[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPArray, ArraySubType = System.Runtime.InteropServices.UnmanagedType.I1, SizeParamIndex = 3)] &lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;byte&lt;/span&gt;[] pBuffer, &lt;span class="kwrd"&gt;int&lt;/span&gt; cbSize,&lt;/pre&gt;&lt;pre&gt;[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)] &lt;span class="kwrd"&gt;string&lt;/span&gt; pwzMimeProposed, &lt;span class="kwrd"&gt;int&lt;/span&gt; dwMimeFlags, &lt;span class="kwrd"&gt;out&lt;/span&gt; IntPtr ppwzMimeOut, &lt;span class="kwrd"&gt;int&lt;/span&gt; dwReserved);&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;/// Ensures that file exists and retrieves the mime type&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;/// &amp;lt;param name="fileName"&amp;gt;Full path to the file&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;Returns the Mime Type&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; GetMimeFromFile(&lt;span class="kwrd"&gt;string&lt;/span&gt; fileName)&lt;/pre&gt;&lt;pre&gt;{&lt;/pre&gt;&lt;pre class="alt"&gt;    IntPtr mimeout;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;if&lt;/span&gt; (!System.IO.File.Exists(fileName))&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; System.IO.FileNotFoundException(fileName + &lt;span class="str"&gt;" not found"&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;int&lt;/span&gt; MaxContent = (&lt;span class="kwrd"&gt;int&lt;/span&gt;)&lt;span class="kwrd"&gt;new&lt;/span&gt; System.IO.FileInfo(fileName).Length;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;if&lt;/span&gt; (MaxContent &amp;gt; 4096) MaxContent = 4096;&lt;/pre&gt;&lt;pre class="alt"&gt;    System.IO.FileStream fs = System.IO.File.OpenRead(fileName);&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;byte&lt;/span&gt;[] buf = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;byte&lt;/span&gt;[MaxContent];&lt;/pre&gt;&lt;pre&gt;    fs.Read(buf, 0, MaxContent);&lt;/pre&gt;&lt;pre class="alt"&gt;    fs.Close();&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;int&lt;/span&gt; result = FindMimeFromData(IntPtr.Zero, fileName, buf, MaxContent, &lt;span class="kwrd"&gt;null&lt;/span&gt;, 0, &lt;span class="kwrd"&gt;out&lt;/span&gt; mimeout, 0);&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;if&lt;/span&gt; (result != 0)&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;throw&lt;/span&gt; System.Runtime.InteropServices.Marshal.GetExceptionForHR(result);&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;string&lt;/span&gt; mime = System.Runtime.InteropServices.Marshal.PtrToStringUni(mimeout);&lt;/pre&gt;&lt;pre&gt;    System.Runtime.InteropServices.Marshal.FreeCoTaskMem(mimeout);&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;return&lt;/span&gt; mime;&lt;/pre&gt;&lt;pre class="alt"&gt;}&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;/// Reads the file to determine the feature code.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;///     /* Extension name specification [Feature codes]&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;///     *7173        gif  &lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;///     *255216      jpg &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;///     *13780       png &lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;///     *6677        bmp &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;///     *239187      txt,aspx,asp,sql &lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;///     *208207      xls,doc,ppt &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;///     *6063        xml &lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;///     *6033        htm,html &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;///     *4742        js &lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;///     *8075        xlsx,docx,pptx,mmap,zip,msi&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;///     *8297        rar&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;///     *01          accdb,mdb &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;///     *7790        exe,dll&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;///     *5666        psd  &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;///     *255254      rdp  &lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;///     *10056       bt  &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;///     *64101       bat&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;///     *3780        pdf&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;///     */&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;/// &amp;lt;param name="hifile"&amp;gt;Posted file following the upload process&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;Returns weather the file type is allowed&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; IsAllowedExtension(HttpPostedFile hifile)&lt;/pre&gt;&lt;pre class="alt"&gt;{&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;bool&lt;/span&gt; ret = &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;    System.IO.BinaryReader r = &lt;span class="kwrd"&gt;new&lt;/span&gt; System.IO.BinaryReader(hifile.InputStream);&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;string&lt;/span&gt; fileclass = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;byte&lt;/span&gt; buffer;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;try&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    {&lt;/pre&gt;&lt;pre&gt;    buffer = r.ReadByte();&lt;/pre&gt;&lt;pre class="alt"&gt;    fileclass = buffer.ToString();&lt;/pre&gt;&lt;pre&gt;    buffer = r.ReadByte();&lt;/pre&gt;&lt;pre class="alt"&gt;    fileclass += buffer.ToString();&lt;/pre&gt;&lt;pre&gt;    }&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;catch&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    {&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;    }&lt;/pre&gt;&lt;pre class="alt"&gt;    r.Close();&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;    String[] fileType = {&lt;span class="str"&gt;"208207"&lt;/span&gt;, &lt;span class="str"&gt;"8075"&lt;/span&gt;, &lt;span class="str"&gt;"3780"&lt;/span&gt;}; &lt;span class="rem"&gt;// Place allowed file types here&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 0; i &amp;lt; fileType.Length; i++)&lt;/pre&gt;&lt;pre&gt;    {&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;if&lt;/span&gt; (fileclass == fileType[i])&lt;/pre&gt;&lt;pre&gt;    {&lt;/pre&gt;&lt;pre class="alt"&gt;        ret = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;    }&lt;/pre&gt;&lt;pre&gt;    }&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;return&lt;/span&gt; ret;&lt;/pre&gt;&lt;pre class="alt"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-7794083211337489201?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/7794083211337489201/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=7794083211337489201' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/7794083211337489201'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/7794083211337489201'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/12/net-determining-file-mime-types.html' title='[.NET] Determining File Mime Types (Correctly!)'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-1068285818973421066</id><published>2010-11-26T02:13:00.000-08:00</published><updated>2010-11-26T02:19:31.552-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='AJAX'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><title type='text'>AJAX - ASP.NET : Call WebMethod defined in User Control</title><content type='html'>If you have welcomed the joys of AJAX into your ASP.NET application, you may or may not have come across this problem.&lt;br /&gt;&lt;br /&gt;With AJAX calls, I tend to store the WebMethod within the ASPX pages rather than services; so that I can keep my logic relating to the page separate from everything else. There is nothing worse than having a global service with tens or hundreds of methods in that get called every time. (well maybe there is, but you see my point!)&lt;br /&gt;&lt;br /&gt;However, where user controls are concerned, we have a slight problem. A limitation of the framework prevents us from calling a WebMethod defined in a User Control (as of .NET 3.5). Some people have suggested adding a proxy method to the page which hosts the user control to call a method within the user control. This is wrong on many levels as it ties the page to the control and defeats the purpose or re-usability with ease.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Solution&lt;/span&gt;&lt;br /&gt;Instead of a page method, add a service method instead. Either an ASMX or an SVC, it doesn't really matter. These are useful to hosting WebMethods that can be reused by many pages within the application OR user controls (which are re-usable by design anyway).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-1068285818973421066?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/1068285818973421066/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=1068285818973421066' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/1068285818973421066'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/1068285818973421066'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/11/ajax-aspnet-call-webmethod-defined-in.html' title='AJAX - ASP.NET : Call WebMethod defined in User Control'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-6873467659562132175</id><published>2010-11-25T07:15:00.000-08:00</published><updated>2010-11-25T07:24:23.700-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><title type='text'>asp:menu - Fix submenu appearing as a white box [IE8+]</title><content type='html'>If you have an asp:menu control as part of your ASP.NET application, you will notice that the sub menu appears as a white box and your content isn't visible. This is quite crucial if this is the only access point to your web pages!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Solutions&lt;/span&gt;&lt;br /&gt;1. Add &lt;span style="font-weight:bold;"&gt;z-index: 100;&lt;/span&gt; within a CSS class bound to the &lt;span style="font-weight:bold;"&gt;DynamicMenuItemStyle&lt;/span&gt; property on the menu control. This is the easiest fix. What IE8+ browsers are doing here is in theory correct, it more of a shortfall of the control. &lt;span style="font-weight:bold; color: red"&gt;[Best Solution]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;2. Use CSS friendly adapters. Requires a total re-design, &lt;a href="http://www.asp.net/cssadapters/"&gt;why not take a look anyway&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;3. Making your browser emulate IE7 by using the following meta tag in the appropriate pages.&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;meta&lt;/span&gt; &lt;span class="attr"&gt;http-equiv&lt;/span&gt;&lt;span class="kwrd"&gt;="X-UA-Compatible"&lt;/span&gt; &lt;span class="attr"&gt;content&lt;/span&gt;&lt;span class="kwrd"&gt;="IE=EmulateIE7"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Note&lt;/span&gt;: The 3rd solution is not the best idea as it goes against the principles of moving forward with the technology!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-6873467659562132175?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/6873467659562132175/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=6873467659562132175' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/6873467659562132175'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/6873467659562132175'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/11/aspmenu-fix-submenu-appearing-as-white.html' title='asp:menu - Fix submenu appearing as a white box [IE8+]'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-607493625760154012</id><published>2010-11-25T07:11:00.000-08:00</published><updated>2010-11-25T07:14:15.430-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>SQL Server Management Studio - Edit Query Results</title><content type='html'>This is a useful way to edit results of queries in SQL Server Management Studio 2005 and 2008.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;SQL Server 2005&lt;/span&gt;&lt;br /&gt;1. Right click table&lt;br /&gt;2. Open Table&lt;br /&gt;3. Right click anywhere in the results &gt; Pane &gt; SQL&lt;br /&gt;4. SQL query windows pops up, enter query here.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;SQL Server 2008&lt;/span&gt;&lt;br /&gt;1. Right click table&lt;br /&gt;2. Edit Top 200 Rows&lt;br /&gt;3. Right click anywhere in the results &gt; Pane &gt; SQL&lt;br /&gt;4. SQL query windows pops up, enter query here.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-607493625760154012?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/607493625760154012/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=607493625760154012' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/607493625760154012'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/607493625760154012'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/11/sql-server-management-studio-edit-query.html' title='SQL Server Management Studio - Edit Query Results'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-1854049985966750248</id><published>2010-11-25T02:42:00.000-08:00</published><updated>2010-11-25T03:06:58.906-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Security'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='XSS'/><title type='text'>XSS: Cross style scripting attacks in ASP.NET [Examples]</title><content type='html'>Recently I have been looking at vulnerabilities in ASP.NET applications where XSS attacks are concerned. In recent years, integration with ASP.NET and AJAX has become more apparent as it offers many benefits; including partial page refreshes. However, this opens our applications up to potential attacks, one of which is the main area of focus for this topic: XSS (Cross-style scripting).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Must Read&lt;/span&gt;: &lt;a href="http://en.wikipedia.org/wiki/Cross-site_scripting"&gt;The XSS Wiki&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;When creating pages in ASP.NET, you may have stumbled upon the &lt;span style="font-weight:bold;"&gt;ValidateRequest&lt;/span&gt; property of the &lt;span style="font-weight:bold;"&gt;Page&lt;/span&gt; directive before. If not, it's a useful .NET feature that analyses page submissions for potentially unsafe mark up. You can test this yourself by entering &lt;span style="font-weight:bold;"&gt;&amp;lt;script&amp;gt;alert('Xss Vector!')&amp;lt;/script&amp;gt;&lt;/span&gt; into a asp.net textbox control and hitting submit on the form. You will receive an exception informing you that the submission is potentially unsafe. Try setting this to false (default is true if not specified) and you'll see that this is no longer picked up by the framework on submit.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;So why not leave this set to true for all pages, what's the problem?&lt;/span&gt;&lt;br /&gt;1. User's may want to enter markup into a text area control for example.&lt;br /&gt;2. &lt;span style="font-weight:bold;"&gt;AJAX&lt;/span&gt; calls to &lt;span style="font-weight:bold;"&gt;WebMethod&lt;/span&gt;'s do not follow this process.&lt;br /&gt;3. Sessions/Cookies/application variables can be hijacked that also do not follow this process.&lt;br /&gt;&lt;br /&gt;The three reasons above present a clear reason of why we should add protection to our ASP.NET applications against XSS attacks. Especially as ASP.NET AJAX is becoming more and more common. We have three options for protection against these kinds of attacks.&lt;br /&gt;&lt;br /&gt;1. Write your own utility to strip out potentially unsafe markup upon each potentially dangerous call.&lt;br /&gt;2. Include the Microsoft Anti-Cross Site Scripting Library into your solution. This is the same as step 1, but without the "Write your own" bit. It's around 700kb (V1.5).&lt;br /&gt;3. Do not make any of this calls where this becomes an issue [not realistic]&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For steps 1 and 2... We need to analyse our code or potential code (I.e. in the design process!) where these issues arise. You refer to the 3 potentially unsafe areas above as a starting point as these area areas where XSS attacks can occur. &lt;a href="http://msdn.microsoft.com/en-us/library/aa973813.aspx"&gt;This Microsoft page gives a good description on how to do this&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Once this areas are known, we can makes all inbound calls safe by stripping out or parsing incoming data using a bespoke tool or Microsoft's Anti-Cross Site Scripting Library.&lt;br /&gt;&lt;br /&gt;Here is a typical example where we make an AJAX call to the server and we use Microsoft's library to parse the incoming data. The example also includes a vulnerable option so the two approaches can be compared.&lt;br /&gt;&lt;br /&gt;&lt;a href="https://docs.google.com/uc?id=0B6SfMAw6tfpRMmFmN2E1MTAtZTQ0MC00ZDg4LWEyYjItMDFkNTVjNGJkODg0&amp;export=download&amp;hl=en"&gt;The example can be downloaded here&lt;/a&gt; [Requires .NET 3.5]&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Useful links&lt;/span&gt;:&lt;br /&gt;&lt;a href="http://ha.ckers.org/xss.html"&gt;XSS Cheat Sheet&lt;/a&gt;&lt;br /&gt;&lt;a href="http://xss.progphp.com/"&gt;Test your XSS Attack skills here!&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-1854049985966750248?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/1854049985966750248/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=1854049985966750248' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/1854049985966750248'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/1854049985966750248'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/11/xss-cross-style-scripting-attacks-in.html' title='XSS: Cross style scripting attacks in ASP.NET [Examples]'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-6947176668018113574</id><published>2010-11-23T02:53:00.000-08:00</published><updated>2010-11-25T02:40:47.420-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JSON'/><category scheme='http://www.blogger.com/atom/ns#' term='JQuery'/><category scheme='http://www.blogger.com/atom/ns#' term='AJAX'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><title type='text'>ASP.NET/AJAX - Client-side validation with server validation controls</title><content type='html'>With web applications getting more and more complex, it becomes necessary to make them more per-formant. It is quite easy to create an ASP.NET web application and within little or no time, most of the logic exists on the server. This is all good and well for a simple application, but as complexity increases, we need to start handing process to the client where client-side operations need to exist.&lt;br /&gt;&lt;br /&gt;One good example is validation. For example, there is no reason why we should have required field validation on the server (I.e. checking if a field exists in the code behind after submitting a form to the server). We can easily use a &lt;span style="font-weight:bold;"&gt;RequiredFieldValidator&lt;/span&gt; in this case, and this will be processed on the client-side.&lt;br /&gt;&lt;br /&gt;Ok, now for more complex examples, and this is the main vocal point of this article... What if we are using a custom validator and we need to check if, for example; an email exists dynamically without submitting the whole form? The common thing developers do here is override the &lt;span style="font-weight:bold;"&gt;OnServerValidate&lt;/span&gt; property of a &lt;span style="font-weight:bold;"&gt;CustomValidator&lt;/span&gt;, then this will take care of things when the form is submitted. I am now going to discuss how we can avoid this....&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;The old method&lt;/span&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_HiphnHyooWk/TOuicMl6eXI/AAAAAAAAABo/7WjQsTiYA1Q/s1600/oldway.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 69px;" src="http://4.bp.blogspot.com/_HiphnHyooWk/TOuicMl6eXI/AAAAAAAAABo/7WjQsTiYA1Q/s320/oldway.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5542702371709811058" /&gt;&lt;/a&gt;&lt;br /&gt;- Requires whole page postback&lt;br /&gt;- Less per-formant&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;The new method&lt;/span&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_HiphnHyooWk/TOujfYqrRMI/AAAAAAAAAB4/8tc8Df9FL0o/s1600/newway.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 101px;" src="http://2.bp.blogspot.com/_HiphnHyooWk/TOujfYqrRMI/AAAAAAAAAB4/8tc8Df9FL0o/s320/newway.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5542703526002246850" /&gt;&lt;/a&gt;&lt;br /&gt;- Partial page postback&lt;br /&gt;- Asynchronous, can be performed on-the-fly (dynamically)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;With the old method, you can see that we must submit the form to the server in order to use our server side validation method. Server side validation is useful if you wish to use a database for example (check if email exists), something that your Javascript cannot do alone.&lt;br /&gt;&lt;br /&gt;With the new method, we override the &lt;span style="font-weight:bold;"&gt;ClientValidationFunction&lt;/span&gt; of the &lt;span style="font-weight:bold;"&gt;CustomValidator&lt;/span&gt; and set it to a javascript function. This javascript function then wraps up some data using JSON; this data refers to what we are validating (I.e. email address), then passes it to a WebMethod on the server. The server method will behave exactly like the previous OnServerValidate method previously, and pass back the results of our validation process. The &lt;span style="font-weight:bold;"&gt;CustomValidator&lt;/span&gt; will then use this to trigger an error if necessary.&lt;br /&gt;&lt;br /&gt;I have attached the project files used in this example (written in ASP.NET 3.5). If you open the Javascript file, you can see that a page method is being referenced. You can also reference a service (.asmx) by uncommenting the line below in the script, and commenting out the page method reference. Both work exactly the same but present two alternate mechanisms.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="https://docs.google.com/uc?id=0B6SfMAw6tfpRNDRkMGUzNDMtY2M4NC00M2UyLWFmZGItNGU5ZGM5Nzc0ODZl&amp;export=download&amp;hl=en"&gt;Download the project files here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If the Web Service in different Namespace you can refer it before the class name this Main formula may help you : &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;NameSpaceName.ClassName.WebMethdName(Parameters , Success callback function, Error callback function);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Parameters&lt;/span&gt;: you can pass one or many parameters.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Success callback function&lt;/span&gt; :handles returned data from the service .&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Error callback function&lt;/span&gt; :Any errors that occur when the Web Service is called will trigger in this function. Using Error Callback function is optional.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Note&lt;/span&gt;: In this example, I am using the $.ajax command of JQuery to call the WebMethod. So in the url section, we need to specify the method as a URL relative to where it's being called from.&lt;br /&gt;&lt;br /&gt;I.e&lt;br /&gt;&lt;br /&gt;+ javascript&lt;br /&gt;  --- callwebservice.js    &lt; the script calling the service&lt;br /&gt;+ Services&lt;br /&gt;  --- service.asmx         &lt; the service being called&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Then your url will be "../Services/service.asmx/NameOfTheWebMethod"&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-6947176668018113574?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/6947176668018113574/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=6947176668018113574' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/6947176668018113574'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/6947176668018113574'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/11/aspnetajax-client-side-validation-with.html' title='ASP.NET/AJAX - Client-side validation with server validation controls'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_HiphnHyooWk/TOuicMl6eXI/AAAAAAAAABo/7WjQsTiYA1Q/s72-c/oldway.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-4253595944917858084</id><published>2010-11-09T02:44:00.001-08:00</published><updated>2010-11-09T02:49:09.245-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Web Testing'/><title type='text'>Multiple Versions of IE - With IE7, IE8 and IE9!!!</title><content type='html'>Here is a really good tool for emulating versions IE from 5.5 to 9. For those of you that have used a similar tool in the past (Multiple IE's) you'll notice that this has been discontinued and there are a few difficulties getting it to work with Windows Vista and Windows 7.&lt;br /&gt;&lt;br /&gt;Here is a better tool, IETester&lt;br /&gt;&lt;a href="http://www.my-debugbar.com/wiki/IETester/HomePage"&gt;http://www.my-debugbar.com/wiki/IETester/HomePage&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-4253595944917858084?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/4253595944917858084/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=4253595944917858084' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/4253595944917858084'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/4253595944917858084'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/11/multiple-versions-of-ie-with-ie7-ie8.html' title='Multiple Versions of IE - With IE7, IE8 and IE9!!!'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-5645311664556365935</id><published>2010-11-03T08:09:00.001-07:00</published><updated>2010-11-03T08:09:37.247-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CSS'/><title type='text'>CSS: Corner Radius</title><content type='html'>http://www.the-art-of-web.com/css/border-radius/&lt;br /&gt;&lt;br /&gt;Really good article!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-5645311664556365935?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/5645311664556365935/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=5645311664556365935' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/5645311664556365935'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/5645311664556365935'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/11/css-corner-radius.html' title='CSS: Corner Radius'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-5730299514511511489</id><published>2010-10-21T03:50:00.000-07:00</published><updated>2010-10-21T03:54:51.878-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>C#: Capture exception and all inner exceptions</title><content type='html'>With complex architectures and many layers in the code throwing exceptions, it can prove difficult to find out exactly what went wrong.&lt;br /&gt;&lt;br /&gt;Generally, the GUI may produce an error for example "Payment could not be processed." when making a payment on-line. From this error, we don't know which layer caused this error, but we know that along the way, something occurred.&lt;br /&gt;&lt;br /&gt;This code snippet takes an exception and loops through all inner exceptions and produces a string for the whole exception. This can be stored in a logfile and the problem can be easily identified.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;/// Gets a full exception message string from a given exception.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;/// This will loop through all inner exceptions.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;/// &amp;lt;param name="ex"&amp;gt;Incoming exception&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;Full exception message&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;internal&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; GetFullExceptionMessage(Exception ex)&lt;/pre&gt;&lt;pre&gt;{&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;string&lt;/span&gt; result = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;while&lt;/span&gt; (ex != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre&gt;    {&lt;/pre&gt;&lt;pre class="alt"&gt;    result += ex.ToString() + Environment.NewLine;&lt;/pre&gt;&lt;pre&gt;    ex = ex.InnerException;&lt;/pre&gt;&lt;pre class="alt"&gt;    }&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;return&lt;/span&gt; result;&lt;/pre&gt;&lt;pre&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-5730299514511511489?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/5730299514511511489/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=5730299514511511489' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/5730299514511511489'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/5730299514511511489'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/10/c-capture-exception-and-all-inner.html' title='C#: Capture exception and all inner exceptions'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-6186255001733047437</id><published>2010-10-13T08:19:00.000-07:00</published><updated>2010-10-13T08:25:23.313-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Flash'/><title type='text'>Downgrading Adobe Flash Player</title><content type='html'>So I had an issue today where all of my SWF video tutorials did not work correctly after a certain version of the Flash Player. I originally used ViewletCam software to do this back in 2004; and the videos seemed to half at random intervals and then crash.&lt;br /&gt;&lt;br /&gt;I needed a way to at least view these files locally, so that I could convert them to something more suitable. I had FLV in mind, and I could use these to load into many free web-embedded flash players.&lt;br /&gt;&lt;br /&gt;This is what I did.&lt;br /&gt;&lt;br /&gt;1. Uninstall the current version of flash. Adobe provides uninstallers for all versions. &lt;a href="http://kb2.adobe.com/cps/141/tn_14157.html"&gt;Current page to do this&lt;/a&gt;&lt;br /&gt;2. test that the uninstall worked. This should either: not load or prompt you to install flash player (do not install here) &lt;a href="http://www.adobe.com/software/flash/about/"&gt;Link here&lt;/a&gt;&lt;br /&gt;3. Obtain an older copy of flash player. Adobe has them all &lt;a href="http://kb2.adobe.com/cps/142/tn_14266.html"&gt;Here&lt;/a&gt; or take a visit to OldVersions.com&lt;br /&gt;4. Install the old flash player.&lt;br /&gt;5. Repeat step 2... this should give you your new flash version.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-6186255001733047437?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/6186255001733047437/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=6186255001733047437' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/6186255001733047437'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/6186255001733047437'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/10/downgrading-flash-player.html' title='Downgrading Adobe Flash Player'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-2116860082424293348</id><published>2010-10-12T04:06:00.000-07:00</published><updated>2010-10-12T04:11:36.107-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CSS'/><title type='text'>CSS: Hacks in Google Chrome and Safari only...</title><content type='html'>Here's a nice snippet to use in CSS when it seems like all other browsers are displaying your content correctly besides browsers based on Apple WebKit (Chrome, Safari etc.)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;An example of setting css properties in WebKit browsers&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;/* This works only in Safari and Google Chrome */&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;@media screen and (-webkit-min-device-pixel-ratio:0) {&lt;/pre&gt;&lt;pre class="alt"&gt;    .classNameHere {&lt;/pre&gt;&lt;pre&gt;        margin: 0 0 1px 0;&lt;/pre&gt;&lt;pre class="alt"&gt;        padding: 0px 3px 0px 3px;&lt;/pre&gt;&lt;pre&gt;    }&lt;/pre&gt;&lt;pre class="alt"&gt;    #exampleBorderStyleHere {&lt;/pre&gt;&lt;pre&gt;        border:solid 1px #000000;&lt;/pre&gt;&lt;pre class="alt"&gt;    }&lt;/pre&gt;&lt;pre&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-2116860082424293348?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/2116860082424293348/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=2116860082424293348' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/2116860082424293348'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/2116860082424293348'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/10/css-hacks-in-google-chrome-and-safari.html' title='CSS: Hacks in Google Chrome and Safari only...'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-4395968011448570881</id><published>2010-10-08T05:25:00.001-07:00</published><updated>2010-10-08T05:35:42.964-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><category scheme='http://www.blogger.com/atom/ns#' term='JQuery'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><title type='text'>ASP.NET/JQUERY - Maintain Scroll Position of DIV (example uses a treeview)</title><content type='html'>Today I had the task of maintaining the scroll position of an &lt;span style="font-weight:bold;"&gt;asp:TreeView&lt;/span&gt; control. Keeping it short and sweet; here's what I came up with.&lt;br /&gt;&lt;br /&gt;I noticed that when rendered in the browser, the TreeView is rendered as a div... and from back in the days of remembering window positions after post backs, I knew this wouldn't be much different.&lt;br /&gt;&lt;br /&gt;The solution I was working on used JQuery already and I found it useful to pull out references to server controls using the 'endwith' syntax. You can also get client id's, it doesn't matter to an extent.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Code behind&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Page_Load(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;/pre&gt;&lt;pre&gt;{&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;this&lt;/span&gt;.AddEvents();&lt;/pre&gt;&lt;pre&gt;}&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; AddEvents()&lt;/pre&gt;&lt;pre class="alt"&gt;{&lt;/pre&gt;&lt;pre&gt;    ScriptManager.RegisterStartupScript(&lt;span class="kwrd"&gt;this&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.GetType(), &lt;span class="str"&gt;"Load"&lt;/span&gt;, &lt;span class="str"&gt;"PageLoad();"&lt;/span&gt;, &lt;span class="kwrd"&gt;true&lt;/span&gt;);&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;this&lt;/span&gt;.tvOrganisation.Attributes.Add(&lt;span class="str"&gt;"onscroll"&lt;/span&gt;, &lt;span class="str"&gt;"saveScrollPosition(this)"&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;In the above code i'm attaching an &lt;span style="font-weight:bold;"&gt;onscroll&lt;/span&gt; event to the Treeview. I'm also adding a form load function in javascript so that I can initialise anything in here.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Page Markup&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;="text/javascript"&lt;/span&gt; &lt;span class="attr"&gt;src&lt;/span&gt;&lt;span class="kwrd"&gt;="LOCATION OF JQUERY HERE/jquery-x.x.x.js"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;script type=&lt;span class="str"&gt;"text/javascript"&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;function&lt;/span&gt; saveScrollPosition(div) {&lt;/pre&gt;&lt;pre&gt;        $(&lt;span class="str"&gt;"[id$='hdnTVScrollYPos']"&lt;/span&gt;).val(div.scrollTop);&lt;/pre&gt;&lt;pre class="alt"&gt;        $(&lt;span class="str"&gt;"[id$='hdnTVScrollXPos']"&lt;/span&gt;).val(div.scrollLeft);&lt;/pre&gt;&lt;pre&gt;    }&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;function&lt;/span&gt; restoreScrollPosition() {&lt;/pre&gt;&lt;pre class="alt"&gt;        $(&lt;span class="str"&gt;"[id$='tvTREEVIEWNAME']"&lt;/span&gt;).scrollTop($(&lt;span class="str"&gt;"[id$='hdnTVScrollYPos']"&lt;/span&gt;).val());&lt;/pre&gt;&lt;pre&gt;        $(&lt;span class="str"&gt;"[id$='tvTREEVIEWNAME']"&lt;/span&gt;).scrollLeft($(&lt;span class="str"&gt;"[id$='hdnTVScrollXPos']"&lt;/span&gt;).val());&lt;/pre&gt;&lt;pre class="alt"&gt;    }&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;function&lt;/span&gt; PageLoad() {;&lt;/pre&gt;&lt;pre class="alt"&gt;        restoreScrollPosition();&lt;/pre&gt;&lt;pre&gt;    }&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:HiddenField&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;="hdnTVScrollXPos"&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt; &lt;span class="attr"&gt;Value&lt;/span&gt;&lt;span class="kwrd"&gt;="0"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:HiddenField&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;="hdnTVScrollYPos"&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt; &lt;span class="attr"&gt;Value&lt;/span&gt;&lt;span class="kwrd"&gt;="0"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Here i'm using two hidden fields to hold the values of X and Y. This will maintain throughout postback and uses a cookie-less approach towards maintaining these details. The JavaScript speaks for itself.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-4395968011448570881?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/4395968011448570881/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=4395968011448570881' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/4395968011448570881'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/4395968011448570881'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/10/aspnetjquery-maintain-scroll-position.html' title='ASP.NET/JQUERY - Maintain Scroll Position of DIV (example uses a treeview)'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-5850135738870940432</id><published>2010-10-04T06:31:00.000-07:00</published><updated>2010-10-04T06:42:50.692-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CSS'/><title type='text'>CSS: Cross Browser Gradients</title><content type='html'>As a Web Developer, my usual ethic is to immediately create an ingenious architecture and spill out reusable code within the framework I've just created; while my design aspects are crudely left to the side until I need a GUI to make the thing work!&lt;br /&gt;In practise, it doesn't really matter which order these are done, just as long as the requirements are in place and there is a general idea.&lt;br /&gt;&lt;br /&gt;However, when i'm at home (without the glorious support of a design team to make my images and write my CSS for me), things do get done, but designing pages with a div layout; bearing cross browser functionality in mind and actually making it look good takes a lot of skill. So here's one for the skillset....&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Cross Browser Gradients with CSS&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;.gradientTitle {&lt;/pre&gt;&lt;pre&gt;    background-color: #CECEF6; &lt;span class="rem"&gt;/* Opera and browsers that do not support gradients  */&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    background: -webkit-gradient(linear, left top, right bottom, from(#CECEF6), to(#FFFFFF)); &lt;span class="rem"&gt;/* Webkit browsers: Chrome, Safari etc. */&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    background: -moz-linear-gradient(left,  #CECEF6,  #FFFFFF); &lt;span class="rem"&gt;/* Mozilla Firefox */&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    filter: progid:DXImageTransform.Microsoft.gradient(GradientType=1, startColorstr=&lt;span class="str"&gt;'#CECEF6'&lt;/span&gt;, endColorstr=&lt;span class="str"&gt;'#FFFFFF'&lt;/span&gt;); &lt;span class="rem"&gt;/* IE 5.5+ */&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    padding: 2px 2px 2px 8px;&lt;/pre&gt;&lt;pre class="alt"&gt;    color: #1C1C1C;&lt;/pre&gt;&lt;pre&gt;    width: 60%;&lt;/pre&gt;&lt;pre class="alt"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I have set an initial background for browsers that do not support gradients. If a browser is capable of picking up one of these three, the background-color is overridden.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Preview&lt;/span&gt;&lt;br /&gt;&lt;h2 style="font-size: 10pt; background-color: #CECEF6; background: -webkit-gradient(linear, left top, right bottom, from(#CECEF6), to(#FFFFFF)); background: -moz-linear-gradient(left, #CECEF6, #FFFFFF); filter: progid:DXImageTransform.Microsoft.gradient(GradientType=1, startColorstr='#CECEF6', endColorstr='#FFFFFF'); padding: 2px 2px 2px 8px; color: #1C1C1C; width: 60%"&gt;Here's a Sample Heading&lt;/h2&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-5850135738870940432?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/5850135738870940432/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=5850135738870940432' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/5850135738870940432'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/5850135738870940432'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/10/css-cross-browser-gradients.html' title='CSS: Cross Browser Gradients'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-264814850485796904</id><published>2010-09-29T03:32:00.000-07:00</published><updated>2010-09-29T03:48:46.611-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><category scheme='http://www.blogger.com/atom/ns#' term='JQuery'/><title type='text'>Javascript: Namespaces and O-O examples...</title><content type='html'>I'm not sure how common practise this is, but where I currently work we have a standard whereby we placed common JavaScript functionality in separate files and what could be called classes. I'm sure most developers out there do group common functions in files and import them when needed. This is fine, but it doesn't promote certain O-O practises like information hiding and the feel of objects, methods and properties. This is what this post aims to achieve.&lt;br /&gt;&lt;br /&gt;I have attached a sample project file which declares a JavaScript name space in a separate file, declares a Messages 'class' in another and a sample HTML page which invokes various methods and properties against it. Sample can be found at the end of this post.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Namespace declaration&lt;/span&gt; - Must be imported first&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;/******************************&lt;/pre&gt;&lt;pre&gt;** BANTY Namespace definition&lt;/pre&gt;&lt;pre class="alt"&gt;******************************/&lt;/pre&gt;&lt;pre&gt;var BANTY = BANTY || {};&lt;/pre&gt;&lt;pre class="alt"&gt;BANTY = (&lt;span class="kwrd"&gt;function&lt;/span&gt;() {&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;return&lt;/span&gt; {&lt;/pre&gt;&lt;pre class="alt"&gt;        helloWorld : &lt;span class="kwrd"&gt;function&lt;/span&gt;() {&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="str"&gt;"Helllo World!"&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;        }&lt;/pre&gt;&lt;pre&gt;    }&lt;/pre&gt;&lt;pre class="alt"&gt;}());&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Class definition&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;/******************************&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;** Define Messages class&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;*******************************/&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;if&lt;/span&gt; (!BANTY.Messages) BANTY.Messages = {};&lt;/pre&gt;&lt;pre class="alt"&gt;BANTY.Messages = (function() {&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;// private declarations here&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    var pi_Message;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;    var pi_ChangeMessage = function (newMsg) {&lt;/pre&gt;&lt;pre class="alt"&gt;        pi_Message = newMsg;&lt;/pre&gt;&lt;pre&gt;    };&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;/pre&gt;&lt;pre&gt;    &lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;// public declarations here&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;return&lt;/span&gt; {&lt;/pre&gt;&lt;pre class="alt"&gt;        publicProperty : &lt;span class="str"&gt;"This is a public property"&lt;/span&gt;,&lt;/pre&gt;&lt;pre&gt;        &lt;/pre&gt;&lt;pre class="alt"&gt;        init : function (Args) {&lt;/pre&gt;&lt;pre&gt;            pi_Message = &lt;span class="str"&gt;"Message initialised."&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;        },&lt;/pre&gt;&lt;pre&gt;        &lt;/pre&gt;&lt;pre class="alt"&gt;        showMessage : function () {&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="str"&gt;"The value of the message is: "&lt;/span&gt; + pi_Message;&lt;/pre&gt;&lt;pre class="alt"&gt;        },&lt;/pre&gt;&lt;pre&gt;        &lt;/pre&gt;&lt;pre class="alt"&gt;        changeMessage : function (msg) {&lt;/pre&gt;&lt;pre&gt;            pi_ChangeMessage(msg);&lt;/pre&gt;&lt;pre class="alt"&gt;        },&lt;/pre&gt;&lt;pre&gt;    };&lt;/pre&gt;&lt;pre class="alt"&gt;}());&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Example HTML Page&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;!&lt;/span&gt;&lt;span class="html"&gt;DOCTYPE&lt;/span&gt; &lt;span class="attr"&gt;html&lt;/span&gt; &lt;span class="attr"&gt;PUBLIC&lt;/span&gt; &lt;span class="kwrd"&gt;"-//W3C//DTD XHTML 1.0 Transitional//EN"&lt;/span&gt; &lt;span class="kwrd"&gt;"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;html&lt;/span&gt; &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;="http://www.w3.org/1999/xhtml"&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;head&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Javascript O-O Example&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt; &lt;span class="attr"&gt;src&lt;/span&gt;&lt;span class="kwrd"&gt;="Banty.js"&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;="text/javascript"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &amp;lt;script src=&lt;span class="str"&gt;"http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"&lt;/span&gt; type=&lt;span class="str"&gt;"text/javascript"&lt;/span&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;lt;/head&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;body style=&lt;span class="str"&gt;"font-family: verdana; font-size: 8pt"&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &amp;lt;div id=&lt;span class="str"&gt;"tagged"&lt;/span&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;    &amp;lt;script src=&lt;span class="str"&gt;"BANTY.Messages.js"&lt;/span&gt; type=&lt;span class="str"&gt;"text/javascript"&lt;/span&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/pre&gt;&lt;pre&gt;    &amp;lt;script type=&lt;span class="str"&gt;"text/javascript"&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    $(&lt;span class="str"&gt;'#tagged'&lt;/span&gt;).append(&lt;span class="str"&gt;'&amp;lt;br /&amp;gt;&amp;lt;div&amp;gt;&amp;lt;font color="0000FF"&amp;gt;&amp;lt;b&amp;gt;Information hiding principles...&amp;lt;/b&amp;gt;&amp;lt;/font&amp;gt;&amp;lt;/div&amp;gt;'&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;    $(&lt;span class="str"&gt;'#tagged'&lt;/span&gt;).append(&lt;span class="str"&gt;'&amp;lt;div&amp;gt;Can I see BANTY?:&amp;lt;b&amp;gt; '&lt;/span&gt;+ (BANTY ? &lt;span class="str"&gt;'Yes'&lt;/span&gt; : &lt;span class="str"&gt;'No'&lt;/span&gt;) +&lt;span class="str"&gt;'&amp;lt;/b&amp;gt;&amp;lt;/div&amp;gt;'&lt;/span&gt;);&lt;/pre&gt;&lt;pre class="alt"&gt;    $(&lt;span class="str"&gt;'#tagged'&lt;/span&gt;).append(&lt;span class="str"&gt;'&amp;lt;div&amp;gt;Can I see BANTY.helloWorld?:&amp;lt;b&amp;gt; '&lt;/span&gt;+ (BANTY ? &lt;span class="str"&gt;'Yes'&lt;/span&gt; : &lt;span class="str"&gt;'No'&lt;/span&gt;) +&lt;span class="str"&gt;'&amp;lt;/b&amp;gt;&amp;lt;/div&amp;gt;'&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;    $(&lt;span class="str"&gt;'#tagged'&lt;/span&gt;).append(&lt;span class="str"&gt;'&amp;lt;div&amp;gt;Can I see BANTY.Messages?:&amp;lt;b&amp;gt; '&lt;/span&gt;+ (BANTY.Messages ? &lt;span class="str"&gt;'Yes'&lt;/span&gt; : &lt;span class="str"&gt;'No'&lt;/span&gt;) +&lt;span class="str"&gt;'&amp;lt;/b&amp;gt;&amp;lt;/div&amp;gt;'&lt;/span&gt;);&lt;/pre&gt;&lt;pre class="alt"&gt;    $(&lt;span class="str"&gt;'#tagged'&lt;/span&gt;).append(&lt;span class="str"&gt;'&amp;lt;div&amp;gt;Can I see BANTY.Messages.publicProperty?:&amp;lt;b&amp;gt; '&lt;/span&gt;+ (BANTY.Messages.publicProperty ? &lt;span class="str"&gt;'Yes'&lt;/span&gt; : &lt;span class="str"&gt;'No'&lt;/span&gt;) +&lt;span class="str"&gt;'&amp;lt;/b&amp;gt;&amp;lt;/div&amp;gt;'&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;    $(&lt;span class="str"&gt;'#tagged'&lt;/span&gt;).append(&lt;span class="str"&gt;'&amp;lt;div&amp;gt;Can I see BANTY.Messages.showMessage?:&amp;lt;b&amp;gt; '&lt;/span&gt;+ (BANTY.Messages.showMessage ? &lt;span class="str"&gt;'Yes'&lt;/span&gt; : &lt;span class="str"&gt;'No'&lt;/span&gt;) +&lt;span class="str"&gt;'&amp;lt;/b&amp;gt;&amp;lt;/div&amp;gt;'&lt;/span&gt;);&lt;/pre&gt;&lt;pre class="alt"&gt;    $(&lt;span class="str"&gt;'#tagged'&lt;/span&gt;).append(&lt;span class="str"&gt;'&amp;lt;div&amp;gt;Can I see BANTY.Messages.pi_Message?:&amp;lt;b&amp;gt; '&lt;/span&gt;+ (BANTY.Messages.pi_Message ? &lt;span class="str"&gt;'Yes'&lt;/span&gt; : &lt;span class="str"&gt;'No'&lt;/span&gt;) +&lt;span class="str"&gt;'&amp;lt;/b&amp;gt;&amp;lt;/div&amp;gt;'&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;    $(&lt;span class="str"&gt;'#tagged'&lt;/span&gt;).append(&lt;span class="str"&gt;'&amp;lt;div&amp;gt;Can I see BANTY.Messages.pi_ChangeMessage?:&amp;lt;b&amp;gt; '&lt;/span&gt;+ (BANTY.Messages.pi_ChangeMessage ? &lt;span class="str"&gt;'Yes'&lt;/span&gt; : &lt;span class="str"&gt;'No'&lt;/span&gt;) +&lt;span class="str"&gt;'&amp;lt;/b&amp;gt;&amp;lt;/div&amp;gt;'&lt;/span&gt;);&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;    $(&lt;span class="str"&gt;'#tagged'&lt;/span&gt;).append(&lt;span class="str"&gt;'&amp;lt;br /&amp;gt;&amp;lt;div&amp;gt;&amp;lt;font color="0000FF"&amp;gt;&amp;lt;b&amp;gt;Show and Change Messages...&amp;lt;/b&amp;gt;&amp;lt;/font&amp;gt;&amp;lt;/div&amp;gt;'&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;    $(&lt;span class="str"&gt;'#tagged'&lt;/span&gt;).append(&lt;span class="str"&gt;'&amp;lt;div&amp;gt;&amp;lt;b&amp;gt; BANTY.helloWorld:&amp;lt;/b&amp;gt; '&lt;/span&gt;+ BANTY.helloWorld() +&lt;span class="str"&gt;'&amp;lt;/div&amp;gt;'&lt;/span&gt;);&lt;/pre&gt;&lt;pre class="alt"&gt;    $(&lt;span class="str"&gt;'#tagged'&lt;/span&gt;).append(&lt;span class="str"&gt;'&amp;lt;div&amp;gt;&amp;lt;b&amp;gt; BANTY.Messages.report():&amp;lt;/b&amp;gt; '&lt;/span&gt;+ BANTY.Messages.showMessage() +&lt;span class="str"&gt;'&amp;lt;/div&amp;gt;'&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;    $(&lt;span class="str"&gt;'#tagged'&lt;/span&gt;).append(&lt;span class="str"&gt;'&amp;lt;div&amp;gt;&amp;lt;b&amp;gt; BANTY.Messages.init():&amp;lt;/b&amp;gt; '&lt;/span&gt;+ BANTY.Messages.init() +&lt;span class="str"&gt;'&amp;lt;/div&amp;gt;'&lt;/span&gt;);&lt;/pre&gt;&lt;pre class="alt"&gt;    $(&lt;span class="str"&gt;'#tagged'&lt;/span&gt;).append(&lt;span class="str"&gt;'&amp;lt;div&amp;gt;&amp;lt;b&amp;gt; BANTY.Messages.report():&amp;lt;/b&amp;gt; '&lt;/span&gt;+ BANTY.Messages.showMessage() +&lt;span class="str"&gt;'&amp;lt;/div&amp;gt;'&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;    $(&lt;span class="str"&gt;'#tagged'&lt;/span&gt;).append(&lt;span class="str"&gt;'&amp;lt;div&amp;gt;&amp;lt;b&amp;gt; BANTY.Messages.changeMessage(newmsg):&amp;lt;/b&amp;gt; '&lt;/span&gt;+ BANTY.Messages.changeMessage(&lt;span class="str"&gt;"newmsg"&lt;/span&gt;) +&lt;span class="str"&gt;'&amp;lt;/div&amp;gt;'&lt;/span&gt;);&lt;/pre&gt;&lt;pre class="alt"&gt;    $(&lt;span class="str"&gt;'#tagged'&lt;/span&gt;).append(&lt;span class="str"&gt;'&amp;lt;div&amp;gt;&amp;lt;b&amp;gt; BANTY.Messages.report():&amp;lt;/b&amp;gt; '&lt;/span&gt;+ BANTY.Messages.showMessage() +&lt;span class="str"&gt;'&amp;lt;/div&amp;gt;'&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;body&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;html&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Example Output&lt;/span&gt;&lt;br /&gt;&lt;div id="tagged"&gt;&lt;br&gt;&lt;div&gt;&lt;font color="0000FF"&gt;&lt;b&gt;Information hiding principles...&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;Can I see BANTY?:&lt;b&gt; Yes&lt;/b&gt;&lt;/div&gt;&lt;div&gt;Can I see BANTY.helloWorld?:&lt;b&gt; Yes&lt;/b&gt;&lt;/div&gt;&lt;div&gt;Can I see BANTY.Messages?:&lt;b&gt; Yes&lt;/b&gt;&lt;/div&gt;&lt;div&gt;Can I see BANTY.Messages.publicProperty?:&lt;b&gt; Yes&lt;/b&gt;&lt;/div&gt;&lt;div&gt;Can I see BANTY.Messages.showMessage?:&lt;b&gt; Yes&lt;/b&gt;&lt;/div&gt;&lt;div&gt;Can I see BANTY.Messages.pi_Message?:&lt;b&gt; No&lt;/b&gt;&lt;/div&gt;&lt;div&gt;Can I see BANTY.Messages.pi_ChangeMessage?:&lt;b&gt; No&lt;/b&gt;&lt;/div&gt;&lt;br&gt;&lt;div&gt;&lt;font color="0000FF"&gt;&lt;b&gt;Show and Change Messages...&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt; BANTY.helloWorld:&lt;/b&gt; Helllo World!&lt;/div&gt;&lt;div&gt;&lt;b&gt; BANTY.Messages.report():&lt;/b&gt; The value of the message is: undefined&lt;/div&gt;&lt;div&gt;&lt;b&gt; BANTY.Messages.init():&lt;/b&gt; undefined&lt;/div&gt;&lt;div&gt;&lt;b&gt; BANTY.Messages.report():&lt;/b&gt; The value of the message is: Message initialised.&lt;/div&gt;&lt;div&gt;&lt;b&gt; BANTY.Messages.changeMessage(newmsg):&lt;/b&gt; undefined&lt;/div&gt;&lt;div&gt;&lt;b&gt; BANTY.Messages.report():&lt;/b&gt; The value of the message is: newmsg&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="https://sites.google.com/site/tutorialgenius/file-cabinet/%5BJS%5DO-OExample.zip"&gt;Download Sample Files Here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Thanks go out to my company for putting this standard in place.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-264814850485796904?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/264814850485796904/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=264814850485796904' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/264814850485796904'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/264814850485796904'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/09/javascript-namespaces-and-o-o-examples.html' title='Javascript: Namespaces and O-O examples...'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-2565989749771974076</id><published>2010-09-29T01:49:00.001-07:00</published><updated>2010-09-29T02:11:51.611-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>ASP.NET - Get IPv4 Address, even if the user is using a proxy or an intranet user</title><content type='html'>Today I was working on some PayPal integration for an internal web application when part of the API suggested I needed an IP Address for the user to enhance security.&lt;br /&gt;Realising this was an intranet application which could be used externally, I had to cater for all aspects.&lt;br /&gt;Getting an IP Address for an internal users involves looking up the host addresses using the System.Net.Dns namespace, rather than a simple peek in a server variable. As well as this, I needed to make sure I could identify real IP Addresses for users behind a proxy. If that wasn;t enough, the PayPal API doesn't support IPv6, so I had to search the host list for a IPv4 address and use that.... PayPal requires an IP or it will fail, so if everything else fails, it will return the loopback address (ack!). here's what I came up with...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;// Invoker&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;string&lt;/span&gt; IPAddress = IPHelper.GetIPAddress(Request.ServerVariables[&lt;span class="str"&gt;"HTTP_VIA"&lt;/span&gt;],&lt;/pre&gt;&lt;pre class="alt"&gt;                                                Request.ServerVariables[&lt;span class="str"&gt;"HTTP_X_FORWARDED_FOR"&lt;/span&gt;],&lt;/pre&gt;&lt;pre&gt;                                                Request.ServerVariables[&lt;span class="str"&gt;"REMOTE_ADDR"&lt;/span&gt;]);&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;/// Provides IP addressing functionality to any&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;/// calling part of the system.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; IPHelper&lt;/pre&gt;&lt;pre class="alt"&gt;{&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// Gets the user's IP Address&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// &amp;lt;param name="httpVia"&amp;gt;HTTP_VIA Server variable&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;param name="httpXForwardedFor"&amp;gt;HTTP_X_FORWARDED Server variable&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// &amp;lt;param name="RemoteAddr"&amp;gt;REMOTE_ADDR Server variable&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;user's IP Address&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; GetIPAddress(&lt;span class="kwrd"&gt;string&lt;/span&gt; HttpVia, &lt;span class="kwrd"&gt;string&lt;/span&gt; HttpXForwardedFor, &lt;span class="kwrd"&gt;string&lt;/span&gt; RemoteAddr)&lt;/pre&gt;&lt;pre&gt;    {&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;// Use a default address if all else fails.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;string&lt;/span&gt; result = &lt;span class="str"&gt;"127.0.0.1"&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;// Web user - if using proxy&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;string&lt;/span&gt; tempIP = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (HttpVia != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre class="alt"&gt;            tempIP = HttpXForwardedFor;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="rem"&gt;// Web user - not using proxy or can't get the Client IP&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            tempIP = RemoteAddr;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;// If we can't get a V4 IP from the above, try host address list for internal users.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (!IsIPV4(tempIP))&lt;/pre&gt;&lt;pre class="alt"&gt;        {&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;try&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            {&lt;/pre&gt;&lt;pre&gt;                &lt;span class="kwrd"&gt;string&lt;/span&gt; hostName = System.Net.Dns.GetHostName();&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (System.Net.IPAddress ip &lt;span class="kwrd"&gt;in&lt;/span&gt; System.Net.Dns.GetHostAddresses(hostName))&lt;/pre&gt;&lt;pre&gt;                {&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="kwrd"&gt;if&lt;/span&gt; (IsIPV4(ip))&lt;/pre&gt;&lt;pre&gt;                    {&lt;/pre&gt;&lt;pre class="alt"&gt;                        result = ip.ToString();&lt;/pre&gt;&lt;pre&gt;                        &lt;span class="kwrd"&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;                    }&lt;/pre&gt;&lt;pre&gt;                }&lt;/pre&gt;&lt;pre class="alt"&gt;            }&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;catch&lt;/span&gt; { }&lt;/pre&gt;&lt;pre class="alt"&gt;        }&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;return&lt;/span&gt; result;&lt;/pre&gt;&lt;pre&gt;    }&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// Determines weather an IP Address is V4&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// &amp;lt;param name="input"&amp;gt;input string&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;Is IPV4 True or False&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; IsIPV4(&lt;span class="kwrd"&gt;string&lt;/span&gt; input)&lt;/pre&gt;&lt;pre&gt;    {&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;bool&lt;/span&gt; result = &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;        System.Net.IPAddress address = &lt;span class="kwrd"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (System.Net.IPAddress.TryParse(input, &lt;span class="kwrd"&gt;out&lt;/span&gt; address))&lt;/pre&gt;&lt;pre class="alt"&gt;            result = IsIPV4(address);&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;return&lt;/span&gt; result;&lt;/pre&gt;&lt;pre&gt;    }&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// Determines weather an IP Address is V4&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// &amp;lt;param name="address"&amp;gt;input IP address&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;Is IPV4 True or False&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; IsIPV4(System.Net.IPAddress address)&lt;/pre&gt;&lt;pre&gt;    {&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;bool&lt;/span&gt; result = &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;switch&lt;/span&gt; (address.AddressFamily)&lt;/pre&gt;&lt;pre&gt;        {&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;case&lt;/span&gt; System.Net.Sockets.AddressFamily.InterNetwork:   &lt;span class="rem"&gt;// we have IPv4&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                result = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;case&lt;/span&gt; System.Net.Sockets.AddressFamily.InterNetworkV6: &lt;span class="rem"&gt;// we have IPv6&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="kwrd"&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;                &lt;span class="kwrd"&gt;default&lt;/span&gt;:&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="kwrd"&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;            }&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; result;&lt;/pre&gt;&lt;pre class="alt"&gt;        }&lt;/pre&gt;&lt;pre&gt;    }&lt;/pre&gt;&lt;pre class="alt"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-2565989749771974076?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/2565989749771974076/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=2565989749771974076' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/2565989749771974076'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/2565989749771974076'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/09/aspnet-get-ipv4-address-even-if-user-is.html' title='ASP.NET - Get IPv4 Address, even if the user is using a proxy or an intranet user'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-4518481247323565696</id><published>2010-09-23T02:22:00.000-07:00</published><updated>2010-09-23T02:27:42.092-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>asp:Menu controls not working in Chrome/Safari</title><content type='html'>I faced a small issue today with asp:Menu controls not working properly in Chrome or Safari the first time the page is loaded. However, if I refresh the page, the contents seem to load fine.&lt;br /&gt;The underlying problem is the way Chrome manages it's adaptors and we need to be able to clear these out and refresh the page if this situation occurs.&lt;br /&gt;&lt;br /&gt;I have therefore written an OnInit event for any ASP.NET page or user control in which the menu is placed. Simply just add it in the code behind...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Fix Menu rendering in Chrome and Safari&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnInit(EventArgs e)&lt;/pre&gt;&lt;pre&gt;{&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;// For Chrome and Safari&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;if&lt;/span&gt; (Request.UserAgent.IndexOf(&lt;span class="str"&gt;"AppleWebKit"&lt;/span&gt;) &amp;gt; 0)&lt;/pre&gt;&lt;pre class="alt"&gt;    {&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (Request.Browser.Adapters.Count &amp;gt; 0)&lt;/pre&gt;&lt;pre class="alt"&gt;        {&lt;/pre&gt;&lt;pre&gt;            Request.Browser.Adapters.Clear();&lt;/pre&gt;&lt;pre class="alt"&gt;            Response.Redirect(Page.Request.Url.AbsoluteUri);&lt;/pre&gt;&lt;pre&gt;        }&lt;/pre&gt;&lt;pre class="alt"&gt;    }&lt;/pre&gt;&lt;pre&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- Using the "AppleWebKit" we can identify these browsers&lt;br /&gt;- By checking more than one adapter exists, we avoid re-directing every time; this only needs to be done on the first hit.&lt;br /&gt;- We Re-Direct back to itself the first time the page is hit.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-4518481247323565696?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/4518481247323565696/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=4518481247323565696' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/4518481247323565696'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/4518481247323565696'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/09/aspmenu-controls-not-working-in.html' title='asp:Menu controls not working in Chrome/Safari'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-5425786624047163751</id><published>2010-09-22T07:53:00.000-07:00</published><updated>2010-09-27T03:05:54.116-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>C#: Cultures</title><content type='html'>Cultures are things you probably won't come across for general projects unless you are dealing with support for multiple viewing countries. This mainly includes: Dates, times and currencies.&lt;br /&gt;&lt;br /&gt;For example, When parsing (using Parse/TryParse) a DateTime object, it assumes the DateTime is in US format... so when we come to use this, we'll notice our days and months are the wrong way round!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Parsing a string in a DateTime object with a UK Culture&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Globalization;   &lt;span class="rem"&gt;// For access to culture objects&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; DateTime ParseDate(&lt;span class="kwrd"&gt;string&lt;/span&gt; IncomingDate)&lt;/pre&gt;&lt;pre class="alt"&gt;{&lt;/pre&gt;&lt;pre&gt;    CultureInfo ukCulture = &lt;span class="kwrd"&gt;new&lt;/span&gt; CultureInfo(&lt;span class="str"&gt;"en-GB"&lt;/span&gt;);&lt;/pre&gt;&lt;pre class="alt"&gt;    DateTime parsedDate = &lt;span class="kwrd"&gt;new&lt;/span&gt; DateTime();&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;    DateTime.TryParse(IncomingDate, ukCulture.DateTimeFormat, DateTimeStyles.None, &lt;span class="kwrd"&gt;out&lt;/span&gt; parsedDate);&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;return&lt;/span&gt; parsedDate;&lt;/pre&gt;&lt;pre&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;An implicit example&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;DateTime dateObj = DateTime.Parse(inputString, &lt;span class="kwrd"&gt;new&lt;/span&gt; CultureInfo(&lt;span class="str"&gt;"en-GB"&lt;/span&gt;));&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We can also apply culture globally across a whole application by setting culture settings in the Web.config file. In the following snippet, we have Culture and UICulture. The former refers to how DateTime objects and currencies are parsed etc. Using a en-GB culture will ensure these all use UK currencies and formatting. The latter determines which resource files are used for the UI.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Setting the culture globally in the Web.config&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&amp;lt;globalization uiCulture=&lt;span class="str"&gt;"en-GB"&lt;/span&gt; culture=&lt;span class="str"&gt;"en-GB"&lt;/span&gt; /&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-5425786624047163751?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/5425786624047163751/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=5425786624047163751' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/5425786624047163751'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/5425786624047163751'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/09/c-cultures.html' title='C#: Cultures'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-6546464423023169691</id><published>2010-09-20T06:32:00.000-07:00</published><updated>2010-11-25T07:40:45.115-08:00</updated><title type='text'>Sending HTML Emails and Emailing Tricks with C#</title><content type='html'>Sending emails is relatively easy with C#, even-so, its not much more difficult to send HTML based emails either. The formatting, and how different email clients interpret the HTML and CSS in the emails, differs slightly. The aims of this post is to present a few typical scenarios of different types of emails which are sent.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Sending a Simple email using an email server - non-HTML&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Net.Mail;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;MailMessage mail = &lt;span class="kwrd"&gt;new&lt;/span&gt; MailMessage(&lt;span class="str"&gt;"from@email.com"&lt;/span&gt;, &lt;span class="str"&gt;"to@email.com"&lt;/span&gt;, &lt;span class="str"&gt;"Email Subject"&lt;/span&gt;, &lt;span class="str"&gt;"Email Message"&lt;/span&gt;);&lt;/pre&gt;&lt;pre class="alt"&gt;mail.IsBodyHtml = &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;this&lt;/span&gt;.SendMail(mail);&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;/// Sends the mail using a mail message.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="rem"&gt;/// &amp;lt;param name="Mail"&amp;gt;The mail message.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SendMail(MailMessage Mail)&lt;/pre&gt;&lt;pre&gt;{&lt;/pre&gt;&lt;pre class="alt"&gt;     SmtpClient smtpClient = &lt;span class="kwrd"&gt;new&lt;/span&gt; SmtpClient();&lt;/pre&gt;&lt;pre&gt;     smtpClient.Host = "Email Server Address";&lt;/pre&gt;&lt;pre class="alt"&gt;     smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;     &lt;span class="kwrd"&gt;try&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;     {&lt;/pre&gt;&lt;pre class="alt"&gt;          smtpClient.Send(Mail);&lt;/pre&gt;&lt;pre&gt;     }&lt;/pre&gt;&lt;pre class="alt"&gt;     &lt;span class="kwrd"&gt;catch&lt;/span&gt; (Exception ex)&lt;/pre&gt;&lt;pre&gt;     {&lt;/pre&gt;&lt;pre class="alt"&gt;          &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; EmailException(ErrorCodeType.SendFailed, ex);&lt;/pre&gt;&lt;pre&gt;     }&lt;/pre&gt;&lt;pre class="alt"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;This is enough to send a simple email to a target destination using an existing email server. To enable HTML is the body, we simply enable the IsBodyHtml property of the MailMessage object by setting it to true.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Simple HTML Email using the function in the previous example&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;br /&gt;&lt;pre class="alt"&gt;MailMessage mail = &lt;span class="kwrd"&gt;new&lt;/span&gt; MailMessage(&lt;span class="str"&gt;"from@email.com"&lt;/span&gt;, &lt;span class="str"&gt;"to@email.com"&lt;/span&gt;, &lt;span class="str"&gt;"Email Subject"&lt;/span&gt;, &lt;span class="str"&gt;"&amp;lt;b&amp;gt;HELLO!!&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Test Message..."&lt;/span&gt;);&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;mail.IsBodyHtml = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;this&lt;/span&gt;.SendMail(mail);&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;With OutLook for example, some representations of styling alter slightly. For example, I spent some time trying to understand why the line-height was interpreted differently in outlook. For whatever reason, If I tested the HTML template in IE, FF or Chrome; everything would be the same apart from the line-height. This seems to be a common problem. The solution I came up with is to tell outlook to render it in a certain way and that other browsers should ignore it.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;HTML Email with line spacing and styles applied to the body of the email&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;string&lt;/span&gt; emailBody = &lt;span class="str"&gt;"&amp;lt;div style=\"font-family: Verdana, Arial, sans-serif; font-size: 9pt; mso-line-height-rule:exactly; line-height: 20px\"&amp;gt;"&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;emailBody += &lt;span class="str"&gt;"&amp;lt;b&amp;gt;HELLO!!&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Test Message...&amp;lt;/div&amp;gt;"&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;MailMessage mail = &lt;span class="kwrd"&gt;new&lt;/span&gt; MailMessage(&lt;span class="str"&gt;"from@email.com"&lt;/span&gt;, &lt;span class="str"&gt;"to@email.com"&lt;/span&gt;, &lt;span class="str"&gt;"Email Subject"&lt;/span&gt;, emailBody);&lt;/pre&gt;&lt;pre class="alt"&gt; &lt;/pre&gt;&lt;pre&gt;mail.IsBodyHtml = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt; &lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;this&lt;/span&gt;.SendMail(mail);&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;By setting "mso-line-height-rule:exactly" before the line-height property, we are tell mso (Microsoft Office) to render this differently to other browsers. You'll notice that I set the line-height to 20px... for a 9pt font, this is quite huge normally, but in Outlook; it's not.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;One more tip, which may be quite trivial to some... If you want to using alias' in your emails (I.e. Appear that the email is being sent from an Alias) then there is no special code. Simply format the 'From' address in the following Format... "AliasName" &lt;email@address.com&gt;  (Include the quotes aswell)&lt;br /&gt;&lt;br /&gt;In a config file, this might look like... &lt;span style="font-weight:bold;"&gt;[Remember we need to escape special characters in the XML config file!]&lt;/span&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;appSettings&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;add&lt;/span&gt; &lt;span class="attr"&gt;key&lt;/span&gt;&lt;span class="kwrd"&gt;="Email.FromAddress"&lt;/span&gt; &lt;span class="attr"&gt;value&lt;/span&gt;&lt;span class="kwrd"&gt;="&amp;amp;quot;WebAdmin&amp;amp;quot; &amp;amp;lt;online@tmgcrb.co.uk&amp;amp;gt;"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;appSettings&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-6546464423023169691?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/6546464423023169691/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=6546464423023169691' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/6546464423023169691'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/6546464423023169691'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/09/sending-html-emails-and-emailing-tricks.html' title='Sending HTML Emails and Emailing Tricks with C#'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-4605303967491879537</id><published>2010-09-16T00:57:00.000-07:00</published><updated>2010-09-16T01:01:09.940-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Windows'/><title type='text'>Forcibly clear a printer queue</title><content type='html'>Sometimes the printer queue just won't clear, no matter how many times you right click and try to delete the job. Here's how to actually clear it out properly!&lt;br /&gt;&lt;br /&gt;1. Start &gt; Run &gt; Services.msc&lt;br /&gt;&lt;br /&gt;2. Find "Printer Spooler" and stop the service&lt;br /&gt;&lt;br /&gt;3. Go to "C:\Windows\System32\spool\PRINTERS" and you will see a list of files. These represent the jobs in the printer queue. Remove these.&lt;br /&gt;&lt;br /&gt;4. Restart the "Printer Spooler" service and your queue should be cleared.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-4605303967491879537?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/4605303967491879537/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=4605303967491879537' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/4605303967491879537'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/4605303967491879537'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/09/forcibly-clear-printer-queue.html' title='Forcibly clear a printer queue'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-5518022696346545405</id><published>2010-09-13T03:53:00.000-07:00</published><updated>2010-09-13T03:55:15.926-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Virtual Hardware'/><category scheme='http://www.blogger.com/atom/ns#' term='VMWare'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows'/><title type='text'>View Gradients/Colours properly in your Virtual Machine (VM)</title><content type='html'>• In the Windows XP operating system (remote system), click on Start menu, then Run. &lt;br /&gt;• Type GPEdit.msc to open Group Policy Editor. &lt;br /&gt;• Navigate to Local Computer Policy -&gt; Computer Configuration -&gt; Administrative Templates -&gt; Windows Components -&gt; Terminal Services. &lt;br /&gt;• In the right pane, double-click on the Limit Maximum Color Depth setting. &lt;br /&gt;• In the Properties dialog, select radio button of Enabled, and then set Color Depth value to 24 bit or Client Compatible&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-5518022696346545405?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/5518022696346545405/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=5518022696346545405' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/5518022696346545405'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/5518022696346545405'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/09/view-gradientscolours-properly-in-your.html' title='View Gradients/Colours properly in your Virtual Machine (VM)'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-76868609630209965</id><published>2010-09-10T02:56:00.000-07:00</published><updated>2010-09-10T03:03:41.367-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Code Snippit - Determining whether brackets are balanced</title><content type='html'>&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;We usually have coding challenges at work quite often. This one was quite useful. The aims were to do something that regular expressions struggle doing; that is, determine whether brackets are balanced.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Example of a legal expression: “([as](&lt;{}&gt;))”.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Example of an illegal expression: “({&lt;)&gt;}”.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Here's what I came up with...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; IsValid(&lt;span class="kwrd"&gt;string&lt;/span&gt; str)&lt;br /&gt;{&lt;br /&gt;    &lt;span class="kwrd"&gt;if&lt;/span&gt; (!&lt;span class="kwrd"&gt;string&lt;/span&gt;.IsNullOrEmpty(str))&lt;br /&gt;    {&lt;br /&gt;        List&amp;lt;&lt;span class="kwrd"&gt;char&lt;/span&gt;&amp;gt; LeftParenthesis = &lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;&lt;span class="kwrd"&gt;char&lt;/span&gt;&amp;gt;() { &lt;span class="str"&gt;'('&lt;/span&gt;, &lt;span class="str"&gt;'{'&lt;/span&gt;, &lt;span class="str"&gt;'['&lt;/span&gt;, &lt;span class="str"&gt;'&amp;lt;'&lt;/span&gt; };&lt;br /&gt;        List&amp;lt;&lt;span class="kwrd"&gt;char&lt;/span&gt;&amp;gt; RightParenthesis = &lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;&lt;span class="kwrd"&gt;char&lt;/span&gt;&amp;gt;() { &lt;span class="str"&gt;')'&lt;/span&gt;, &lt;span class="str"&gt;'}'&lt;/span&gt;, &lt;span class="str"&gt;']'&lt;/span&gt;, &lt;span class="str"&gt;'&amp;gt;'&lt;/span&gt; };&lt;br /&gt;        List&amp;lt;&lt;span class="kwrd"&gt;char&lt;/span&gt;&amp;gt; items = &lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;&lt;span class="kwrd"&gt;char&lt;/span&gt;&amp;gt;(str.Length);&lt;br /&gt;&lt;br /&gt;        &lt;span class="rem"&gt;// Loop through each character&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 0; i &amp;lt; str.Length; i++)&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;char&lt;/span&gt; c = str[i];&lt;br /&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (LeftParenthesis.Contains(c))&lt;br /&gt;            {&lt;br /&gt;                items.Add(c); &lt;span class="rem"&gt;// Add each opening bracket&lt;/span&gt;&lt;br /&gt;            }&lt;br /&gt;            &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; (RightParenthesis.Contains(c))&lt;br /&gt;            {&lt;br /&gt;                &lt;span class="kwrd"&gt;int&lt;/span&gt; rpIndex = RightParenthesis.IndexOf(c);&lt;br /&gt;&lt;br /&gt;                &lt;span class="rem"&gt;// Invalid if there are no open brackets and we find a closing one&lt;/span&gt;&lt;br /&gt;                &lt;span class="kwrd"&gt;int&lt;/span&gt; lastPairIndex = items.LastIndexOf(LeftParenthesis[rpIndex]);&lt;br /&gt;&lt;br /&gt;                &lt;span class="kwrd"&gt;if&lt;/span&gt; (lastPairIndex &amp;gt;= 0)&lt;br /&gt;                {&lt;br /&gt;                    &lt;span class="kwrd"&gt;if&lt;/span&gt; (items[items.Count - 1] != items[lastPairIndex]) &lt;span class="rem"&gt;// Last item must be matching bracket&lt;/span&gt;&lt;br /&gt;                        &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;br /&gt;                    &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;br /&gt;                        items.RemoveAt(lastPairIndex); &lt;span class="rem"&gt;// Remove last pair&lt;/span&gt;&lt;br /&gt;                }&lt;br /&gt;                &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;br /&gt;                    &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="rem"&gt;// Look for any other brackets left over&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (items.Count &amp;gt; 0)&lt;br /&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;br /&gt;}&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-76868609630209965?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/76868609630209965/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=76868609630209965' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/76868609630209965'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/76868609630209965'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/09/code-snippit-determining-whether.html' title='Code Snippit - Determining whether brackets are balanced'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-3654269105725457886</id><published>2010-08-23T04:08:00.000-07:00</published><updated>2010-08-23T04:09:49.323-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='xHTML'/><title type='text'>How to: Configure XHTML Rendering in ASP.NET Web Sites</title><content type='html'>&lt;span style="font-family:verdana;font-size:85%;"&gt;Here's how to configure a website to use XHTML strict. You need to make a minor web.config change too.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;font-size:85%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms178159.aspx"&gt;&lt;span style="font-family:verdana;font-size:85%;"&gt;http://msdn.microsoft.com/en-us/library/ms178159.aspx&lt;/span&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-3654269105725457886?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/3654269105725457886/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=3654269105725457886' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/3654269105725457886'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/3654269105725457886'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/08/how-to-configure-xhtml-rendering-in.html' title='How to: Configure XHTML Rendering in ASP.NET Web Sites'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-4239902764677368902</id><published>2010-06-30T01:42:00.000-07:00</published><updated>2010-06-30T01:50:46.551-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='LinqToSQL'/><title type='text'>LINQ To SQL ERROR: An attempt was made to remove a relationship between a [Table1] and a [Table2].</title><content type='html'>&lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold;font-family:verdana;" &gt;Full Error&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);font-family:verdana;" &gt;An attempt was made to remove a relationship between a [Table1] and a [Table2]. However, one of the relationship's foreign keys ([Table1].[Foreign Key]) cannot be set to null.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;This error usually occurs when trying to called SubmitChanges() on the data context.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;For example, I have received this error when trying to commit an object and I have not property build up its properties (one of which may be another table) and when trying to commit this parent object, its related table will be null; this throws an error.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;So what you could do is...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;1. Ensure the property is present (that is, if you want to commit it in one transaction).&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;2. Tell the framework to delete child items on submitting... Open the DBML file in Xml Editor (Right Click &gt; Open With...) and find the association and tag " &lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-family:verdana;font-size:85%;"  &gt;DeleteOnNull="true"&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:verdana;"&gt; " to the end.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;- Alternately, you can specify this in the code... &lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-family:verdana;font-size:85%;"  &gt;DataContextInstance.TableName.DeleteAllOnSubmit(items);&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;span style="font-family: verdana;"&gt;3. Remove the table reference as a property all together. Open the DBML file, click on the association and view the properties. Set '&lt;span style="font-weight: bold;"&gt;Child Property&lt;/span&gt;' to '&lt;span style="font-weight: bold;"&gt;False&lt;/span&gt;'.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Hope this helps!&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-4239902764677368902?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/4239902764677368902/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=4239902764677368902' title='19 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/4239902764677368902'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/4239902764677368902'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/06/linq-to-sql-error-attempt-was-made-to.html' title='LINQ To SQL ERROR: An attempt was made to remove a relationship between a [Table1] and a [Table2].'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>19</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-2352074782310731224</id><published>2010-06-16T06:10:00.001-07:00</published><updated>2010-06-16T06:10:44.814-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone'/><title type='text'>iPhone SDK in Windows</title><content type='html'>Here's a good guide on getting the iPhone SDK working from a windows isntallation.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;http://iphone-sdk-in-windows.co.uk/&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-2352074782310731224?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/2352074782310731224/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=2352074782310731224' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/2352074782310731224'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/2352074782310731224'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/06/iphone-sdk-in-windows.html' title='iPhone SDK in Windows'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-8139222502661854725</id><published>2010-06-11T07:10:00.000-07:00</published><updated>2010-06-11T07:23:22.826-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CruiseControl.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Continuous Integration'/><title type='text'>CruiseControl.NET: 10 Useful Plugins [Written in C#.NET]</title><content type='html'>&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;For the past two years I have developed various Continuous Integration systems and along the way, like most things, you collect a lot of information. Recently, I have managed to compile most of this into this solution and kept it up to date.&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;For the build process of our Continuous Integration, we can give CruiseControl.NET as much power as we desire. Most developers prefer to keep logic in Nant/MSBuild scripts, while some find themselves using CCNET plugins to manage a lot of the work.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;In this solution attached, I have included all of the plugins I have developed and have used within some of my processes (I say some because the other use build scripts to perform similar actions). I have updated the solution to work with &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;CCNET v1.5&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; [1.5.6804.1 to be specific].&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;If you don't have this particular version, you can either upgrade to it, or easier, copy the required files into the 'References' folder and recompile the plugins. The files required are:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;- ThoughtWorks.CruiseControl.Core.dll&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;- NetReflector.dll&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;- Wix.dll&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;These can all be found in the 'server' directory of your CCNET setup. Remember, with plugins, the file names are specific (NOTE: all must start with ccnet and end within plugin.dll). This has already been done.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Included in the ZIP file are the following plugins:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;- Banty.AssemblyInfoUpdater - Updates assemblyinfo files with a CCNET build version number.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;- Banty.CustomVersioner - Enables a custom versioner (labeller) with wildcard support.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;- Banty.MSILister - Lists and produced a packing file to display the contents of an MSI file as XML.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;- Banty.TestHarness - Used to test the plugins locally&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;- Banty.VersionMSIFile - Injects a CCNET version into an MSI file&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;- Banty.VersionWixFile - Injects a CCNET version into a Wix Setup project&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;- Banty.VSSCommentCollector - Collects VSS comments for the build.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;- CCNet.Sequential.PlugIn+Unittests (External project updated to latest version)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;- MsBuildToCCNet (External project by rodymeister)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;a href="http://sites.google.com/site/tutorialgenius/%5BCCNET%5DCruiseControl.NETPlugins.zip?attredirects=0"&gt;Download here&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-8139222502661854725?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/8139222502661854725/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=8139222502661854725' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/8139222502661854725'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/8139222502661854725'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/06/cruisecontrolnet-10-useful-plugins.html' title='CruiseControl.NET: 10 Useful Plugins [Written in C#.NET]'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-3044494279414803566</id><published>2010-06-11T07:00:00.001-07:00</published><updated>2010-06-11T07:00:20.720-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JSON'/><category scheme='http://www.blogger.com/atom/ns#' term='JQuery'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Working with ASP.NET, JQUERY and JSON [EXAMPLES]</title><content type='html'>I have put together some examples of working with ASP.NET, JQUERY and JSON. The examples use three techniques:&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;- Page Methods&lt;/div&gt;&lt;div&gt;- Web Services&lt;/div&gt;&lt;div&gt;- WCF Services&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;and neither of them use UpdatePanels or ScriptManagers to display dynamic content, worth a look!&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The file is for .NET Framework 3.5 and written in C#.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://sites.google.com/site/tutorialgenius/%5BJQUERY%5DASP.NETwithJSONandJQUERY.zip?attredirects=0"&gt;Download Here&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-3044494279414803566?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/3044494279414803566/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=3044494279414803566' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/3044494279414803566'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/3044494279414803566'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/06/working-with-aspnet-jquery-and-json.html' title='Working with ASP.NET, JQUERY and JSON [EXAMPLES]'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-4139555290131096673</id><published>2010-06-11T01:32:00.000-07:00</published><updated>2010-06-11T01:33:14.617-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JSON'/><category scheme='http://www.blogger.com/atom/ns#' term='JQuery'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><title type='text'>JQuery: Calling ASP.NET Page Methods</title><content type='html'>Here is a great page explaining how to call page methods directly using JQuery.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/"&gt;http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-4139555290131096673?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/4139555290131096673/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=4139555290131096673' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/4139555290131096673'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/4139555290131096673'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/06/jquery-calling-aspnet-page-methods.html' title='JQuery: Calling ASP.NET Page Methods'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-1478973254424343921</id><published>2010-06-04T03:57:00.000-07:00</published><updated>2010-06-04T04:02:44.472-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual Studio'/><title type='text'>Error connecting to undo manager of source file "designer file here"</title><content type='html'>This error happens a lot with visual studio, up to and including VS2008. The reason being that VS keep track of the form designers in debug mode by creating 'designer' files for each ASP.NET or each Windows Form etc...&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This usually occurs, for whatever reason, when the designer file cannot be updated, usually being its corrupted. To resolve this error, simply do the following...&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;ASP.NET&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="  line-height: 18px; "&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;1) Right-click the designer file and select delete&lt;br /&gt;2) Right-click the aspx file and select Convert to Web Application&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="  line-height: 18px; font-family:'segoe ui', tahoma, verdana, 'lucida grande', 'lucida sans unicode', sans-serif;font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Other Project Types&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="  line-height: 18px; font-family:'segoe ui', tahoma, verdana, 'lucida grande', 'lucida sans unicode', sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Exclude the file from the Project, recompile, then re-include, the recompiles.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-1478973254424343921?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/1478973254424343921/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=1478973254424343921' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/1478973254424343921'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/1478973254424343921'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/06/error-connecting-to-undo-manager-of.html' title='Error connecting to undo manager of source file &quot;designer file here&quot;'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-4758807639956366681</id><published>2010-06-02T06:58:00.000-07:00</published><updated>2010-06-02T07:01:04.448-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual Studio'/><title type='text'>.NET: LoaderLock was detected</title><content type='html'>&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Error Message&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#FF0000;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;The problem can be solved  by switching off the MDA:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Debug -&gt; Exceptions -&gt; Managed Debug Assistants&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;and unchecking the LoaderLock item.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;This simply tells visual studio that you do not wish to be alerted by this exception everytime you debug the application.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-4758807639956366681?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/4758807639956366681/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=4758807639956366681' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/4758807639956366681'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/4758807639956366681'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/06/net-loaderlock-was-detected.html' title='.NET: LoaderLock was detected'/><author><name>s34n</name><uri>http://www.blogger.com/profile/16947568863329729565</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='19' height='32' src='http://3.bp.blogspot.com/_HiphnHyooWk/TAY3B1gzMqI/AAAAAAAAAAM/6gIl0rtdtic/S220/3175_544118288223_279201131_2827975_2915520_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-320176107904597883</id><published>2010-06-02T03:09:00.000-07:00</published><updated>2010-06-02T03:40:53.800-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>Restore SQL Server Database from .BAK backup file</title><content type='html'>You would think that restoring a backup would be fairly straight forward, but usual, this isn't always the case. We need to create an MDF (database) and LDF (log file) from the .BAK file, and plug this into SQL Server. urgh.&lt;br /&gt;&lt;br /&gt;First things first... Run the below command to find out the logical names of the MDF and LDF files. I recommand running this under the master database or you will receive a 'database in use' error message.&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;RESTORE&lt;/span&gt; FILELISTONLY&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;FROM&lt;/span&gt; &lt;span class="kwrd"&gt;DISK&lt;/span&gt; = &lt;span class="str"&gt;'C:\dbbackup.bak'&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now we have these names, we can restore to them using the following command. We can specify a UNC path to the BAK file incase we want to update over a network, but the MDF and LDF file paths cannot be UNC.&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;RESTORE&lt;/span&gt; &lt;span class="kwrd"&gt;DATABASE&lt;/span&gt; [TESTDB]&lt;/pre&gt;&lt;pre&gt;&lt;span class="kwrd"&gt;FROM&lt;/span&gt; &lt;span class="kwrd"&gt;DISK&lt;/span&gt; = &lt;span class="str"&gt;'C:\dbbackup.bak'&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;WITH&lt;/span&gt; REPLACE,&lt;/pre&gt;&lt;pre&gt;MOVE &lt;span class="str"&gt;'TESTDB'&lt;/span&gt; &lt;span class="kwrd"&gt;TO&lt;/span&gt; &lt;span class="str"&gt;'C:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\Data\TESTDB.MDF'&lt;/span&gt;,&lt;/pre&gt;&lt;pre class="alt"&gt;MOVE &lt;span class="str"&gt;'TESTDB_log'&lt;/span&gt; &lt;span class="kwrd"&gt;TO&lt;/span&gt; &lt;span class="str"&gt;'C:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\Data\TESTDB_log.LDF'&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;The database name will be the logical name of the MDF file... In my case, I could not get this to work until I had created a database with the same name before hand.&lt;br /&gt;Ensure the directories above exist otherwise it will not work. I chose to place them with my other SQL Server table definitions.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-320176107904597883?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/320176107904597883/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=320176107904597883' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/320176107904597883'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/320176107904597883'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/06/restore-sql-server-database-from-bak.html' title='Restore SQL Server Database from .BAK backup file'/><author><name>TutorialGenius</name><uri>http://www.blogger.com/profile/16984408396121354465</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://4.bp.blogspot.com/_qvTkOBaMdWA/SQosKkjd2wI/AAAAAAAAAAM/ZX5jcQQqXfs/s1600-R/n279201131_2306568_8104.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-2267429232456162894</id><published>2010-04-26T04:05:00.000-07:00</published><updated>2010-04-26T04:12:19.747-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Unit Testing'/><category scheme='http://www.blogger.com/atom/ns#' term='Visual Studio'/><title type='text'>Unit Testing: Accessing AppSettings within the context of the test</title><content type='html'>I recently had an issue with my tests failing, I realised it was because when using my particular gtest suite, the debug files are not stored within bin\Debug, but rather somewhere else; and the configuration files are not being copied!&lt;br /&gt;&lt;br /&gt;This was quite dramatic as my DB connection strings are stored as settings, and needed these to produce tests against the data. The simpliest way to solve this problem is to add a post-build event to the test project. This psot build event will copy the configuration file to the target destination. The testing suite will then pick up these settings as and when requested.&lt;br /&gt;&lt;br /&gt;1. Right click and properties on the test project&lt;br /&gt;2. Click Build Events Tab.&lt;br /&gt;3. Add the following post build event...&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;copy /Y &lt;span class="str"&gt;"$(ProjectDir)app.config"&lt;/span&gt; &lt;span class="str"&gt;"$(TargetPath).config"&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This will ensure your config file is copied to its destination, where your test suite (I.e. NUnit can pick it up).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-2267429232456162894?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/2267429232456162894/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=2267429232456162894' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/2267429232456162894'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/2267429232456162894'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/04/unit-testing-accessing-appsettings.html' title='Unit Testing: Accessing AppSettings within the context of the test'/><author><name>TutorialGenius</name><uri>http://www.blogger.com/profile/16984408396121354465</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://4.bp.blogspot.com/_qvTkOBaMdWA/SQosKkjd2wI/AAAAAAAAAAM/ZX5jcQQqXfs/s1600-R/n279201131_2306568_8104.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-6715315827016645880</id><published>2010-04-23T06:51:00.000-07:00</published><updated>2010-04-23T06:54:30.631-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><category scheme='http://www.blogger.com/atom/ns#' term='JQuery'/><title type='text'>JQuery: Select elements containing an attribute</title><content type='html'>Here's a simply JQuery snippit that will select all elements using the selector which contain a specified attribute...&lt;br /&gt;&lt;br /&gt;This will select all table rows (TR's) of a table with an ID of 'tblTest' that have an attribute 'uniqueid'.&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;$("table#tblTest tr[uniqueid]")&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-6715315827016645880?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/6715315827016645880/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=6715315827016645880' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/6715315827016645880'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/6715315827016645880'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/04/jquery-select-elements-containing.html' title='JQuery: Select elements containing an attribute'/><author><name>TutorialGenius</name><uri>http://www.blogger.com/profile/16984408396121354465</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://4.bp.blogspot.com/_qvTkOBaMdWA/SQosKkjd2wI/AAAAAAAAAAM/ZX5jcQQqXfs/s1600-R/n279201131_2306568_8104.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-7259967237267541453</id><published>2010-04-23T05:48:00.000-07:00</published><updated>2010-04-23T06:51:25.903-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><title type='text'>Javascript: Add/Remove classes from elements</title><content type='html'>Here's a simple way of achiving this without any bloating libraries (I.e. JQuery etc.)&lt;br /&gt;There is also a 'HasClass' method, which becomes quite useful.&lt;br /&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;function hasClass(ele, cls) {&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;return&lt;/span&gt; ele.className.match(&lt;span class="kwrd"&gt;new&lt;/span&gt; RegExp(&lt;span class="str"&gt;'(\\s|^)'&lt;/span&gt; + cls + &lt;span class="str"&gt;'(\\s|$)'&lt;/span&gt;));&lt;/pre&gt;&lt;pre class="alt"&gt;}&lt;/pre&gt;&lt;pre&gt;function addClass(ele, cls) {&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;if&lt;/span&gt; (!&lt;span class="kwrd"&gt;this&lt;/span&gt;.hasClass(ele, cls)) ele.className += &lt;span class="str"&gt;" "&lt;/span&gt; + cls;&lt;/pre&gt;&lt;pre&gt;}&lt;/pre&gt;&lt;pre class="alt"&gt;function removeClass(ele, cls) {&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;if&lt;/span&gt; (hasClass(ele, cls)) {&lt;/pre&gt;&lt;pre class="alt"&gt;        var reg = &lt;span class="kwrd"&gt;new&lt;/span&gt; RegExp(&lt;span class="str"&gt;'(\\s|^)'&lt;/span&gt; + cls + &lt;span class="str"&gt;'(\\s|$)'&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;        ele.className = ele.className.replace(reg, &lt;span class="str"&gt;' '&lt;/span&gt;);&lt;/pre&gt;&lt;pre class="alt"&gt;    }&lt;/pre&gt;&lt;pre&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-7259967237267541453?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/7259967237267541453/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=7259967237267541453' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/7259967237267541453'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/7259967237267541453'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/04/javascript-addremove-classes-from.html' title='Javascript: Add/Remove classes from elements'/><author><name>TutorialGenius</name><uri>http://www.blogger.com/profile/16984408396121354465</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://4.bp.blogspot.com/_qvTkOBaMdWA/SQosKkjd2wI/AAAAAAAAAAM/ZX5jcQQqXfs/s1600-R/n279201131_2306568_8104.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-7190594812166954092</id><published>2010-04-21T05:12:00.000-07:00</published><updated>2010-04-21T05:15:14.522-07:00</updated><title type='text'>ASP.NET: Using FindControl Recursively.</title><content type='html'>FindControl can be a bit of a pain, especially as it doesn't contain recursive support; that being, you need to know the direct parent of an object before you can start your search.&lt;br /&gt;&lt;br /&gt;I have attached a method which is useful, especially when creating generic methods for groups of objects where the parent is unknown.&lt;br /&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// Finds a Control recursively. Note finds the first match and exists&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="RootControl"&amp;gt;Root control to start looking in.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="ControlToFind"&amp;gt;The control to find within it recursively.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;The control if it exists.&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; Control FindControlRecursive(Control RootControl, &lt;span class="kwrd"&gt;string&lt;/span&gt; ControlToFind)&lt;/pre&gt;&lt;pre&gt;        {&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (RootControl.ID == ControlToFind)&lt;/pre&gt;&lt;pre&gt;                &lt;span class="kwrd"&gt;return&lt;/span&gt; RootControl;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (Control Ctl &lt;span class="kwrd"&gt;in&lt;/span&gt; RootControl.Controls)&lt;/pre&gt;&lt;pre class="alt"&gt;            {&lt;/pre&gt;&lt;pre&gt;                Control FoundCtl = FindControlRecursive(Ctl, ControlToFind);&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;if&lt;/span&gt; (FoundCtl != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre&gt;                    &lt;span class="kwrd"&gt;return&lt;/span&gt; FoundCtl;&lt;/pre&gt;&lt;pre class="alt"&gt;            }&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;        }&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8602939654357884727-7190594812166954092?l=tutorialgenius.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialgenius.blogspot.com/feeds/7190594812166954092/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8602939654357884727&amp;postID=7190594812166954092' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/7190594812166954092'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8602939654357884727/posts/default/7190594812166954092'/><link rel='alternate' type='text/html' href='http://tutorialgenius.blogspot.com/2010/04/aspnet-using-findcontrol-recursively.html' title='ASP.NET: Using FindControl Recursively.'/><author><name>TutorialGenius</name><uri>http://www.blogger.com/profile/16984408396121354465</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://4.bp.blogspot.com/_qvTkOBaMdWA/SQosKkjd2wI/AAAAAAAAAAM/ZX5jcQQqXfs/s1600-R/n279201131_2306568_8104.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8602939654357884727.post-4867829167681208992</id><published>2010-04-14T07:37:00.000-07:00</published><updated>2010-04-23T07:02:41.498-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><title type='text'>ASP.NET GridView: Adding Sorting and Paging with Business Object Binding</title><content type='html'>So recently, I was given the challenge of binding a complex business object to a GridView... I didn't think it would be tricky, but I did find a few niggles along the way. I thought I would share them so anybody else attempting to do this can pick up some lessons learned. The following is my implementation of this task...&lt;br /&gt;&lt;br /&gt;This example displays a list of courses. Each course has an ID, a name and a production status. The production status' will be rendered as images within the gridview. Below is the designer structure of the grid..&lt;br /&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:GridView&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;="grdBantyGridView"&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                    &lt;span class="attr"&gt;CssClass&lt;/span&gt;&lt;span class="kwrd"&gt;="gridView"&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="attr"&gt;rowstyle-borderstyle&lt;/span&gt;&lt;span class="kwrd"&gt;="none"&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                    &lt;span class="attr"&gt;GridLines&lt;/span&gt;&lt;span class="kwrd"&gt;="None"&lt;/span&gt; &lt;span class="attr"&gt;BorderStyle&lt;/span&gt;&lt;span class="kwrd"&gt;="None"&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="attr"&gt;RowStyle-CssClass&lt;/span&gt;&lt;span class="kwrd"&gt;="row"&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                    &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="attr"&gt;ShowFooter&lt;/span&gt;&lt;span class="kwrd"&gt;="True"&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                    &lt;span class="attr"&gt;AutoGenerateColumns&lt;/span&gt;&lt;span class="kwrd"&gt;="False"&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="attr"&gt;ShowHeader&lt;/span&gt;&lt;span class="kwrd"&gt;="True"&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                    &lt;span class="attr"&gt;AlternatingRowStyle-CssClass&lt;/span&gt;&lt;span class="kwrd"&gt;="alternate"&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="attr"&gt;AllowSorting&lt;/span&gt;&lt;span class="kwrd"&gt;="True"&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                    &lt;span class="attr"&gt;UseAccessibleHeader&lt;/span&gt;&lt;span class="kwrd"&gt;="True"&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="attr"&gt;onrowdatabound&lt;/span&gt;&lt;span class="kwrd"&gt;="grdBantyGridView_RowDataBound"&lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;                    &lt;span class="attr"&gt;onsorting&lt;/span&gt;&lt;span class="kwrd"&gt;="grdBantyGridView_Sorting"&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="attr"&gt;OnPageIndexChanging&lt;/span&gt;&lt;span class="kwrd"&gt;="grdBantyGridView_PageIndexChanging"&lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;                    &lt;span class="attr"&gt;AllowPaging&lt;/span&gt;&lt;span class="kwrd"&gt;="True"&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="attr"&gt;PageSize&lt;/span&gt;&lt;span class="kwrd"&gt;="10"&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                    &lt;span class="attr"&gt;PagerSettings-Mode&lt;/span&gt;&lt;span class="kwrd"&gt;="NumericFirstLast"&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="attr"&gt;PagerSettings-PageButtonCount&lt;/span&gt;&lt;span class="kwrd"&gt;="10"&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                    &lt;span class="attr"&gt;DataKeyNames&lt;/span&gt;&lt;span class="kwrd"&gt;="ID"&lt;/span&gt; &lt;span class="attr"&gt;EnableViewState&lt;/span&gt;&lt;span class="kwrd"&gt;="False"&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;HeaderStyle&lt;/span&gt; &lt;span class="attr"&gt;CssClass&lt;/span&gt;&lt;span class="kwrd"&gt;="gridViewHeader"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;RowStyle&lt;/span&gt; &lt;span class="attr"&gt;BorderStyle&lt;/span&gt;&lt;span class="kwrd"&gt;="None"&lt;/span&gt; &lt;span class="attr"&gt;CssClass&lt;/span&gt;&lt;span class="kwrd"&gt;="row"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Columns&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:BoundField&lt;/span&gt; &lt;span class="attr"&gt;DataField&lt;/span&gt;&lt;span class="kwrd"&gt;="ID"&lt;/span&gt; &lt;span class="attr"&gt;Visible&lt;/span&gt;&lt;span class="kwrd"&gt;="False"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:TemplateField&lt;/span&gt; &lt;span class="attr"&gt;AccessibleHeaderText&lt;/span&gt;&lt;span class="kwrd"&gt;="Name"&lt;/span&gt; &lt;span class="attr"&gt;HeaderText&lt;/span&gt;&lt;span class="kwrd"&gt;="Name"&lt;/span&gt; &lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="attr"&gt;SortExpression&lt;/span&gt;&lt;span class="kwrd"&gt;="Name"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ItemTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:Label&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;="lblName"&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;                            &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;='&amp;lt;%# Eval("Name") %&amp;gt;'&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;asp:Label&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ItemTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;asp:TemplateField&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:TemplateField&lt;/span&gt; &lt;span class="attr"&gt;AccessibleHeaderText&lt;/span&gt;&lt;span class="kwrd"&gt;="Description"&lt;/span&gt; &lt;span class="attr"&gt;HeaderText&lt;/span&gt;&lt;span class="kwrd"&gt;="Description"&lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;                    &lt;span class="attr"&gt;SortExpression&lt;/span&gt;&lt;span class="kwrd"&gt;="Description"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ItemTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:Label&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;="lblDescription"&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt; &lt;/pre&gt;&lt;pre class="alt"&gt;                            &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;='&amp;lt;%# Eval("Description") %&amp;gt;'&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;asp:Label&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ItemTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;asp:TemplateField&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:TemplateField&lt;/span&gt; &lt;span class="attr"&gt;AccessibleHeaderText&lt;/span&gt;&lt;span class="kwrd"&gt;="Status"&lt;/span&gt; &lt;span class="attr"&gt;HeaderText&lt;/span&gt;&lt;span class="kwrd"&gt;="Status"&lt;/span&gt; &lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="attr"&gt;SortExpression&lt;/span&gt;&lt;span class="kwrd"&gt;="Status"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ItemTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:Image&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;="imgStatus"&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;                            &lt;span class="attr"&gt;ImageUrl&lt;/span&gt;&lt;span class="kwrd"&gt;='&amp;lt;%# GetCourseStatusUrl((Banty.Library.DTO.CourseStatus)Eval("Status")) %&amp;gt;'&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ItemTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;asp:TemplateField&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Columns&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;FooterStyle&lt;/span&gt; &lt;span class="attr"&gt;CssClass&lt;/span&gt;&lt;span class="kwrd"&gt;="gridViewFooter"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;EmptyDataTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            No data available.&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;EmptyDataTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;PagerStyle&lt;/span&gt; &lt;span class="attr"&gt;height&lt;/span&gt;&lt;span class="kwrd"&gt;="5px"&lt;/span&gt; &lt;span class="attr"&gt;verticalalign&lt;/span&gt;&lt;span class="kwrd"&gt;="Bottom"&lt;/span&gt; &lt;span class="attr"&gt;horizontalalign&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;AlternatingRowStyle&lt;/span&gt; &lt;span class="attr"&gt;CssClass&lt;/span&gt;&lt;span class="kwrd"&gt;="alternate"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;asp:GridView&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Things to note&lt;/span&gt;:&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;AutoGenerateColumns&lt;/span&gt; - This gives us more flexibility over what columns appear when we bind out business objects.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;AllowSorting&lt;/span&gt; - Allows the sorting, but because we have disabled AutoGenerateColumns, we need to override the 'onsorting' event.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;AllowPaging&lt;/span&gt; - Allow the paging. We must override the 'OnPageIndexChanging' event to make this work.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;DataKeyNames&lt;/span&gt; - Set this so that we can retrieve each row during the 'onrowdatabound' event. This will store a datakey against each row. I am using this to enable javascript highlights of rows in this example.&lt;br /&gt;&lt;br /&gt;For each column in the Gridview definition, be sure to add a &lt;span style="font-weight:bold;"&gt;SortExpression&lt;/span&gt; value. This helps us in the code-behind to identify while column is requesting the sort.&lt;br /&gt;&lt;br /&gt;The above points are key to creating this pagable and sortable grid, and must be taken into consideration... Lets now have a look at the code behind and how we fit this all together...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; List&amp;lt;Banty.Library.DTO.Course&amp;gt; courses = &lt;span class="kwrd"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="preproc"&gt;#region&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; Properties&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; List&amp;lt;Banty.Library.DTO.Course&amp;gt; Courses { get { &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;this&lt;/span&gt;.courses; } set { &lt;span class="kwrd"&gt;this&lt;/span&gt;.courses = &lt;span class="kwrd"&gt;value&lt;/span&gt;; } }&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="preproc"&gt;#endregion&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Page_Load(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;/pre&gt;&lt;pre&gt;        {&lt;/pre&gt;&lt;pre class="alt"&gt;        }&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// Initialises the user control.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; InitControl()&lt;/pre&gt;&lt;pre class="alt"&gt;        {&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;this&lt;/span&gt;.Courses != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre class="alt"&gt;            {&lt;/pre&gt;&lt;pre&gt;                &lt;span class="kwrd"&gt;this&lt;/span&gt;.SetDataSource(&lt;span class="kwrd"&gt;true&lt;/span&gt;);&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;                pnlNoData.Visible = &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;                pnlGridView.Visible = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;            }&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            {&lt;/pre&gt;&lt;pre class="alt"&gt;                pnlNoData.Visible = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;                pnlGridView.Visible = &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;            }&lt;/pre&gt;&lt;pre&gt;        }&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// Sets the datasource to the gridview.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; List&amp;lt;Banty.Library.DTO.Course&amp;gt; SetDataSource(&lt;span class="kwrd"&gt;bool&lt;/span&gt; dataBind)&lt;/pre&gt;&lt;pre&gt;        {&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="rem"&gt;// Bind apps to the grid view.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;this&lt;/span&gt;.grdBantyGridView.DataSource = &lt;span class="kwrd"&gt;this&lt;/span&gt;.Courses;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="rem"&gt;// Bind if requested&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (dataBind)&lt;/pre&gt;&lt;pre&gt;                &lt;span class="kwrd"&gt;this&lt;/span&gt;.grdBantyGridView.DataBind();&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;this&lt;/span&gt;.Courses;&lt;/pre&gt;&lt;pre class="alt"&gt;        }&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// Performs actions as the row data is bound.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="sender"&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="e"&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; grdBantyGridView_RowDataBound(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, GridViewRowEventArgs e)&lt;/pre&gt;&lt;pre class="alt"&gt;        {&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (e.Row.RowType == DataControlRowType.DataRow)&lt;/pre&gt;&lt;pre class="alt"&gt;            {&lt;/pre&gt;&lt;pre&gt;                &lt;span class="kwrd"&gt;int&lt;/span&gt; uniqueID = 0;&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;if&lt;/span&gt; (Int32.TryParse(&lt;span class="kwrd"&gt;this&lt;/span&gt;.grdBantyGridView.DataKeys[e.Row.RowIndex].Value.ToString(), &lt;span class="kwrd"&gt;out&lt;/span&gt; uniqueID))&lt;/pre&gt;&lt;pre&gt;                {&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="rem"&gt;// Add applicationID to row&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                    e.Row.Attributes[&lt;span class="str"&gt;"uniqueid"&lt;/span&gt;] = uniqueID.ToString();&lt;/pre&gt;&lt;pre class="alt"&gt;                }&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="rem"&gt;// So that we can distinguish rows&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                e.Row.Attributes.Add(&lt;span class="str"&gt;"OnMouseUp"&lt;/span&gt;, &lt;span class="str"&gt;"grdBantyGridView_OnMouseUp("&lt;/span&gt; + e.Row.ClientID + &lt;span class="str"&gt;");"&lt;/span&gt;);&lt;/pre&gt;&lt;pre class="alt"&gt;            }&lt;/pre&gt;&lt;pre&gt;        }&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// Provides an image URL for value.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="input"&amp;gt;data value&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;A URL to the value icon&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; GetCourseStatusUrl(CourseStatus input)&lt;/pre&gt;&lt;pre&gt;        {&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;string&lt;/span&gt; result = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;switch&lt;/span&gt; (input.ID)&lt;/pre&gt;&lt;pre&gt;            {&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;case&lt;/span&gt; 1:&lt;/pre&gt;&lt;pre&gt;                    result = &lt;span class="str"&gt;"../images/icon-no.gif"&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="kwrd"&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;                &lt;span class="kwrd"&gt;case&lt;/span&gt; 2:&lt;/pre&gt;&lt;pre class="alt"&gt;                    result = &lt;span class="str"&gt;"../images/icon-yes.gif"&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;                    &lt;span class="kwrd"&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;case&lt;/span&gt; 3:&lt;/pre&gt;&lt;pre&gt;                    result = &lt;span class="str"&gt;"../images/icon-verified.gif"&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="kwrd"&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;            }&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; result;&lt;/pre&gt;&lt;pre class="alt"&gt;        }&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// Handles the sorting of the gridview columns&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="sender"&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="e"&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; grdBantyGridView_Sorting(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, GridViewSortEventArgs e)&lt;/pre&gt;&lt;pre class="alt"&gt;        {&lt;/pre&gt;&lt;pre&gt;            &lt;span class="rem"&gt;// Determine weather column is valid&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;string&lt;/span&gt;[] validFields = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt;[] { &lt;span class="str"&gt;"Name"&lt;/span&gt;, &lt;span class="str"&gt;"Description"&lt;/span&gt;, &lt;span class="str"&gt;"Status"&lt;/span&gt;};&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/p
