<?xml version="1.0" encoding="utf-8"?>
<feed xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom">
  <title>Keith Rull</title>
  <link rel="alternate" type="text/html" href="http://www.keithrull.com/" />
  <link rel="self" href="http://www.keithrull.com/SyndicationService.asmx/GetAtom" />
  <icon>favicon.ico</icon>
  <updated>2010-06-09T17:21:23.305759-05:00</updated>
  <author>
    <name>Keith Rull</name>
  </author>
  <subtitle>Blog of a Filipino Developer about C#, VB.NET, ASP.NET, Java, PHP, SQL Server, MySql and Oracle</subtitle>
  <id>http://www.keithrull.com/</id>
  <generator uri="http://dasblog.info/" version="2.3.9074.18820">DasBlog</generator>
  <entry>
    <title>Expression Studio 4 is out  and my 60-day tool</title>
    <link rel="alternate" type="text/html" href="http://www.keithrull.com/2010/06/09/ExpressionStudio4IsOutAndMy60dayTool.aspx" />
    <id>http://www.keithrull.com/PermaLink,guid,5f98c016-11a9-4da9-920c-a00eca38e54a.aspx</id>
    <published>2010-06-09T17:06:43.481212-05:00</published>
    <updated>2010-06-09T17:21:23.305759-05:00</updated>
    <category term="All about Keith" label="All about Keith" scheme="http://www.keithrull.com/CategoryView,category,AllAboutKeith.aspx" />
    <category term="Fun Stuff" label="Fun Stuff" scheme="http://www.keithrull.com/CategoryView,category,FunStuff.aspx" />
    <category term="Silverlight" label="Silverlight" scheme="http://www.keithrull.com/CategoryView,category,Silverlight.aspx" />
    <category term="Tech News and Issues" label="Tech News and Issues" scheme="http://www.keithrull.com/CategoryView,category,TechNewsAndIssues.aspx" />
    <author>
      <name>Keith Rull</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">I was really excited last Monday after seeing <a href="http://blog.seattlepi.com/microsoft/archives/209785.asp">Expression
Studio 4 has been released</a> (I have to admit that I'm one of those developers who
logged in at MSDN at 12 midnight to check if the RTM bits are already out. hehe).
I think this is great news for all XAMLers all over the world. On thing that I'm really
sad about though is that our corporate MSDN license only has Expression Studio 4 Professional
and not the Ultimate version. Bummed. So I ended up downloading the 60 day trial up
until I can figure out how I can get a copy of the full version (OK, here's the part
that I ask donations to get a full copy but I'll leave that out. LOL). 
<br /><br />
Sad, but still happy. At least I have 60 days to enjoy this new tool. ;)<br /><p></p><img width="0" height="0" src="http://www.keithrull.com/aggbug.ashx?id=5f98c016-11a9-4da9-920c-a00eca38e54a" /></div>
    </content>
  </entry>
  <entry>
    <title>How To: Count the occurrence of a character in a string in SQL</title>
    <link rel="alternate" type="text/html" href="http://www.keithrull.com/2010/06/09/HowToCountTheOccurrenceOfACharacterInAStringInSQL.aspx" />
    <id>http://www.keithrull.com/PermaLink,guid,da3de00b-ac6d-41b8-84e0-f9fe540c3df9.aspx</id>
    <published>2010-06-09T16:35:38.518-05:00</published>
    <updated>2010-06-09T17:03:53.87488-05:00</updated>
    <category term="Fun Stuff" label="Fun Stuff" scheme="http://www.keithrull.com/CategoryView,category,FunStuff.aspx" />
    <category term="SQL" label="SQL" scheme="http://www.keithrull.com/CategoryView,category,SQL.aspx" />
    <author>
      <name>Keith Rull</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">Last night I was trying to cleanup the spammers
from the database of devpinoy.org and while I was evaluating the result sets i was
able to conclude that aside from using common spam text like 'cheap', 'buy', 'free',
'deal', 'viagra', 'prozac' that 30% of the false emails that spam accounts are using
multiple dots on their email address. A good example is a subset below from the list
of offenders that I found in the devpinoy db.<br /><img src="http://www.keithrull.com/content/binary/spam_email_accounts.png" /><br /><br />
Having found that fact I immediately created a sql script that will delete users from
the database if they have more than 2 dots in their email address.<br /><br />
Enough with the side note and here is some code.<br /><br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">DECLARE</span> @string2check <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">varchar</span>(50) <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">DECLARE</span> @character2find <span style="color: Fuchsia; background-color: Transparent; font-family: Courier New; font-size: 11px;">char</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">SET</span> @string2check
= <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">'this
is a very long string'</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">SET</span> @character2find
= <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">'i'</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">PRINT</span><span style="color: Fuchsia; background-color: Transparent; font-family: Courier New; font-size: 11px;">LEN</span>(@string2check)
- <span style="color: Fuchsia; background-color: Transparent; font-family: Courier New; font-size: 11px;">LEN</span>(<span style="color: Fuchsia; background-color: Transparent; font-family: Courier New; font-size: 11px;">REPLACE</span>(@string2check,
@character2find, <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">''</span>))</span></pre><br />
What the code above is doing is that it is removing the characters that matched our
search key and then subracts the length of that string to the original string to find
the total occurrence of the character we are looking for.<br /><br />
Now, if you want to use this as a function you can use this:<br /><br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">CREATE</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">FUNCTION</span> udf_CountCharOccurence
(    @string2check <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">varchar</span>(500)
,    @character2find <span style="color: Fuchsia; background-color: Transparent; font-family: Courier New; font-size: 11px;">char</span> )<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"></span>RETURNS <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">INT</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">BEGIN</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">RETURN</span> (<span style="color: Fuchsia; background-color: Transparent; font-family: Courier New; font-size: 11px;">LEN</span>(@string2check)
- <span style="color: Fuchsia; background-color: Transparent; font-family: Courier New; font-size: 11px;">LEN</span>(<span style="color: Fuchsia; background-color: Transparent; font-family: Courier New; font-size: 11px;">REPLACE</span>(
                                @string2check,
@character2find)                                         )
                                ) <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">END</span> GO</span></pre>The
code above works great but there's a catch. If you are concerned with case sensitivity
then the code above wont work. The way around it is to use COLLATION which is supported
by the SQL function below:<br /><br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">CREATE</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">FUNCTION</span> udf_CountCharOccurenceCaseSensitive
(    @string2check <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">varchar</span>(500)
,    @character2find <span style="color: Fuchsia; background-color: Transparent; font-family: Courier New; font-size: 11px;">char</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"></span>)RETURNS <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">INT</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">BEGIN</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">RETURN</span> (<span style="color: Fuchsia; background-color: Transparent; font-family: Courier New; font-size: 11px;">LEN</span>(@string2check)
- <span style="color: Fuchsia; background-color: Transparent; font-family: Courier New; font-size: 11px;">LEN</span>(<span style="color: Fuchsia; background-color: Transparent; font-family: Courier New; font-size: 11px;">REPLACE</span>(
                                @string2check <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">COLLATE</span> SQL_Latin1_General_Cp1_CS_AS,
@character2find <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">COLLATE</span> SQL_Latin1_General_Cp1_CS_AS, <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">''</span>)
                                        )
                                ) <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">END</span> GO</span></pre>In
order to use this in your query all you need to do is<br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">PRINT</span> dbo.udf_CountCharOccurenceCaseSensitive(<span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">'This
is a long text'</span>,<span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">'i'</span>)</span></pre>Or
if you want to put it to use to meet the criteria that I mentioned about dots on emails
you can do it this way:<br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">SELECT</span> * <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">FROM</span> Users <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">WHERE</span> dbo.udf_CountCharOccurenceCaseSensitive(EmailAddress,<span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">'.'</span>)
&gt; 2</span></pre><br />
HTH<br /><br /><br /><img width="0" height="0" src="http://www.keithrull.com/aggbug.ashx?id=da3de00b-ac6d-41b8-84e0-f9fe540c3df9" /></div>
    </content>
  </entry>
  <entry>
    <title>How To: Change table cell color depending on its value using jQuery</title>
    <link rel="alternate" type="text/html" href="http://www.keithrull.com/2010/06/09/HowToChangeTableCellColorDependingOnItsValueUsingJQuery.aspx" />
    <id>http://www.keithrull.com/PermaLink,guid,8672fb88-1b26-41f0-b107-973ad6b9b6e8.aspx</id>
    <published>2010-06-09T13:32:49.166-05:00</published>
    <updated>2010-06-09T16:03:19.347739-05:00</updated>
    <category term="Fun Stuff" label="Fun Stuff" scheme="http://www.keithrull.com/CategoryView,category,FunStuff.aspx" />
    <category term="jQuery" label="jQuery" scheme="http://www.keithrull.com/CategoryView,category,jQuery.aspx" />
    <author>
      <name>Keith Rull</name>
    </author>
    <content type="html">Here's a nifty trick using jQuery on how to iterate on all rows of a table except the first row,
 how to get the value of a column in the current row being iterated and how to change the table cell color depending on the value it contains. &lt;br&gt;
&lt;br&gt;
In this case we wanted to change the color of the 3rd column depending on whether
it is higher or lower than the second column. There are two examples in here. The
first one is select the table via its ID and the second version is selecting the table
based on its class name.&lt;br&gt;
&lt;br&gt;
&lt;pre style="font-size: 11px; font-family: Courier New;"&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt; &amp;lt;script
src=&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&lt;/span&gt; type=&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"text/javascript"&lt;/span&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;br&gt;
&amp;lt;script type=&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"text/javascript"&lt;/span&gt;&amp;gt; 
&lt;br&gt;
$(document).ready(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;function&lt;/span&gt;()&lt;br&gt;
{ 
&lt;br&gt;
&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;//iterate
through all the rows in our table called yourtable&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;//excluding
the first row because those are column titles&lt;/span&gt;
&lt;br&gt;
$(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"#yourtablename
tr:not(:first)"&lt;/span&gt;).each(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;function&lt;/span&gt;()
{ 
&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;//get
the value of the table cell located&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;//in
the third column of the current row&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;var&lt;/span&gt; priceYesterday &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; $(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;).find(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"td:nth-child(2)"&lt;/span&gt;).html();&lt;br&gt;
&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;var&lt;/span&gt; priceToday &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; $(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;).find(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"td:nth-child(3)"&lt;/span&gt;).html();&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;//check
if its greater than zero&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;if&lt;/span&gt; (priceToday
&amp;gt; priceYesterday){&lt;br&gt;
&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;//change
the color of the text to green if its a positive number&lt;/span&gt;
&lt;br&gt;
$(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;).find(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"td:nth-child(3)"&lt;/span&gt;).css(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"color"&lt;/span&gt;, &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"#00FF00"&lt;/span&gt;);&lt;br&gt;
}&lt;br&gt;
&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;else&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;if&lt;/span&gt;(priceToday
&amp;lt; priceYesterday){&lt;br&gt;
&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;//change
the color of the text to red if its a negatice number&lt;/span&gt;
&lt;br&gt;
$(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;).find(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"td:nth-child(3)"&lt;/span&gt;).css(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"color"&lt;/span&gt;, &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"#FF0000"&lt;/span&gt;);&lt;br&gt;
}&lt;br&gt;
});&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;//iterate
through all the rows in our table called yourtable&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;//excluding
the first row because those are column titles&lt;/span&gt;
&lt;br&gt;
$(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;".yourtableclassname
tr:not(:first)"&lt;/span&gt;).each(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;function&lt;/span&gt;()
{ 
&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;//get
the value of the table cell located&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;//in
the third column of the current row&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;var&lt;/span&gt; priceYesterday &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; $(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;).find(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"td:nth-child(2)"&lt;/span&gt;).html();&lt;br&gt;
&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;var&lt;/span&gt; priceToday &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; $(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;).find(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"td:nth-child(3)"&lt;/span&gt;).html();&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;//check
if its greater than zero&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;if&lt;/span&gt; (priceToday
&amp;gt; priceYesterday){&lt;br&gt;
&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;//change
the color of the text to green if its a positive number&lt;/span&gt;
&lt;br&gt;
$(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;).find(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"td:nth-child(3)"&lt;/span&gt;).css(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"color"&lt;/span&gt;, &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"#00FF00"&lt;/span&gt;);&lt;br&gt;
}&lt;br&gt;
&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;else&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;if&lt;/span&gt;(priceToday
&amp;lt; priceYesterday){&lt;br&gt;
&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;//change
the color of the text to red if its a negatice number&lt;/span&gt;
&lt;br&gt;
$(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;).find(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"td:nth-child(3)"&lt;/span&gt;).css(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"color"&lt;/span&gt;, &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"#FF0000"&lt;/span&gt;);&lt;br&gt;
}&lt;br&gt;
});&lt;br&gt;
&lt;br&gt;
});&lt;br&gt;
&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;/pre&gt;Below is the full source for this sample:&lt;br&gt;
&lt;br&gt;
&lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt;&lt;script type="text/javascript"&gt; 
			$(document).ready(function()
			{	
				//iterate through all the rows in our table called yourtable
				//excluding the first row because those are column titles
				$("#yourtablename tr:not(:first)").each(function() { 
					
					//get the value of the table cell located
					//in the third column of the current row
					var priceYesterday = $(this).find("td:nth-child(2)").html();
					var priceToday = $(this).find("td:nth-child(3)").html();
					
					//check if its greater than zero
					if (priceToday &gt; priceYesterday){
						//change the color of the text to green if its a positive number
						$(this).find("td:nth-child(3)").css("color", "#00FF00");
					}
					else if(priceToday &lt; priceYesterday){
						//change the color of the text to red if its a negatice number
						$(this).find("td:nth-child(3)").css("color", "#FF0000");
					}
				});
				
				//iterate through all the rows in our table called yourtable
				//excluding the first row because those are column titles
				$(".yourtableclassname tr:not(:first)").each(function() { 
					
					//get the value of the table cell located
					//in the third column of the current row
					var priceYesterday = $(this).find("td:nth-child(2)").html();
					var priceToday = $(this).find("td:nth-child(3)").html();
					
					//check if its greater than zero
					if (priceToday &gt; priceYesterday){
						//change the color of the text to green if its a positive number
						$(this).find("td:nth-child(3)").css("color", "#00FF00");
					}
					else if(priceToday &lt; priceYesterday){
						//change the color of the text to red if its a negatice number
						$(this).find("td:nth-child(3)").css("color", "#FF0000");
					}
				});

			});
		&lt;/script&gt;
&lt;h3&gt;Iterating to the table via table id
&lt;/h3&gt;
&lt;table id="yourtablename"&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;td&gt;
Product Name&lt;/td&gt;
&lt;td&gt;
Yesterday&lt;/td&gt;
&lt;td&gt;
Today&lt;/td&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr sizcache="2"&gt;
&lt;td nodeindex="1"&gt;
Egg&lt;/td&gt;
&lt;td nodeindex="2"&gt;
1.95&lt;/td&gt;
&lt;td style="color: rgb(0, 255, 0);" nodeindex="3"&gt;
2.10&lt;/td&gt;
&lt;/tr&gt;
&lt;tr sizcache="5"&gt;
&lt;td nodeindex="1"&gt;
Sugar&lt;/td&gt;
&lt;td nodeindex="2"&gt;
1.92&lt;/td&gt;
&lt;td style="color: rgb(255, 0, 0);" nodeindex="3"&gt;
1.88&lt;/td&gt;
&lt;/tr&gt;
&lt;tr sizcache="8"&gt;
&lt;td nodeindex="1"&gt;
Milk&lt;/td&gt;
&lt;td nodeindex="2"&gt;
1.95&lt;/td&gt;
&lt;td style="color: rgb(0, 255, 0);" nodeindex="3"&gt;
1.97&lt;/td&gt;
&lt;/tr&gt;
&lt;tr sizcache="11"&gt;
&lt;td nodeindex="1"&gt;
beans&lt;/td&gt;
&lt;td nodeindex="2"&gt;
3.15&lt;/td&gt;
&lt;td style="color: rgb(255, 0, 0);" nodeindex="3"&gt;
3.06&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3&gt;Iterating to the table via class name
&lt;/h3&gt;
&lt;table class="yourtableclassname"&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;td&gt;
Product Name&lt;/td&gt;
&lt;td&gt;
Yesterday&lt;/td&gt;
&lt;td&gt;
Today&lt;/td&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr sizcache="14"&gt;
&lt;td nodeindex="1"&gt;
Egg&lt;/td&gt;
&lt;td nodeindex="2"&gt;
1.95&lt;/td&gt;
&lt;td style="color: rgb(0, 255, 0);" nodeindex="3"&gt;
2.10&lt;/td&gt;
&lt;/tr&gt;
&lt;tr sizcache="17"&gt;
&lt;td nodeindex="1"&gt;
Sugar&lt;/td&gt;
&lt;td nodeindex="2"&gt;
1.92&lt;/td&gt;
&lt;td style="color: rgb(255, 0, 0);" nodeindex="3"&gt;
1.88&lt;/td&gt;
&lt;/tr&gt;
&lt;tr sizcache="20"&gt;
&lt;td nodeindex="1"&gt;
Milk&lt;/td&gt;
&lt;td nodeindex="2"&gt;
1.95&lt;/td&gt;
&lt;td style="color: rgb(0, 255, 0);" nodeindex="3"&gt;
1.97&lt;/td&gt;
&lt;/tr&gt;
&lt;tr sizcache="23"&gt;
&lt;td nodeindex="1"&gt;
beans&lt;/td&gt;
&lt;td nodeindex="2"&gt;
3.15&lt;/td&gt;
&lt;td style="color: rgb(255, 0, 0);" nodeindex="3"&gt;
3.06&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;br&gt;
&lt;pre style="font-size: 11px; font-family: Courier New;"&gt;&lt;font color="#ff0000"&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;&amp;lt;html&amp;gt;&lt;br&gt;
&amp;lt;head&amp;gt;&lt;br&gt;
&amp;lt;script src=&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&lt;/span&gt; type=&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"text/javascript"&lt;/span&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;br&gt;
&amp;lt;script type=&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"text/javascript"&lt;/span&gt;&amp;gt; 
&lt;br&gt;
$(document).ready(function()&lt;br&gt;
{ 
&lt;br&gt;
&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;//iterate
through all the rows in our table called yourtable&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;//excluding
the first row because those are column titles&lt;/span&gt;
&lt;br&gt;
$(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"#yourtablename
tr:not(:first)"&lt;/span&gt;).each(function() { 
&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;//get
the value of the table cell located&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;//in
the third column of the current row&lt;/span&gt;
&lt;br&gt;
var priceYesterday &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; $(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;).find(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"td:nth-child(2)"&lt;/span&gt;).html();&lt;br&gt;
var priceToday &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; $(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;).find(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"td:nth-child(3)"&lt;/span&gt;).html();&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;//check
if its greater than zero&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;if&lt;/span&gt; (priceToday
&amp;gt; priceYesterday){&lt;br&gt;
&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;//change
the color of the text to green if its a positive number&lt;/span&gt;
&lt;br&gt;
$(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;).find(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"td:nth-child(3)"&lt;/span&gt;).css(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"color"&lt;/span&gt;, &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"#00FF00"&lt;/span&gt;);&lt;br&gt;
}&lt;br&gt;
&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;else&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;if&lt;/span&gt;(priceToday
&amp;lt; priceYesterday){&lt;br&gt;
&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;//change
the color of the text to red if its a negatice number&lt;/span&gt;
&lt;br&gt;
$(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;).find(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"td:nth-child(3)"&lt;/span&gt;).css(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"color"&lt;/span&gt;, &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"#FF0000"&lt;/span&gt;);&lt;br&gt;
}&lt;br&gt;
});&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;//iterate
through all the rows in our table called yourtable&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;//excluding
the first row because those are column titles&lt;/span&gt;
&lt;br&gt;
$(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;".yourtableclassname
tr:not(:first)"&lt;/span&gt;).each(function() { 
&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;//get
the value of the table cell located&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;//in
the third column of the current row&lt;/span&gt;
&lt;br&gt;
var priceYesterday &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; $(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;).find(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"td:nth-child(2)"&lt;/span&gt;).html();&lt;br&gt;
var priceToday &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; $(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;).find(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"td:nth-child(3)"&lt;/span&gt;).html();&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;//check
if its greater than zero&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;if&lt;/span&gt; (priceToday
&amp;gt; priceYesterday){&lt;br&gt;
&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;//change
the color of the text to green if its a positive number&lt;/span&gt;
&lt;br&gt;
$(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;).find(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"td:nth-child(3)"&lt;/span&gt;).css(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"color"&lt;/span&gt;, &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"#00FF00"&lt;/span&gt;);&lt;br&gt;
}&lt;br&gt;
&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;else&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;if&lt;/span&gt;(priceToday
&amp;lt; priceYesterday){&lt;br&gt;
&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;//change
the color of the text to red if its a negatice number&lt;/span&gt;
&lt;br&gt;
$(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;).find(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"td:nth-child(3)"&lt;/span&gt;).css(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"color"&lt;/span&gt;, &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"#FF0000"&lt;/span&gt;);&lt;br&gt;
}&lt;br&gt;
});&lt;br&gt;
&lt;br&gt;
});&lt;br&gt;
&amp;lt;/script&amp;gt;&lt;br&gt;
&amp;lt;/head&amp;gt;&lt;br&gt;
&amp;lt;body&amp;gt;&lt;br&gt;
&amp;lt;h3&amp;gt;Iterating to the table via table id&amp;lt;/h3&amp;gt;&lt;br&gt;
&amp;lt;table id=&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"yourtablename"&lt;/span&gt;&amp;gt;&lt;br&gt;
&amp;lt;thead&amp;gt;&lt;br&gt;
&amp;lt;tr&amp;gt;&lt;br&gt;
&amp;lt;td&amp;gt;Product Name&amp;lt;/td&amp;gt;&lt;br&gt;
&amp;lt;td&amp;gt;Yesterday&amp;lt;/td&amp;gt;&lt;br&gt;
&amp;lt;td&amp;gt;Today&amp;lt;/td&amp;gt; 
&lt;br&gt;
&amp;lt;/tr&amp;gt;&lt;br&gt;
&amp;lt;/thead&amp;gt;&lt;br&gt;
&amp;lt;tbody&amp;gt;&lt;br&gt;
&amp;lt;tr&amp;gt;&lt;br&gt;
&amp;lt;td&amp;gt;Egg&amp;lt;/td&amp;gt;&lt;br&gt;
&amp;lt;td&amp;gt;1.95&amp;lt;/td&amp;gt;&lt;br&gt;
&amp;lt;td&amp;gt;2.10&amp;lt;/td&amp;gt;&lt;br&gt;
&amp;lt;/tr&amp;gt;&lt;br&gt;
&amp;lt;tr&amp;gt;&lt;br&gt;
&amp;lt;td&amp;gt;Sugar&amp;lt;/td&amp;gt;&lt;br&gt;
&amp;lt;td&amp;gt;1.92&amp;lt;/td&amp;gt;&lt;br&gt;
&amp;lt;td&amp;gt;1.88&amp;lt;/td&amp;gt;&lt;br&gt;
&amp;lt;/tr&amp;gt; 
&lt;br&gt;
&amp;lt;tr&amp;gt;&lt;br&gt;
&amp;lt;td&amp;gt;Milk&amp;lt;/td&amp;gt;&lt;br&gt;
&amp;lt;td&amp;gt;1.95&amp;lt;/td&amp;gt;&lt;br&gt;
&amp;lt;td&amp;gt;1.97&amp;lt;/td&amp;gt;&lt;br&gt;
&amp;lt;/tr&amp;gt;&lt;br&gt;
&amp;lt;tr&amp;gt;&lt;br&gt;
&amp;lt;td&amp;gt;beans&amp;lt;/td&amp;gt;&lt;br&gt;
&amp;lt;td&amp;gt;3.15&amp;lt;/td&amp;gt;&lt;br&gt;
&amp;lt;td&amp;gt;3.06&amp;lt;/td&amp;gt;&lt;br&gt;
&amp;lt;/tr&amp;gt; 
&lt;br&gt;
&amp;lt;/tbody&amp;gt;&lt;br&gt;
&amp;lt;/table&amp;gt;&lt;br&gt;
&lt;br&gt;
&amp;lt;h3&amp;gt;Iterating to the table via &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;class&lt;/span&gt; name&amp;lt;/h3&amp;gt;&lt;br&gt;
&amp;lt;table &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;class&lt;/span&gt;=&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"yourtableclassname"&lt;/span&gt;&amp;gt;&lt;br&gt;
&amp;lt;thead&amp;gt;&lt;br&gt;
&amp;lt;tr&amp;gt;&lt;br&gt;
&amp;lt;td&amp;gt;Product Name&amp;lt;/td&amp;gt;&lt;br&gt;
&amp;lt;td&amp;gt;Yesterday&amp;lt;/td&amp;gt;&lt;br&gt;
&amp;lt;td&amp;gt;Today&amp;lt;/td&amp;gt; 
&lt;br&gt;
&amp;lt;/tr&amp;gt;&lt;br&gt;
&amp;lt;/thead&amp;gt;&lt;br&gt;
&amp;lt;tbody&amp;gt;&lt;br&gt;
&amp;lt;tr&amp;gt;&lt;br&gt;
&amp;lt;td&amp;gt;Egg&amp;lt;/td&amp;gt;&lt;br&gt;
&amp;lt;td&amp;gt;1.95&amp;lt;/td&amp;gt;&lt;br&gt;
&amp;lt;td&amp;gt;2.10&amp;lt;/td&amp;gt;&lt;br&gt;
&amp;lt;/tr&amp;gt;&lt;br&gt;
&amp;lt;tr&amp;gt;&lt;br&gt;
&amp;lt;td&amp;gt;Sugar&amp;lt;/td&amp;gt;&lt;br&gt;
&amp;lt;td&amp;gt;1.92&amp;lt;/td&amp;gt;&lt;br&gt;
&amp;lt;td&amp;gt;1.88&amp;lt;/td&amp;gt;&lt;br&gt;
&amp;lt;/tr&amp;gt; 
&lt;br&gt;
&amp;lt;tr&amp;gt;&lt;br&gt;
&amp;lt;td&amp;gt;Milk&amp;lt;/td&amp;gt;&lt;br&gt;
&amp;lt;td&amp;gt;1.95&amp;lt;/td&amp;gt;&lt;br&gt;
&amp;lt;td&amp;gt;1.97&amp;lt;/td&amp;gt;&lt;br&gt;
&amp;lt;/tr&amp;gt;&lt;br&gt;
&amp;lt;tr&amp;gt;&lt;br&gt;
&amp;lt;td&amp;gt;beans&amp;lt;/td&amp;gt;&lt;br&gt;
&amp;lt;td&amp;gt;3.15&amp;lt;/td&amp;gt;&lt;br&gt;
&amp;lt;td&amp;gt;3.06&amp;lt;/td&amp;gt;&lt;br&gt;
&amp;lt;/tr&amp;gt; 
&lt;br&gt;
&amp;lt;/tbody&amp;gt;&lt;br&gt;
&amp;lt;/table&amp;gt;&lt;br&gt;
&amp;lt;/body&amp;gt;&lt;br&gt;
&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;/font&gt;&lt;/pre&gt;You can copy and paste the code above and put it on a new file to see
it running or you can view this sample running here: &lt;a href="http://www.keithrull.com/content/binary/jquery_change_table_cell_color_depending_on_value.html"&gt;jquery_change_table_cell_color_depending_on_value.html
(3.05 KB)&lt;/a&gt;
&lt;br&gt;
&lt;br&gt;
HTH&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.keithrull.com/aggbug.ashx?id=8672fb88-1b26-41f0-b107-973ad6b9b6e8" /&gt;</content>
  </entry>
  <entry>
    <title>How To: Calculate Mathematical Expressions in .NET</title>
    <link rel="alternate" type="text/html" href="http://www.keithrull.com/2010/05/18/HowToCalculateMathematicalExpressionsInNET.aspx" />
    <id>http://www.keithrull.com/PermaLink,guid,f9733a82-19bc-45dc-b4cd-659a40af0e66.aspx</id>
    <published>2010-05-18T18:41:31.4367505-05:00</published>
    <updated>2010-05-18T19:26:09.145249-05:00</updated>
    <category term=".NET" label=".NET" scheme="http://www.keithrull.com/CategoryView,category,NET.aspx" />
    <category term="Fun Stuff" label="Fun Stuff" scheme="http://www.keithrull.com/CategoryView,category,FunStuff.aspx" />
    <author>
      <name>Keith Rull</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">Everyday you learn something new. You do.
That is if you let yourself to be taught everyday.<br /><br />
I didn't know that you could solve this expression string in .NET in one line of code: <font color="#ff0000"><b>"4
+ 5 + 10 - 4 / 5 * 2"</b></font><br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">using</span> System; <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">using</span> System.Collections.Generic; <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">using</span> System.Linq; <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">using</span> System.Text; <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">using</span> System.Data; <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">namespace</span> KeithRull.SimpleExpressionCalculator
{ <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">class</span> Program
{ <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">static</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">void</span> Main(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">string</span>[]
args) { <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">string</span> expressionToEvaluate <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"4
+ 5 + 10 - 4 / 5 * 2"</span>; var result <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">new</span> DataTable().Compute(expressionToEvaluate, <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">null</span>);
Console.Write(result); Console.Read(); } } } </span></pre>The result is 17.4. Nifty
huh? You can also group the expressions to display a clearer evaluation instruction
and it still will work.<br /><font color="#0000ff" face="Times New Roman"><br /></font><font color="#0000ff" face="Times New Roman">string expressionToEvaluate =
"(((4 + 5) + (10 - 4)) / 5) * 2";</font><font color="#008000">//will result to 6</font><br /><br />
This is all cool but there's a gotcha. DataTable.Compute() method can only evaluate
simple expressions so your<br /><br /><font color="#0000ff" face="Times New Roman">string expressionToEvaluate = "Tan(10)
* 2";</font><font color="#ff0000">//error</font><br /><br />
Would throw an exception of type EvaluateException because it could not recognize
the function Tan().<br /><br />
One solution you could take to solve this problem is to use a dynamic language in
the DLR like IronRuby or IronPython.<br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">namespace</span> KeithRull.SimpleExpressionCalculator
{ <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">class</span> Program
{ <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">static</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">void</span> Main(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">string</span>[]
args) { <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">string</span> expressionToEvaluate <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"Tan(20)
* 2"</span>; var p <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">new</span> IronPython.Hosting.PythonEngine();
var result <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">=</span> p.EvaluateAs&lt;<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">double</span>&gt;(expressionToEvaluate);
Console.Write(result); Console.Read(); <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">//will
output: 4.47432188844948</span> } } } </span></pre>You can check out <b><a href="http://blogs.msdn.com/kirillosenkov/archive/2009/03/26/dlr-hosting-in-silverlight.aspx">Kirill
Osenkov's post</a></b> for more info regarding this approach.<br /><br />
Another way which i think is the better way is using a third-party library that already
support this like <b><a href="http://ncalc.codeplex.com/">NCalc</a></b>.<br /><br /><a href="http://ncalc.codeplex.com/">NCalc</a> is an open source Mathematical Expression
Evaluator for .NET that can parse any expression and evaluate the result, including
static or dynamic parameters and custom functions.<br /><br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">using</span> System; <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">using</span> System.Collections.Generic; <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">using</span> System.Linq; <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">using</span> System.Text; <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">using</span> System.Data; <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">using</span> NCalc; <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">namespace</span> KeithRull.SimpleExpressionCalculator
{ <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">class</span> Program
{ <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">static</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">void</span> Main(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">string</span>[]
args) { <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">string</span> expressionToEvaluate <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"Tan(20)
* 2"</span>; Expression e <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">new</span> Expression(expressionToEvaluate);
var result <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">=</span> e.Evaluate();
Console.Write(result); Console.Read(); <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">//will
output: 4.47432188844948</span> } } }</span></pre>Pretty cool huh?!<br /><br /><p></p><img width="0" height="0" src="http://www.keithrull.com/aggbug.ashx?id=f9733a82-19bc-45dc-b4cd-659a40af0e66" /></div>
    </content>
  </entry>
  <entry>
    <title>Just Released: Silverlight 4 Tools for VS 2010, new SL themes and WCF RIA Services</title>
    <link rel="alternate" type="text/html" href="http://www.keithrull.com/2010/05/18/JustReleasedSilverlight4ToolsForVS2010NewSLThemesAndWCFRIAServices.aspx" />
    <id>http://www.keithrull.com/PermaLink,guid,714eb96c-4d5e-4c4a-b7a1-87bf028a7429.aspx</id>
    <published>2010-05-18T02:07:19.952-05:00</published>
    <updated>2010-05-18T02:44:12.864031-05:00</updated>
    <category term=".NET" label=".NET" scheme="http://www.keithrull.com/CategoryView,category,NET.aspx" />
    <category term="Release" label="Release" scheme="http://www.keithrull.com/CategoryView,category,Release.aspx" />
    <category term="Silverlight" label="Silverlight" scheme="http://www.keithrull.com/CategoryView,category,Silverlight.aspx" />
    <category term="Tech News and Issues" label="Tech News and Issues" scheme="http://www.keithrull.com/CategoryView,category,TechNewsAndIssues.aspx" />
    <category term="WCF" label="WCF" scheme="http://www.keithrull.com/CategoryView,category,WCF.aspx" />
    <author>
      <name>Keith Rull</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
        </p>
Just in case you missed it, <b><a href="http://timheuer.com/">Tim Heuer</a></b> has <b><a href="http://timheuer.com/blog/archive/2010/05/17/silverlight-4-tools-released-and-new-application-templates.aspx">announced</a></b> that
Silverlight 4 Tools for Visual Studio 2010, WCF RIA Services and 3 new SL themes have
been released today. This is an exciting news for Silverlight aficionados who have
been waiting for the RTM version of SL4 Tools since the last RC who are itching to
put their hands on this new set of goodies.<br /><br />
If you want to learn more about SL, the best place to start is to go to Silverlight.net
and checkout the Getting Started section. I would also suggest you follow <b><a href="http://www.timheuer.com">Tim's
blog</a></b> and subscribe to his updates and also as follow <a href="http://www.silverlightcream.com/"><b>Silverlight
Cream</b></a> for the latest stream of info from SL developers. 
<br /><br />
If you are looking for Silverlight books for beginners my suggestion would be to get <a href="http://www.amazon.com/Silverlight-2-Unleashed-Laurent-Bugnion/dp/0672330148/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1274168205&amp;sr=8-1"><b>Laurent's
book</b></a> (a <a href="http://www.amazon.com/Silverlight-4-Unleashed-Laurent-Bugnion/dp/0672333368/ref=sr_1_3?ie=UTF8&amp;s=books&amp;qid=1274168205&amp;sr=8-3"><b>SL4
edition</b></a> will come out in September) and start from there. You should also
checkout <a href="http://www.amazon.com/Foundation-Silverlight-Animation-Jeff-Paries/dp/143022407X/ref=sr_1_10?ie=UTF8&amp;s=books&amp;qid=1274167864&amp;sr=8-10"><b>Jeff
Pairies</b></a> mind boggling book about <a href="http://www.amazon.com/Foundation-Silverlight-Animation-Jeff-Paries/dp/143022407X/ref=sr_1_10?ie=UTF8&amp;s=books&amp;qid=1274167864&amp;sr=8-10"><b>Silverlight
animation</b></a> and also <a href="http://www.amazon.com/Data-Driven-Services-Silverlight-John-Papa/dp/0596523092/ref=sr_1_19?ie=UTF8&amp;s=books&amp;qid=1274167951&amp;sr=8-19"><b>John
Papa's</b></a> classic SL book that talks about data-driven services with Silverlight.
Although some of these books are 1-2 versions behind I still believe that there are
a lot of value in them that you can still apply with your Silverlight 4 projects.<br /><br /><img src="http://www.keithrull.com/content/binary/silverlight4toolsvs2010.png" border="0" /><br /><br />
I've just downloaded the package via the <a href="http://www.microsoft.com/web/gallery/install.aspx?appid=silverlight4tools;silverlight4toolkit;riaservicestoolkit"><b>WPI</b></a> and
I can't tell you how much excited I am to see SL4T-4-VS2010 RTMed. This will surely
be a fun week.<br /><br /><br /><img src="http://www.keithrull.com/content/binary/sl4toolsinstalled.png" border="0" /><br /><br />
Nice, time to rock this ship!<br /><img width="0" height="0" src="http://www.keithrull.com/aggbug.ashx?id=714eb96c-4d5e-4c4a-b7a1-87bf028a7429" /></div>
    </content>
  </entry>
  <entry>
    <title>How To: Change the row and column colors of a table using jQuery</title>
    <link rel="alternate" type="text/html" href="http://www.keithrull.com/2010/05/06/HowToChangeTheRowAndColumnColorsOfATableUsingJQuery.aspx" />
    <id>http://www.keithrull.com/PermaLink,guid,7b24f16a-7001-4434-a330-17245c7e15af.aspx</id>
    <published>2010-05-05T19:23:11.767-05:00</published>
    <updated>2010-05-05T19:47:50.8438415-05:00</updated>
    <category term="jQuery" label="jQuery" scheme="http://www.keithrull.com/CategoryView,category,jQuery.aspx" />
    <author>
      <name>Keith Rull</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
        </p>
Here's a quick and easy way to alternate the row colors of a table using jQuery<br /><br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;">&lt;script&gt;<br />
$(document).ready(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">function</span>()<br />
{<br /><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">//set
the color of the row based on rowindex</span> $(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">".report-table-horizontal
tr:even"</span>).css(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"background-color"</span>, <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"#FFF8DC"</span>);<br />
$(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">".report-table-horizontal
tr:odd"</span>).css(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"background-color"</span>, <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"#FFFBD0"</span>);<br /><br /><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">//highlight
the table titles by selecting the first row</span> $(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">".report-table-horizontal
tr:first"</span>).css(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"background-color"</span>, <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"#FFCC33"</span>);<br /><br />
});<br />
&lt;/script&gt;</span></pre>The resulting code will apply the to the table and would
look like this:<br /><br /><img src="http://www.keithrull.com/content/binary/changingtablerowcolorsinjquery.JPG" border="0" /><br /><br />
Basically what the code is doing is that it is selecting a css class called "report-table-horizontal"
and applies the style to the tr attribute of the table based on their row index whether
they are even or odd.<br /><br />
Now if you want to change the color of a  table column you can do so using this
script:<br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;">&lt;script&gt;
$(document).ready(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">function</span>()
{ <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">//set
the color of the row based on rowindex</span> $(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">".report-table-vertical
tr:even"</span>).css(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"background-color"</span>, <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"#FFF8DC"</span>);
$(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">".report-table-vertical
tr:odd"</span>).css(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"background-color"</span>, <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"#FFFBD0"</span>); <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">//set
the color of the first column</span> $(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">".report-table-vertical
td:first-child"</span>).css(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"background-color"</span>, <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"#FFCC33"</span>);
}); &lt;/script&gt;</span></pre><br /><img src="http://www.keithrull.com/content/binary/changingtablecolumncolorsinjquery.JPG" border="0" /><br /><br />
The difference on this code is the third line wherein we specified that the style
will be applied on the first td element of the table. Alternately you can use the
nth-child(n) selector instead to do the same task:<br /><br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;">$(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">".report-table-vertical
td:nth-child(1)"</span>).css(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"background-color"</span>, <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"#FFCC33"</span>);</span></pre><br />
Hope this helps. You can view the live sample here: 
<br /><a href="http://www.keithrull.com/content/binary/alternating%20table%20colors%20with%20jquery.html">alternating
table colors with jquery.html (2.42 KB)</a><br /><br />
or just copy and paste the HTML code below to a new file:<br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;">&lt;html&gt;
&lt;head&gt; &lt;title&gt;Working <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">with</span> tables <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">in</span> jQuery&lt;/title&gt;
&lt;script src=<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"</span> type=<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"text/javascript"</span>&gt;&lt;/script&gt;
&lt;script&gt; $(document).ready(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">function</span>()
{ <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">//set
the color of the row based on rowindex</span> $(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">".report-table-horizontal
tr:even"</span>).css(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"background-color"</span>, <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"#FFF8DC"</span>);
$(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">".report-table-horizontal
tr:odd"</span>).css(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"background-color"</span>, <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"#FFFBD0"</span>); <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">//highlight
the table titles by selecting the first row</span> $(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">".report-table-horizontal
tr:first"</span>).css(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"background-color"</span>, <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"#FFCC33"</span>); <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">//set
the color of the row based on rowindex</span> $(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">".report-table-vertical
tr:even"</span>).css(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"background-color"</span>, <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"#FFF8DC"</span>);
$(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">".report-table-vertical
tr:odd"</span>).css(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"background-color"</span>, <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"#FFFBD0"</span>); <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">//set
the color of the first column</span> $(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">".report-table-vertical
td:nth-child(1)"</span>).css(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"background-color"</span>, <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"#FFCC33"</span>);
}); &lt;/script&gt; &lt;style type=<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"text/css"</span>&gt;
body { font-family: Arial; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;h2&gt;Alternating
row colors <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">in</span> a
table <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">with</span> jquery&lt;/h2&gt;
&lt;table class=<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"report-table-horizontal"</span>&gt;
&lt;tr&gt; &lt;td width=<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"100px"</span>&gt;Firstname&lt;/td&gt;
&lt;td width=<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"100px"</span>&gt;Lastname&lt;/td&gt;
&lt;td&gt;Email&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Keith&lt;/td&gt; &lt;td&gt;Rull&lt;/td&gt;
&lt;td&gt;keith@example.com&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Charissa&lt;/td&gt;
&lt;td&gt;Rull&lt;/td&gt; &lt;td&gt;charissa@example.com&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;
&lt;td&gt;Zoe Adrielle&lt;/td&gt; &lt;td&gt;Rull&lt;/td&gt; &lt;td&gt;zoe@example.com&lt;/td&gt;
&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;John&lt;/td&gt; &lt;td&gt;Doe&lt;/td&gt; &lt;td&gt;jdoe@example.com&lt;/td&gt;
&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Jane&lt;/td&gt; &lt;td&gt;Doe&lt;/td&gt; &lt;td&gt;janedoe@example.com&lt;/td&gt;
&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Tony&lt;/td&gt; &lt;td&gt;Brown&lt;/td&gt; &lt;td&gt;brown@example.com&lt;/td&gt;
&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Lisa&lt;/td&gt; &lt;td&gt;Sally&lt;/td&gt; &lt;td&gt;sally@example.com&lt;/td&gt;
&lt;/tr&gt; &lt;/table&gt; &lt;br /&gt; &lt;h2&gt;Change the color of the the first
column <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">with</span> jquery&lt;/h2&gt;
&lt;table class=<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"report-table-vertical"</span>&gt;
&lt;tr&gt; &lt;td width=<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"100px"</span>&gt;Product&lt;/td&gt;
&lt;td&gt;Price&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Eggs&lt;/td&gt; &lt;td&gt;$1.10&lt;/td&gt;
&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Flour&lt;/td&gt; &lt;td&gt;$1.20&lt;/td&gt; &lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;Carrots&lt;/td&gt; &lt;td&gt;$0.35&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;
&lt;td&gt;Cucumber&lt;/td&gt; &lt;td&gt;$0.50&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Melon&lt;/td&gt;
&lt;td&gt;$0.99&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/body&gt; &lt;html&gt;</span></pre><br /><img width="0" height="0" src="http://www.keithrull.com/aggbug.ashx?id=7b24f16a-7001-4434-a330-17245c7e15af" /></div>
    </content>
  </entry>
  <entry>
    <title>How To: Encrypt the ViewState in ASP.NET</title>
    <link rel="alternate" type="text/html" href="http://www.keithrull.com/2010/05/04/HowToEncryptTheViewStateInASPNET.aspx" />
    <id>http://www.keithrull.com/PermaLink,guid,16419014-c9c6-4f89-8bd4-8d63efd8617b.aspx</id>
    <published>2010-05-04T16:40:43.4107565-05:00</published>
    <updated>2010-05-04T16:42:00.301343-05:00</updated>
    <category term=".NET" label=".NET" scheme="http://www.keithrull.com/CategoryView,category,NET.aspx" />
    <category term="ASP.NET" label="ASP.NET" scheme="http://www.keithrull.com/CategoryView,category,ASPNET.aspx" />
    <category term="Tutorial" label="Tutorial" scheme="http://www.keithrull.com/CategoryView,category,Tutorial.aspx" />
    <author>
      <name>Keith Rull</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Sometimes its the basic things that we tend to forget. It's true. One example is encrypting
the ViewState. Someone asked me this question today and I had to admit that I wasn't
able to answer on top of my head. Whats funny is that I've been doing it all along
but never told myself to remember how.
</p>
        <p>
Anyhow, lets go back to the topic on how to encrypt the ViewState in ASP.NET.
</p>
        <p>
Prior to .NET 2.0 the way you would do this is via the <a href="http://msdn.microsoft.com/en-us/library/w8h3skw9.aspx">machineKey</a> element
validation attribute. In .NET 2.0 onwards Microsoft provided us with an option to
specify ViewState encryption in the page level or web.config level via the ViewStateEncryptionMode
attribute.
</p>
        <p>
          <span style="color: rgb(0, 0, 255);">ViewStateEncryptionMode</span> has three enumeration
values that you could use defending on what you need. They are <span style="color: rgb(0, 0, 255);"><b><i>Auto,
Never and Always</i></b></span>. ViewStateEncryptionMode.Auto means that the page
will be encrypted if a control request for encryption. By default the value for ViewStateEncryptionMode
is set to Auto. ViewStateEncryptionMode.Never means that ASP.NET will not encrypt
the ViewState on your page even if a control request for it. This is a good bypassing
mechanism if and only if you know that the page does not need to have ViewState encryption
on it. ViewStateEncryptionMode.Always on the otherhand will encrypt your page all
the time. A good practice for pages with sensitive information is to always set this
ViewStateEncryptionMode to Always as you don't want anybody compromising your ViewState.
</p>
        <p>
To enable ViewState encryption in the page all you need to do is specify the value
for ViewStateEncryptionMode at the Page directive
</p>
        <p>
          <span style="color: rgb(255, 0, 0);">&lt;%@Page ViewStateEncryptionMode="Always" %&gt;</span>
        </p>
        <p>
To enable ViewState encryption via web.config to apply to the whole application
</p>
        <p>
          <span style="color: rgb(255, 0, 0);">&lt;configuration&gt;<br />
   &lt;system.web&gt;<br />
      &lt;pages ViewStateEncryptionMode="Always" /&gt;<br />
   &lt;/system.web&gt;<br />
&lt;/configuration&gt;</span>
        </p>
        <p>
One thing to remember though is that you can't set <span style="color: rgb(0, 0, 255);">ViewStateEncryptionMode</span> via
code
</p>
        <p>
To request for ViewState encryption inside a control all you need to do is call <span style="color: rgb(0, 0, 255);">RegisterViewStateEcryption()</span> method
from the <span style="color: rgb(0, 0, 255);">Page</span> class
</p>
        <p>
          <span style="color: rgb(0, 0, 255);">protected override void OnInit(EventArgs e) 
<br />
{<br />
    base.OnInit(e);<br />
    if(Page != null) 
<br />
    {<br />
        Page.RegisterRequiresViewStateEncryption();<br />
    }<br />
}</span>
        </p>
        <p>
          <b>
            <i>Ahhh, such reverie. Now I need to remember this for future use (or questions).
Cheers!</i>
          </b>
        </p>
        <img width="0" height="0" src="http://www.keithrull.com/aggbug.ashx?id=16419014-c9c6-4f89-8bd4-8d63efd8617b" />
      </div>
    </content>
  </entry>
  <entry>
    <title>VS2010 Keyboard shortcuts released</title>
    <link rel="alternate" type="text/html" href="http://www.keithrull.com/2010/04/12/VS2010KeyboardShortcutsReleased.aspx" />
    <id>http://www.keithrull.com/PermaLink,guid,bfa36369-e8d4-426c-8795-10422db47223.aspx</id>
    <published>2010-04-12T17:03:17.524-05:00</published>
    <updated>2010-05-04T17:09:05.8662455-05:00</updated>
    <category term=".NET" label=".NET" scheme="http://www.keithrull.com/CategoryView,category,NET.aspx" />
    <category term="Tools of the Trade" label="Tools of the Trade" scheme="http://www.keithrull.com/CategoryView,category,ToolsOfTheTrade.aspx" />
    <author>
      <name>Keith Rull</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <br />
        <p>
        </p>
        <img src="http://www.keithrull.com/content/binary/vs2010shortcuts.JPG" border="0" />
        <br />
        <br />
Just in case you need to freshen up on the keyboard shortcuts for VS 2010 you can
get them <b><a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;FamilyID=92ced922-d505-457a-8c9c-84036160639f#filelist">here</a></b>.<br /><img width="0" height="0" src="http://www.keithrull.com/aggbug.ashx?id=bfa36369-e8d4-426c-8795-10422db47223" /></div>
    </content>
  </entry>
  <entry>
    <title>ASP.NET MVC 2 is out!!</title>
    <link rel="alternate" type="text/html" href="http://www.keithrull.com/2010/03/12/ASPNETMVC2IsOut.aspx" />
    <id>http://www.keithrull.com/PermaLink,guid,bce8f4f2-ddb6-4f06-accc-7aba0ed79290.aspx</id>
    <published>2010-03-11T20:51:04.744-06:00</published>
    <updated>2010-05-02T20:58:06.7966775-05:00</updated>
    <category term="ASP.NET" label="ASP.NET" scheme="http://www.keithrull.com/CategoryView,category,ASPNET.aspx" />
    <category term="MVC" label="MVC" scheme="http://www.keithrull.com/CategoryView,category,MVC.aspx" />
    <author>
      <name>Keith Rull</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
In case you missed the <a href="http://twitter.com/shanselman/status/10358856689">announcement</a>,
ASP.NET MVC 2 is out and ready for the picking. Go get it <a href="http://go.microsoft.com/fwlink/?LinkID=185037">here</a>.
</p>
        <p>
          <a href="http://devpinoy.org/resized-image.ashx/__size/550x0/__key/CommunityServer.Blogs.Components.WeblogFiles/keithrull/asp.netmvc2isout.png">
            <img src="http://devpinoy.org/resized-image.ashx/__size/550x0/__key/CommunityServer.Blogs.Components.WeblogFiles/keithrull/asp.netmvc2isout.png" border="0" />
          </a>
        </p>
        <img width="0" height="0" src="http://www.keithrull.com/aggbug.ashx?id=bce8f4f2-ddb6-4f06-accc-7aba0ed79290" />
      </div>
    </content>
  </entry>
  <entry>
    <title>How To: Working with Enums in C#</title>
    <link rel="alternate" type="text/html" href="http://www.keithrull.com/2010/01/09/HowToWorkingWithEnumsInC.aspx" />
    <id>http://www.keithrull.com/PermaLink,guid,cdf94e4a-1814-4f92-b925-b0967dcc4aea.aspx</id>
    <published>2010-01-08T20:40:44.337-06:00</published>
    <updated>2010-05-02T20:42:59.095985-05:00</updated>
    <category term=".NET" label=".NET" scheme="http://www.keithrull.com/CategoryView,category,NET.aspx" />
    <author>
      <name>Keith Rull</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Enums are special value types that lets you specify a group of numeric constants.
For example:
</p>
        <p>
          <span style="color: #0000ff;">enum Languages<br />
{<br />
English,<br />
Spanish,<br />
Chinese,<br />
Japanese,<br />
French,<br />
Filipino<br />
}</span>
        </p>
        <p>
We can use an anum as follows:
</p>
        <p>
          <span style="color: #0000ff;">Languages ls = Languages.Filipino<br />
bool canSpeakFilipino (ls == Languages.Filipino)</span>
          <span style="color: #008000;">//return
true</span>
        </p>
        <p>
By default enums have an underlying ingtegral value which is of type int and the constant
values start from 0 to infinity based on how they enum members are declared. You can
also specify an alternate integral type as follows
</p>
        <p>
          <span style="color: #0000ff;">enum Languages: byte 
<br />
{ 
<br />
English,<br />
Spanish,<br />
Chinese,<br />
Japanese,<br />
French,<br />
Filipino<br />
}</span>
        </p>
        <p>
Or do an explicit value for each enum member
</p>
        <p>
          <span style="color: #0000ff;">enum Languages: byte 
<br />
{ 
<br />
English = 1,<br />
Spanish = 2,<br />
Chinese = 4,<br />
Japanese = 8,<br />
French = 16,<br />
Filipino = 32<br />
}</span>
        </p>
        <p>
          <br />
You can also assign some values of the enum and let the compiler decide on the value
of the other unassigned enum members which is an increment of 1 by the previous value
of the previous member.
</p>
        <p>
          <span style="color: #0000ff;">enum Languages 
<br />
{ 
<br />
English = 1,<br />
Spanish,<br />
Chinese,<br />
Japanese = 8,<br />
French,<br />
Filipino<br />
}</span>
        </p>
        <p>
The code above will result to English = 1, Spanish = 2, Chinese = 3, Japanese = 8,
French = 9, Filipino = 10
</p>
        <p>
It is a good practice to define a value for 0 in enums to signify "no value" as 0
in enums mean the absence of all properties possible. Defining a value for 0 with
make it a valid state for your enum.
</p>
        <p>
          <span style="color: #0000ff;">enum Languages: byte 
<br />
{<br /><strong>None = 0</strong>, 
<br />
English = 1,<br />
Spanish = 2,<br />
Chinese = 4,<br />
Japanese = 8,<br />
French = 16,<br />
Filipino = 32<br />
}</span>
        </p>
        <p>
This is specifically useful when you are using flags attribute on your enum as this
will catch values presented as 0
</p>
        <p>
          <span style="color: #0000ff;">
            <strong>[Flags]<br /></strong>enum Languages: byte 
<br />
{<br />
None = 0, 
<br />
English = 1,<br />
Spanish = 2,<br />
Chinese = 4,<br />
Japanese = 8,<br />
French = 16,<br />
Filipino = 32<br />
}</span>
        </p>
        <p>
          <span style="color: #0000ff;">Language ls;</span>
          <span style="color: #008000;">//will
default to 0<br /></span>
          <span style="color: #0000ff;">Console.WriteLine(ls);</span>
          <span style="color: #008000;"> //will
print None on the console</span>
        </p>
        <p>
Adding the [Flags] attribute to your enums will help you "combine values" of enums
into one.
</p>
        <p>
          <span style="color: #0000ff;">Language ls = Language.English | Language.Filipino |
Language.French;<br />
Console.WriteLine("I can speak {0}", ls);</span>
          <br />
          <span style="color: #008000;">//The code above will print: I can speak English, Filipino,
French</span>
        </p>
        <img width="0" height="0" src="http://www.keithrull.com/aggbug.ashx?id=cdf94e4a-1814-4f92-b925-b0967dcc4aea" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Free Laptop Bag? LOL</title>
    <link rel="alternate" type="text/html" href="http://www.keithrull.com/2009/12/03/FreeLaptopBagLOL.aspx" />
    <id>http://www.keithrull.com/PermaLink,guid,214df45a-cac2-4d6c-a490-cccc3c2ffcd9.aspx</id>
    <published>2009-12-03T17:51:10.8587575-06:00</published>
    <updated>2009-12-03T17:53:51.722485-06:00</updated>
    <category term="Fun Stuff" label="Fun Stuff" scheme="http://www.keithrull.com/CategoryView,category,FunStuff.aspx" />
    <author>
      <name>Keith Rull</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">I just saw this posting from sandiego.craigslist.com
and it really made me laugh. LOL.<br /><br /><a href="http://sandiego.craigslist.org/csd/sys/1493519713.html"><i>http://sandiego.craigslist.org/csd/sys/1493519713.html</i></a><br /><br /><img src="http://www.keithrull.com/content/binary/freelaptopbag.GIF" border="0" /><br /><br />
Heheh. Funny.<br /><img width="0" height="0" src="http://www.keithrull.com/aggbug.ashx?id=214df45a-cac2-4d6c-a490-cccc3c2ffcd9" /></div>
    </content>
  </entry>
</feed>