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

<channel>
	<title>toddVance.Com</title>
	<atom:link href="http://toddvance.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://toddvance.com</link>
	<description>programming notes...</description>
	<lastBuildDate>Fri, 03 Sep 2010 18:00:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Add and Remove ROWS in table using JQuery</title>
		<link>http://toddvance.com/?p=570</link>
		<comments>http://toddvance.com/?p=570#comments</comments>
		<pubDate>Fri, 03 Sep 2010 18:00:09 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[JQuery/JScript]]></category>

		<guid isPermaLink="false">http://toddvance.com/?p=570</guid>
		<description><![CDATA[Sounds hard, but very simple.
Say I have a table on a page and a button to add rows to that table.  On that button, I have added an ONCLICK to go to the function below. 
Below, I gave my table a CLASS name because .Net screws up the ID &#8212; and I am able [...]]]></description>
			<content:encoded><![CDATA[<p>Sounds hard, but very simple.</p>
<p>Say I have a table on a page and a button to add rows to that table.  On that button, I have added an ONCLICK to go to the function below. </p>
<p>Below, I gave my table a CLASS name because .Net screws up the ID &#8212; and I am able to call that when the button is clicked.<br />
Here the .append function adds after the last element &#8212; THIS COULD BE  PROBLEM FOR YOU if you have a TBODY.  There are workarounds but I am not going to discuss those at this time.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> AddCustomSetting<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.cusSettingsTable'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&lt;tr&gt;&lt;td onclick='RemoveRow(this);'&gt;Remove&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;input type='textbox' /&gt;&lt;/td&gt;&lt;td&gt;Test Me&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>That is all it would take to add a new Row to a table&#8230; now what if we want to remove it?  Well notice in that append statement that I added another onclick function to remove the row and sent the TD (via this) element with the call.   Here is that function:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> RemoveRow<span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>And that is it!  JQuery strikes again!<br />
ciao!<br />
t</p>
]]></content:encoded>
			<wfw:commentRss>http://toddvance.com/?feed=rss2&amp;p=570</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create Custom Object In Javascript!  very cool.</title>
		<link>http://toddvance.com/?p=558</link>
		<comments>http://toddvance.com/?p=558#comments</comments>
		<pubDate>Wed, 25 Aug 2010 14:23:04 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[JQuery/JScript]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://toddvance.com/?p=558</guid>
		<description><![CDATA[You can define your own objects in Javascript that will hold properties and perform calculations.
Additionally, as if that is not cool enough (dang I love Javascript), you can also define methods/functions that are attached to those objects (see below).
AND additionally, as if THAT is still not cool enough, if you are using Visual Studio 2010 [...]]]></description>
			<content:encoded><![CDATA[<p>You can define your own objects in Javascript that will hold properties and perform calculations.</p>
<p>Additionally, as if that is not cool enough (dang I love Javascript), you can also define methods/functions that are attached to those objects (see below).</p>
<p>AND additionally, as if THAT is still not cool enough, if you are using Visual Studio 2010 (not sure about 2008) &#8211; you will get &#8216; intellisense&#8217; for these new Javascript objects (he laughs uncontrollably from pure geek joy!)!!!</p>
<div id="attachment_560" class="wp-caption alignright" style="width: 378px"><a href="http://toddvance.com/wp-content/uploads/2010/08/javasriptIntellisense.png"><img class="size-full wp-image-560" title="javasriptIntellisense" src="http://toddvance.com/wp-content/uploads/2010/08/javasriptIntellisense.png" alt="Javascript custom Intellisense" width="368" height="233" /></a><p class="wp-caption-text">Notice ID and Name are properties and MultiplyBy1000 is my custom made method for this object.</p></div>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">  <span style="color: #006600; font-style: italic;">//Create an array to hold your objects</span>
  <span style="color: #003366; font-weight: bold;">var</span> jsObjectList <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
  <span style="color: #006600; font-style: italic;">//You can define objects in Javascript like you would any JS function</span>
  <span style="color: #003366; font-weight: bold;">function</span> myJSObject<span style="color: #009900;">&#40;</span>num1<span style="color: #339933;">,</span> num2<span style="color: #339933;">,</span> myName<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">num1</span> <span style="color: #339933;">=</span> num1<span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">num2</span> <span style="color: #339933;">=</span> num2<span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">myName</span> <span style="color: #339933;">=</span> myName<span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">combinedNums</span> <span style="color: #339933;">=</span> num1 <span style="color: #339933;">*</span> num2<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #006600; font-style: italic;">//You can create methods and functions (that return values) for these objects by using the PROTOTYPE keyword.</span>
   myJSObject.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">MultiplyNumberBy1000</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>numberToMultiplyBy1000<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">alert</span> <span style="color: #009900;">&#40;</span>numberToMultiplyBy1000 <span style="color: #339933;">*</span> <span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span> 
&nbsp;
  <span style="color: #006600; font-style: italic;">//Make one of your spiffy new objects and then add it to your array!</span>
  <span style="color: #003366; font-weight: bold;">function</span> createOneOfMySpiffyNewObjectsAndAddItToMyArray<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">//Instantiating new obj</span>
	<span style="color: #003366; font-weight: bold;">var</span> newObject <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> myJSObject<span style="color: #009900;">&#40;</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">12</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Todds'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">//Adding it to array</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>jsObjectList.<span style="color: #660066;">length</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span>
                 jsObjectList<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> newObject<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">else</span>
                 jsObjectList<span style="color: #009900;">&#91;</span>jsObjectList.<span style="color: #660066;">length</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> newObject<span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #006600; font-style: italic;">//Now you can iterate through your array and grab values from your list of objects like this!</span>
  <span style="color: #003366; font-weight: bold;">function</span> iterateMyObjectArray<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> jsObjectList.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
            <span style="color: #003366; font-weight: bold;">var</span> currentNewObject <span style="color: #339933;">=</span> jsObjectList<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #006600; font-style: italic;">//Now pull info from that object like this...</span>
	    <span style="color: #003366; font-weight: bold;">var</span> a <span style="color: #339933;">=</span> currentNewObject.<span style="color: #660066;">num1</span><span style="color: #339933;">;</span>
	    <span style="color: #003366; font-weight: bold;">var</span> b <span style="color: #339933;">=</span> currentNewObject.<span style="color: #660066;">myName</span> <span style="color: #006600; font-style: italic;">// etc, etc.</span>
&nbsp;
	    <span style="color: #006600; font-style: italic;">//And call methods like this</span>
	    currentNewObject.<span style="color: #660066;">MultiplyBy1000</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
       <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://toddvance.com/?feed=rss2&amp;p=558</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Panda Game&#8230;</title>
		<link>http://toddvance.com/?p=555</link>
		<comments>http://toddvance.com/?p=555#comments</comments>
		<pubDate>Wed, 18 Aug 2010 19:14:22 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[XNA/Game programming]]></category>

		<guid isPermaLink="false">http://toddvance.com/?p=555</guid>
		<description><![CDATA[Full Javascript Panda game I created (i cant for the life of me remember why I chose a PANDA &#8212; but whatever) &#8230; http://toddvance.com/games/panda/
Check it out, it also includes a php login and high score feature.
Cool.
]]></description>
			<content:encoded><![CDATA[<p>Full Javascript Panda game I created (i cant for the life of me remember why I chose a PANDA &#8212; but whatever) &#8230; http://toddvance.com/games/panda/</p>
<p>Check it out, it also includes a php login and high score feature.</p>
<p>Cool.</p>
]]></content:encoded>
			<wfw:commentRss>http://toddvance.com/?feed=rss2&amp;p=555</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add JQuery, Javascript, CSS to ASPx User Controls parent</title>
		<link>http://toddvance.com/?p=551</link>
		<comments>http://toddvance.com/?p=551#comments</comments>
		<pubDate>Tue, 22 Jun 2010 14:50:25 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[JQuery/JScript]]></category>

		<guid isPermaLink="false">http://toddvance.com/?p=551</guid>
		<description><![CDATA[This is my preferred method.  (Microsoft has controls such as ScriptManager and ScriptManagerProxy but like nearly everything they do, I believe its overkill)  To me, this is the simplest method.
The Problem:  You want to convert or to create a user control that has scripts and/or css.
Solution:  Within the Page_Load event of [...]]]></description>
			<content:encoded><![CDATA[<p>This is my preferred method.  (Microsoft has controls such as ScriptManager and ScriptManagerProxy but like nearly everything they do, I believe its overkill)  To me, this is the simplest method.</p>
<p>The Problem:  You want to convert or to create a user control that has scripts and/or css.</p>
<p>Solution:  Within the Page_Load event of the user control, simply include the following:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">    <span style="color: #008080; font-style: italic;">//For Scripts - notice we add this script call to the PARENT HEADER</span>
    LiteralControl jQuery <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> LiteralControl<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    jQuery.<span style="color: #0000FF;">Text</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;&lt;script type=<span style="color: #008080; font-weight: bold;">\&quot;</span>text/javascript<span style="color: #008080; font-weight: bold;">\&quot;</span> src=<span style="color: #008080; font-weight: bold;">\&quot;</span>js/jquery.js<span style="color: #008080; font-weight: bold;">\&quot;</span>&gt;&lt;/script&gt;&quot;</span><span style="color: #008000;">;</span>
    Page.<span style="color: #0000FF;">Header</span>.<span style="color: #0000FF;">Controls</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>jQuery<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">//For CSS - You could add Media under attributes as well.  </span>
    HtmlLink stylesLink <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> HtmlLink<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    stylesLink.<span style="color: #0000FF;">Attributes</span><span style="color: #000000;">&#91;</span><span style="color: #666666;">&quot;rel&quot;</span><span style="color: #000000;">&#93;</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;stylesheet&quot;</span><span style="color: #008000;">;</span>
    stylesLink.<span style="color: #0000FF;">Attributes</span><span style="color: #000000;">&#91;</span><span style="color: #666666;">&quot;type&quot;</span><span style="color: #000000;">&#93;</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;text/css&quot;</span><span style="color: #008000;">;</span>
    stylesLink.<span style="color: #0000FF;">Href</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;css/yourPagesCSS.css&quot;</span><span style="color: #008000;">;</span>
    Page.<span style="color: #0000FF;">Header</span>.<span style="color: #0000FF;">Controls</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>stylesLink<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

<p>Hope this helps someone! t</p>
]]></content:encoded>
			<wfw:commentRss>http://toddvance.com/?feed=rss2&amp;p=551</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get parent div ID with JQuery</title>
		<link>http://toddvance.com/?p=549</link>
		<comments>http://toddvance.com/?p=549#comments</comments>
		<pubDate>Thu, 17 Jun 2010 17:38:47 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[JQuery/JScript]]></category>

		<guid isPermaLink="false">http://toddvance.com/?p=549</guid>
		<description><![CDATA[$(this).parent().attr(&#8220;id&#8221;);
]]></description>
			<content:encoded><![CDATA[<p>$(this).parent().attr(&#8220;id&#8221;);</p>
]]></content:encoded>
			<wfw:commentRss>http://toddvance.com/?feed=rss2&amp;p=549</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL IF ELSE structure.</title>
		<link>http://toddvance.com/?p=544</link>
		<comments>http://toddvance.com/?p=544#comments</comments>
		<pubDate>Mon, 14 Jun 2010 16:24:34 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[ADO / SQL]]></category>

		<guid isPermaLink="false">http://toddvance.com/?p=544</guid>
		<description><![CDATA[
IF 
&#40;SELECT COUNT&#40;*&#41; FROM Production.Product WHERE Name LIKE 'Touring-3000%' &#41; &#38;gt; 5
BEGIN
   SET @BikeCount = 
        &#40;SELECT COUNT&#40;*&#41; 
         FROM Production.Product 
         WHERE Name LIKE 'Touring-3000%'&#41;;
   SET @AvgWeight = 
        &#40;SELECT AVG&#40;Weight&#41; 
         FROM Production.Product 
         WHERE Name LIKE 'Touring-3000%'&#41;;
   PRINT 'There are ' + CAST&#40;@BikeCount AS varchar&#40;3&#41;&#41; + ' Touring-3000 bikes.'
   PRINT 'The average weight of the top 5 Touring-3000 bikes is ' + CAST&#40;@AvgWeight [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">IF</span> 
<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> COUNT<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">FROM</span> Production<span style="color: #66cc66;">.</span>Product <span style="color: #993333; font-weight: bold;">WHERE</span> Name <span style="color: #993333; font-weight: bold;">LIKE</span> <span style="color: #ff0000;">'Touring-3000%'</span> <span style="color: #66cc66;">&#41;</span> &amp;gt; <span style="color: #cc66cc;">5</span>
BEGIN
   <span style="color: #993333; font-weight: bold;">SET</span> @BikeCount <span style="color: #66cc66;">=</span> 
        <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> COUNT<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#41;</span> 
         <span style="color: #993333; font-weight: bold;">FROM</span> Production<span style="color: #66cc66;">.</span>Product 
         <span style="color: #993333; font-weight: bold;">WHERE</span> Name <span style="color: #993333; font-weight: bold;">LIKE</span> <span style="color: #ff0000;">'Touring-3000%'</span><span style="color: #66cc66;">&#41;</span>;
   <span style="color: #993333; font-weight: bold;">SET</span> @AvgWeight <span style="color: #66cc66;">=</span> 
        <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> AVG<span style="color: #66cc66;">&#40;</span>Weight<span style="color: #66cc66;">&#41;</span> 
         <span style="color: #993333; font-weight: bold;">FROM</span> Production<span style="color: #66cc66;">.</span>Product 
         <span style="color: #993333; font-weight: bold;">WHERE</span> Name <span style="color: #993333; font-weight: bold;">LIKE</span> <span style="color: #ff0000;">'Touring-3000%'</span><span style="color: #66cc66;">&#41;</span>;
   PRINT <span style="color: #ff0000;">'There are '</span> <span style="color: #66cc66;">+</span> CAST<span style="color: #66cc66;">&#40;</span>@BikeCount <span style="color: #993333; font-weight: bold;">AS</span> varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">' Touring-3000 bikes.'</span>
   PRINT <span style="color: #ff0000;">'The average weight of the top 5 Touring-3000 bikes is '</span> <span style="color: #66cc66;">+</span> CAST<span style="color: #66cc66;">&#40;</span>@AvgWeight <span style="color: #993333; font-weight: bold;">AS</span> varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">8</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">'.'</span>;
END
ELSE 
BEGIN
<span style="color: #993333; font-weight: bold;">SET</span> @AvgWeight <span style="color: #66cc66;">=</span> 
        <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> AVG<span style="color: #66cc66;">&#40;</span>Weight<span style="color: #66cc66;">&#41;</span>
         <span style="color: #993333; font-weight: bold;">FROM</span> Production<span style="color: #66cc66;">.</span>Product 
         <span style="color: #993333; font-weight: bold;">WHERE</span> Name <span style="color: #993333; font-weight: bold;">LIKE</span> <span style="color: #ff0000;">'Touring-3000%'</span> <span style="color: #66cc66;">&#41;</span>;
   PRINT <span style="color: #ff0000;">'Average weight of the Touring-3000 bikes is '</span> <span style="color: #66cc66;">+</span> CAST<span style="color: #66cc66;">&#40;</span>@AvgWeight <span style="color: #993333; font-weight: bold;">AS</span> varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">8</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">'.'</span> ;
END ;
GO</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://toddvance.com/?feed=rss2&amp;p=544</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting a .net System.Drawing color from a Hex value.</title>
		<link>http://toddvance.com/?p=536</link>
		<comments>http://toddvance.com/?p=536#comments</comments>
		<pubDate>Mon, 14 Jun 2010 14:36:43 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[ASP.Net]]></category>

		<guid isPermaLink="false">http://toddvance.com/?p=536</guid>
		<description><![CDATA[So I&#8217;m using a jquery color picker, got to the back code where I was going to grab my colors and thought for a minute that there was no way to convert my HEX to one of the .Net system colors&#8230; (what am I thinking, WE should always remember that there is more than likely [...]]]></description>
			<content:encoded><![CDATA[<p>So I&#8217;m using a jquery color picker, got to the back code where I was going to grab my colors and thought for a minute that there was no way to convert my HEX to one of the .Net system colors&#8230; (what am I thinking, WE should always remember that there is more than likely some class available to do what you need, as was the case here!)</p>
<p>SO YOU got a hex and need it to convert to a system color?  Here ya go:</p>
<p><strong><span style="text-decoration: underline;"><span style="color: #0000ff;">System.Drawing.ColorTranslator.FromHtml(&#8220;#FFFFFF&#8221;);</span></span></strong></p>
<p>Thank you .Net<br />
T</p>
]]></content:encoded>
			<wfw:commentRss>http://toddvance.com/?feed=rss2&amp;p=536</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Send JSON via AJAX to JQuery from an aspx page.</title>
		<link>http://toddvance.com/?p=526</link>
		<comments>http://toddvance.com/?p=526#comments</comments>
		<pubDate>Thu, 10 Jun 2010 15:11:25 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[JQuery/JScript]]></category>
		<category><![CDATA[JSON]]></category>

		<guid isPermaLink="false">http://toddvance.com/?p=526</guid>
		<description><![CDATA[This took me many tries to get this right so I am logging this so I dont have to go through this again.
JSON (Javascript Object Notation) allows us to send data to our Javascript (JQuery) and let it read that data in very useful ways.  With JSON, we can send basic keys and values to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://toddvance.com/wp-content/uploads/2010/05/jquery-logo.png"><img src="http://toddvance.com/wp-content/uploads/2010/05/jquery-logo.png" alt="" title="jquery-logo" width="268" height="268" class="alignleft size-full wp-image-508" /></a>This took me many tries to get this right so I am logging this so I dont have to go through this again.</p>
<p>JSON (Javascript Object Notation) allows us to send data to our Javascript (JQuery) and let it read that data in very useful ways.  With JSON, we can send basic keys and values to Javascript (as I will show here) up to complete objects with parameters and functions ( just google JSON tutorials to see some amazing ways to use the data).</p>
<p>HERE I will show the following scenario:  using an aspx page (but it could just as easily be a simple html page) I declare the JQuery library and  using JQuery on that page  I make a call to another aspx page (so we can get to the server and do &#8216;thinking&#8217; stuff) using one of JQuerys Ajax functions  (&#8220;$.post&#8221;) -  In that CALLED page I will be grabbing any sent in data (because our JQuery can send data to that page) , doing WHATEVER you want to do with the data (tap into a database, apply business rules, etc.) and then formatting whatever data you want to return in JSON format so that our JQuery can use it in a somewhat intelligent fashion.</p>
<p>I probably lost many of you, so let me just SHOW you and it will be much clearer.</p>
<p>STEP 1:  Markup &#8211; add the JQuery Library to your page, then call the $.post function (that function can take several types of configurations but the one I am using is the NAME of the page I am calling, the data I am sending to it, what to do with the Results I get back, and finally telling it that the results WILL BE IN JSON format.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&lt;head runat=&quot;server&quot;&gt;
    &lt;title&gt;JSON Test Page&lt;/title&gt;    
    &lt;script type=&quot;text/javascript&quot; src=&quot;js/jquery.js&quot;&gt;&lt;/script&gt;
    <span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
    $<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#jsonButt&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                  $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#jsonReturnDiv'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'&lt;img src=&quot;images/loading.gif&quot; /&gt;'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
&nbsp;
                  $.<span style="color: #660066;">post</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ajax/jsonTestPage.aspx'</span><span style="color: #339933;">,</span>         
                        <span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'ThisIsWhereIWouldSendDataIn'</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">'Data1'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Data2Etc'</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">'Data2'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>  
                      <span style="color: #006600; font-style: italic;">//The data we return will come back as JSON</span>
                       <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>                            
                           $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#firstReturnDiv'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>data.<span style="color: #660066;">first</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                           $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#secondReturnDiv'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>data.<span style="color: #660066;">second</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                           $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#thirdReturnDiv'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>data.<span style="color: #660066;">third</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                           $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#jsonReturnDiv'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">''</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
                        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;json&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
              <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
     <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
     <span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span> 
&lt;/head&gt;
&lt;body&gt;
    &lt;form id=&quot;form1&quot; runat=&quot;server&quot;&gt;
        &lt;div id=&quot;firstReturnDiv&quot;&gt; This is the first return div... check it&lt;/div&gt;
        &lt;hr /&gt;
        &lt;div id=&quot;secondReturnDiv&quot;&gt; This is the second return div... check it&lt;/div&gt;
        &lt;hr /&gt; 
        &lt;div id=&quot;thirdReturnDiv&quot;&gt; This is the third return div... check it&lt;/div&gt;       
        &lt;hr /&gt;
        &lt;input id=&quot;jsonButt&quot; type=&quot;button&quot; value=&quot;button&quot; /&gt; &lt;div id=&quot;jsonReturnDiv&quot;&gt;&lt;/div&gt;
    &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></div></div>

<p>If you dont understand the Document ready, butt click, and the rest then you should probably just read a couple QUICK JQuery tutorials &#8212; its very simple to pick up and very worthwhile.  Basically the .click function is what Kicks the whole thing off so that when a user clicks a button on my page that I have set the ID to &#8216;jsonButt&#8217;.   (I also kick off a lovely little whirly gig [ i love whirly gigs ] that I eventually hide after the data comes back) &#8230;.</p>
<p>STEP 2:  Code Behind &#8211;  So inside of my aspx page (the one I point to in the $.post function  ( &#8216;ajax/jsonTestPage.aspx&#8217;, )  I remove ALL markup and only leave my top line &#8220;<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="jsonTestPage.aspx.cs" Inherits="ajax.jsonTestPage" %>&#8221; .  Then in code behind I can grab the data that was sent in to the page via the Query string (I dont do this here) &#8230; the format the JSON data to return BACK to the page.  *** TWO THINGS MUST BE PRESENT TO MAKE THIS WORK :  THE CONTENT TYPE MUST BE SET AS I HAVE HERE AND THE JSON DATA HAS TO BE SURROUNDED BY DOUBLE QUOTES</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">        <span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">void</span> Page_Load<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, EventArgs e<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
           <span style="color: #008080; font-style: italic;">// Response.ClearHeaders();</span>
            Response.<span style="color: #0000FF;">Cache</span>.<span style="color: #0000FF;">SetCacheability</span><span style="color: #000000;">&#40;</span>HttpCacheability.<span style="color: #0000FF;">NoCache</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008080; font-style: italic;">//JSON MUST BE SENT BACK WITH THIS CONTENT TYPE!</span>
            Response.<span style="color: #0000FF;">ContentType</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;application/json&quot;</span><span style="color: #008000;">;</span> 
            <span style="color: #008080; font-style: italic;">//JSON MUST HAVE DOUBLE QOUTES!!!</span>
            <span style="color: #FF0000;">string</span> jsonReturn <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;{<span style="color: #008080; font-weight: bold;">\&quot;</span>first<span style="color: #008080; font-weight: bold;">\&quot;</span>:<span style="color: #008080; font-weight: bold;">\&quot;</span>This is the first<span style="color: #008080; font-weight: bold;">\&quot;</span>, <span style="color: #008080; font-weight: bold;">\&quot;</span>second<span style="color: #008080; font-weight: bold;">\&quot;</span>:<span style="color: #008080; font-weight: bold;">\&quot;</span>This is SECOND!<span style="color: #008080; font-weight: bold;">\&quot;</span>, <span style="color: #008080; font-weight: bold;">\&quot;</span>third<span style="color: #008080; font-weight: bold;">\&quot;</span> : <span style="color: #008080; font-weight: bold;">\&quot;</span>This is third!<span style="color: #008080; font-weight: bold;">\&quot;</span>}&quot;</span><span style="color: #008000;">;</span>
            Response.<span style="color: #0000FF;">Write</span><span style="color: #000000;">&#40;</span>jsonReturn<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span></pre></div></div>

<p>Now look at the jsonReturn string.  We have a piece of data called &#8216;first&#8217; and it&#8217;s value &#8216;This is the first&#8217;, etc&#8230; here is where we could make more complicated objects but we will keep it simple for now.  </p>
<p>STEP 3 &#8211;  This isnt really a step but just some explanation&#8230;  The Response.Write now sends the data back to the page in JSON format.  If you look again at our $.post function you will see that the return data  (which we have appropriately named &#8216;data&#8217;)  will be used here:</p>
<p>   function(data) {<br />
                           $(&#8216;#firstReturnDiv&#8217;).html(data.first);<br />
                           $(&#8216;#secondReturnDiv&#8217;).html(data.second);<br />
                           $(&#8216;#thirdReturnDiv&#8217;).html(data.third);<br />
                           $(&#8216;#jsonReturnDiv&#8217;).html( &#8221; );<br />
                        },<br />
Take note of how we were able to use the data simply now by calling data.first, data.second, etc&#8230; again, this is a simple (although elegant) use.  This allows us to do many advanced things with our return data.  We could even return an array of multiple objects and be able to use and manipulate and display them straight from Javascript. </p>
<p>Using this technique, one could write an elegant front end using ONLY JQuery and HTML while still being able to harness the power of IIS on the back end.   Hope this helps someone!   T.</p>
]]></content:encoded>
			<wfw:commentRss>http://toddvance.com/?feed=rss2&amp;p=526</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# &#8211; How to get Page Life Cycle Events</title>
		<link>http://toddvance.com/?p=522</link>
		<comments>http://toddvance.com/?p=522#comments</comments>
		<pubDate>Fri, 04 Jun 2010 18:32:34 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://toddvance.com/?p=522</guid>
		<description><![CDATA[Use &#8220;override&#8221; keyword and make sure that your AutoEventWireup is set to True in Markup.

And there you go!
Ciao!
]]></description>
			<content:encoded><![CDATA[<p>Use &#8220;override&#8221; keyword and make sure that your AutoEventWireup is set to True in Markup.</p>
<p><a href="http://toddvance.com/wp-content/uploads/2010/06/overrideKeyword.png"><img class="aligncenter size-full wp-image-523" title="overrideKeyword" src="http://toddvance.com/wp-content/uploads/2010/06/overrideKeyword.png" alt="" width="497" height="196" /></a></p>
<p>And there you go!</p>
<p>Ciao!</p>
]]></content:encoded>
			<wfw:commentRss>http://toddvance.com/?feed=rss2&amp;p=522</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Controlling the SRC of an IFRAME from code behind.</title>
		<link>http://toddvance.com/?p=519</link>
		<comments>http://toddvance.com/?p=519#comments</comments>
		<pubDate>Tue, 01 Jun 2010 17:42:39 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[VB.Net]]></category>
		<category><![CDATA[nugget. asp.net]]></category>

		<guid isPermaLink="false">http://toddvance.com/?p=519</guid>
		<description><![CDATA[Make sure to add the &#8221; runat=&#8217;server&#8217; &#8221; in the markup.

 myIFrame.Attributes&#91;&#34;src&#34;&#93; = &#34;http://www.google.com&#34;;

]]></description>
			<content:encoded><![CDATA[<p>Make sure to add the &#8221; runat=&#8217;server&#8217; &#8221; in the markup.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"> myIFrame.<span style="color: #0000FF;">Attributes</span><span style="color: #000000;">&#91;</span><span style="color: #666666;">&quot;src&quot;</span><span style="color: #000000;">&#93;</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;http://www.google.com&quot;</span><span style="color: #008000;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://toddvance.com/?feed=rss2&amp;p=519</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
