<?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>Programming By A Tool</title>
	<atom:link href="http://byatool.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://byatool.com</link>
	<description>Come waste time with me, because let's be honest:  We're both pathetic and lonely.</description>
	<lastBuildDate>Mon, 08 Mar 2010 20:07:54 +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>Child IFrame Page Interacting with Parent Page&#8230; Yeah I went there.</title>
		<link>http://byatool.com/lessons/child-iframe-page-interacting-with-parent-page-yeah-i-went-there/</link>
		<comments>http://byatool.com/lessons/child-iframe-page-interacting-with-parent-page-yeah-i-went-there/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 20:07:54 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Lessons]]></category>
		<category><![CDATA[iframe]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=1241</guid>
		<description><![CDATA[Example here.
File this under "Why?" but I wanted to see if a child could talk to a parent and then receive information back from the parent to update itself with.  As usual, my lack of intelligent wording probably has you scratching your head... if you do that.  Personally I don't get that expression [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.byatool.com/Hosted/LiveDemos/JavascriptIframeDelegate/Parent.htm">Example here.</a></p>
<p>File this under "Why?" but I wanted to see if a child could talk to a parent and then receive information back from the parent to update itself with.  As usual, my lack of intelligent wording probably has you scratching your head... if you do that.  Personally I don't get that expression as when I'm confused I more than likely will grab a jar of peanut butter and start lathering up with it, but to each his own.</p>
<p>So here's the idea, and this post is only the start.</p>
<p>You have a parent page, Parent.htm, with an iframe and you want the parent to do something and alert the child that something happened.  For now, it's actually really simple.</p>
<p>On the parent I have a method:</p>
<pre>  <span style="color: #0000ff;">function</span> callMethod(text, methodDelgate) {
    <span style="color: #0000ff;">if</span> (methodDelgate != <span style="color: #0000ff;">null</span>) {
      methodDelgate(text);
    }
  }
</pre>
<p>And this simple markup:</p>
<pre>  &lt;iframe id="myFrame" src="Child.htm"&gt;&lt;/iframe&gt;
</pre>
<p>Wow huh?  Well on the child I have this:</p>
<pre>  <span style="color: #0000ff;">function</span> callParent(text) {
    <span style="color: #0000ff;">if</span> (top.callMethod != <span style="color: #0000ff;">null</span>) {
	  top.callMethod(text, changeText);
    }
  }
</pre>
<p>This is easy.  If the parent has the method, send the text through and a method to call when finished.  What is this method?  Well its:</p>
<pre>  <span style="color: #0000ff;">function </span>changeText(text) {
    jQuery(<span style="color: #800000;">'#returnText'</span>).text(text);
  }
</pre>
<p>Which simply sets the text on some div to show it actually worked.</p>
<p>What happens when I click a button that calls callParent?  It talks to the parent, the parent calls the passed in method, and the child updates itself.</p>
<p>Not sure this is rocket science, but there will be more on it as I add in the idea of a dynamically created pop up on the parent being used by the child.  Until then, try not to be yourself.  You embarrass your mother.</p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li><a href="http://byatool.com/lessons/jquery-validation-how-to-use-to-get-rid-of-even-the-toughest-stains/" title="jQuery Validation &#8211; How to Use to Get Rid Of Even The Toughest Stains">jQuery Validation &#8211; How to Use to Get Rid Of Even The Toughest Stains</a></li><li><a href="http://byatool.com/ui/556/" title="jQuery: Add a Pop Up Div to a Link Dynamically">jQuery: Add a Pop Up Div to a Link Dynamically</a></li><li><a href="http://byatool.com/ui/jquery-position-absolute-and-how-to-make-it-all-work/" title="JQuery, Position : Absolute, and How to Make It All Work">JQuery, Position : Absolute, and How to Make It All Work</a></li><li><a href="http://byatool.com/lessons/get-the-jquery-datepicker-to-work-with-jquery-modal-dialog/" title="Get the jQuery DatePicker to Work With jQuery Modal Dialog">Get the jQuery DatePicker to Work With jQuery Modal Dialog</a></li><li><a href="http://byatool.com/ui/jquery-modal-dialog-hide-that-stupid-x-button-windows-close-button/" title="jQuery Modal Dialog : Hide That Stupid X Button / Windows Close Button">jQuery Modal Dialog : Hide That Stupid X Button / Windows Close Button</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/lessons/child-iframe-page-interacting-with-parent-page-yeah-i-went-there/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apple&#8217;s Latest Innovation Is Astounding, A Real Game Changer</title>
		<link>http://byatool.com/pointless/apples-latest-innovation-is-astounding-a-real-game-changer/</link>
		<comments>http://byatool.com/pointless/apples-latest-innovation-is-astounding-a-real-game-changer/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 19:42:50 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Pointless]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=1235</guid>
		<description><![CDATA[I don't know how they did it, but they made the world's first shrink ray.  Amazing.

Related PostsNo Related Posts]]></description>
			<content:encoded><![CDATA[<p>I don't know how they did it, but they made the world's first shrink ray.  Amazing.</p>
<p><img src="http://byatool.com/wp-content/uploads/2010/01/apple-creation-0100-rm-eng.jpg" alt="" title="apple-creation-0100-rm-eng" width="600" height="398" class="aligncenter size-full wp-image-1234" /></p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li>No Related Posts</li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/pointless/apples-latest-innovation-is-astounding-a-real-game-changer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get the jQuery DatePicker to Work With jQuery Modal Dialog</title>
		<link>http://byatool.com/lessons/get-the-jquery-datepicker-to-work-with-jquery-modal-dialog/</link>
		<comments>http://byatool.com/lessons/get-the-jquery-datepicker-to-work-with-jquery-modal-dialog/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 19:35:41 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Lessons]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=1231</guid>
		<description><![CDATA[Being that I am the man, I thought I would share this little thingy with you because... well I'm the man.
So here's the issue:  You have a date picker, a modal dialog, and you can't see the calendar when you click on the icon and/or textbox.  First thought, 'WHY DOES THIS HAPPEN TO ME???!?!' [...]]]></description>
			<content:encoded><![CDATA[<p>Being that I am the man, I thought I would share this little thingy with you because... well I'm the man.</p>
<p>So here's the issue:  You have a date picker, a modal dialog, and you can't see the calendar when you click on the icon and/or textbox.  First thought, 'WHY DOES THIS HAPPEN TO ME???!?!'  Second though, 'I wonder if that tool knows how to get past this.'  Good news!  I do.  Turns out it has to do with the z-index.  The modal dialog by default has a z-index of 1000ish when showing. (And any modal dialog "above that" will increase it's z-index to match.)  If the calendar isn't higher than that, no go.  </p>
<p>Now you might be using the jquery styles from <a href="http://jqueryui.com/themeroller/"> the jquery site</a> and might be putting your through your keyboard thinking about having to deal with that mess.  However, it's actually a simple fix in there... there being the ui.datepicker.css file.</p>
<pre>
  .ui-datepicker { width: 17em; padding: .2em .2em 0;<strong> z-index:9000</strong>; }
</pre>
<p>And there you have it.  Now the calendar will show up in front of anything lower than 9000, and as everyone knows: Anything over 9000 is impossible.</p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li><a href="http://byatool.com/lessons/child-iframe-page-interacting-with-parent-page-yeah-i-went-there/" title="Child IFrame Page Interacting with Parent Page&#8230; Yeah I went there.">Child IFrame Page Interacting with Parent Page&#8230; Yeah I went there.</a></li><li><a href="http://byatool.com/ui/jquery-modal-dialog-hide-that-stupid-x-button-windows-close-button/" title="jQuery Modal Dialog : Hide That Stupid X Button / Windows Close Button">jQuery Modal Dialog : Hide That Stupid X Button / Windows Close Button</a></li><li><a href="http://byatool.com/ui/jquery-check-all-checkboxes-toggle-method-thingy/" title="jQuery &#8211; Check All Checkboxes Toggle Method Thingy">jQuery &#8211; Check All Checkboxes Toggle Method Thingy</a></li><li><a href="http://byatool.com/lessons/jquery-validation-adding-errors-to-the-error-containter-with-love/" title="jQuery Validation: Adding Errors to the Error Containter&#8230; With Love!">jQuery Validation: Adding Errors to the Error Containter&#8230; With Love!</a></li><li><a href="http://byatool.com/ui/jquery-grab-bag-whole-bunch-of-jquery-functionality/" title="jQuery Grab Bag &#8211; Whole bunch of jQuery Functionality">jQuery Grab Bag &#8211; Whole bunch of jQuery Functionality</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/lessons/get-the-jquery-datepicker-to-work-with-jquery-modal-dialog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ByATool.com Is Looking For Writers</title>
		<link>http://byatool.com/wordpress/byatool-is-looking-for-writers/</link>
		<comments>http://byatool.com/wordpress/byatool-is-looking-for-writers/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 21:05:40 +0000</pubDate>
		<dc:creator>Andre</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Writing]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=1222</guid>
		<description><![CDATA[Yeah, you read that right.  ByATool.com is looking to add one to three writers with various IT backgrounds.  This is not a job, it is simply an avenue for you to get your work read.  We want to know what YOU want to write about.  It's no fun to be given a topic to write [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><img class="alignleft size-full wp-image-1223" title="Writer" src="http://byatool.com/wp-content/uploads/2010/01/writer.jpg" alt="" width="140" height="200" style="padding: 4px;" />Yeah, you read that right.  ByATool.com is looking to add one to three writers with various IT backgrounds.  This is not a job, it is simply an avenue for you to get your work read.  We want to know what YOU want to write about.  It's no fun to be given a topic to write about when your passion lies elsewhere.  Please contact us at the address listed below so we can discuss this one-on-one!</p>
<p style="text-align: justify;"><strong>What we need from you:</strong><br />
Name:<br />
E-Mail:<br />
What would you like to write about:<br />
How often would you like to write:</p>
<p style="text-align: justify;">Please submit this simple information, <span style="text-decoration: underline;">along with an example blog post</span> to iwanttowrite [at] byatool [dot] com</p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li>No Related Posts</li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/wordpress/byatool-is-looking-for-writers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dear Microsoft,</title>
		<link>http://byatool.com/uncategorized/dear-microsoft/</link>
		<comments>http://byatool.com/uncategorized/dear-microsoft/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 19:00:00 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=1220</guid>
		<description><![CDATA[If it takes a whole paragraph to explain what "continue" means,  maybe you  should rethink the button text and/or layout.
Sincerely,
Sean
Related PostsNo Related Posts]]></description>
			<content:encoded><![CDATA[<p>If it takes a whole paragraph to explain what "continue" means,  maybe you  should rethink the button text and/or layout.</p>
<p>Sincerely,</p>
<p>Sean</p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li>No Related Posts</li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/uncategorized/dear-microsoft/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Modal Dialog : Hide That Stupid X Button / Windows Close Button</title>
		<link>http://byatool.com/ui/jquery-modal-dialog-hide-that-stupid-x-button-windows-close-button/</link>
		<comments>http://byatool.com/ui/jquery-modal-dialog-hide-that-stupid-x-button-windows-close-button/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 16:05:18 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[UI]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Modal Dialog]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=1213</guid>
		<description><![CDATA[This is quick one, so hold on to your... whatever.
Want to get rid of that X at the top right of the modal "Control"?  Well here it is:  (The bold part, moron)
     jQuery('#WaitingDiv').dialog({
          autoOpen: false,
      [...]]]></description>
			<content:encoded><![CDATA[<p>This is quick one, so hold on to your... whatever.</p>
<p>Want to get rid of that X at the top right of the modal "Control"?  Well here it is:  (The bold part, moron)</p>
<pre>     jQuery(<span style="color: #800000;">'#WaitingDiv'</span>).dialog({
          autoOpen: false,
          bgiframe: false,
          height: 150,
          width: 200,
          modal: true,
         <strong> open: function(event, ui) { jQuery(<span style="color: #800000;">'.ui-dialog-titlebar-close'</span>).hide();</strong> }
        });
</pre>
<p>And that's really it.  Just thought I'd pass that on to you, the consumer.</p>
<p>On a side note, the big movie thing is the <a href=" http://www.huffingtonpost.com/2010/01/11/spider-man-4-off-spider-m_n_419264.html">canceling of Spiderman 4 or at least going in a new direction</a>.  As much as I don't care, it might lead to my dream come true:</p>
<p>A spiderman movie based on the SNES classic: Spider-Man &amp; Venom: Maximum Carnage.  Uwe Boll, are you out there?</p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li><a href="http://byatool.com/lessons/child-iframe-page-interacting-with-parent-page-yeah-i-went-there/" title="Child IFrame Page Interacting with Parent Page&#8230; Yeah I went there.">Child IFrame Page Interacting with Parent Page&#8230; Yeah I went there.</a></li><li><a href="http://byatool.com/lessons/get-the-jquery-datepicker-to-work-with-jquery-modal-dialog/" title="Get the jQuery DatePicker to Work With jQuery Modal Dialog">Get the jQuery DatePicker to Work With jQuery Modal Dialog</a></li><li><a href="http://byatool.com/ui/jquery-check-all-checkboxes-toggle-method-thingy/" title="jQuery &#8211; Check All Checkboxes Toggle Method Thingy">jQuery &#8211; Check All Checkboxes Toggle Method Thingy</a></li><li><a href="http://byatool.com/lessons/jquery-validation-adding-errors-to-the-error-containter-with-love/" title="jQuery Validation: Adding Errors to the Error Containter&#8230; With Love!">jQuery Validation: Adding Errors to the Error Containter&#8230; With Love!</a></li><li><a href="http://byatool.com/ui/jquery-grab-bag-whole-bunch-of-jquery-functionality/" title="jQuery Grab Bag &#8211; Whole bunch of jQuery Functionality">jQuery Grab Bag &#8211; Whole bunch of jQuery Functionality</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/ui/jquery-modal-dialog-hide-that-stupid-x-button-windows-close-button/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery &#8211; Check All Checkboxes Toggle Method Thingy</title>
		<link>http://byatool.com/ui/jquery-check-all-checkboxes-toggle-method-thingy/</link>
		<comments>http://byatool.com/ui/jquery-check-all-checkboxes-toggle-method-thingy/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 23:20:11 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[UI]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=1203</guid>
		<description><![CDATA[So here's a quick on for all you boys and girls... and anything else I might have missed.
Say you want to check all check boxes in a grid or whatever, but you want it to toggle.  So if if it's time to check all, all get checked and then the next time the button [...]]]></description>
			<content:encoded><![CDATA[<p>So here's a quick on for all you boys and girls... and anything else I might have missed.<br />
Say you want to check all check boxes in a grid or whatever, but you want it to toggle.  So if if it's time to check all, all get checked and then the next time the button is clicked it will uncheck.  Now you could do this in three methods, maybe two but that's why you're a mouth breather.</p>
<p>Special people like me do it in one.</p>
<pre>    <span style="color: #0000ff;">function</span> toggleCheckboxes(buttonId, checkBoxNamePrefix, checked)
    {
      <span style="color: #008000;">//Get all checkboxes with the prefix name and check/uncheck</span>
      jQuery(<span style="color: #800000;">'[id*=' + checkBoxNamePrefix + ']'</span>).attr(<span style="color: #800000;">'checked'</span>, checked);

      <span style="color: #008000;">//remove any click handlers from the button</span>
      <span style="color: #008000;">//  Why?  Because jQuery(buttonId).click() will just add another handler</span>
      jQuery(buttonId).unbind(<span style="color: #800000;">'click'</span>); 

      <span style="color: #008000;">//Add the new click handler</span>
      jQuery(buttonId).click(
        <span style="color: #0000ff;">function</span>() {
          toggleCheckboxes(buttonId, checkBoxNamePrefix, !checked);
        }
      );
    }</pre>
<p>And POW!  What?  You want to know how to use it?  Fine, but only because I'm nice.</p>
<pre>   jQuery(<span style="color: #800000;">'#buttonName'</span>).click(
     <span style="color: #0000ff;">function</span>() {
       toggleCheckboxes(<span style="color: #800000;">'#buttonName'</span>,<span style="color: #800000;"> 'someCheckBoxName'</span>, <span style="color: #0000ff;">true</span>);
     }
   );</pre>
<p>And in case you were still wondering why I used .unbind and didn't understand the comment, it's because using just .click will add another handler to the button. So next click you will get both check and uncheck all.  Kind of hurts the effectiveness.</p>
<p>And there you have it.  Once again I have filled your life with meaning.  Couldn't be easier.  Or maybe it could but that's not my problem now is it?  Go back to doing something useful.</p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li><a href="http://byatool.com/lessons/child-iframe-page-interacting-with-parent-page-yeah-i-went-there/" title="Child IFrame Page Interacting with Parent Page&#8230; Yeah I went there.">Child IFrame Page Interacting with Parent Page&#8230; Yeah I went there.</a></li><li><a href="http://byatool.com/lessons/get-the-jquery-datepicker-to-work-with-jquery-modal-dialog/" title="Get the jQuery DatePicker to Work With jQuery Modal Dialog">Get the jQuery DatePicker to Work With jQuery Modal Dialog</a></li><li><a href="http://byatool.com/ui/jquery-modal-dialog-hide-that-stupid-x-button-windows-close-button/" title="jQuery Modal Dialog : Hide That Stupid X Button / Windows Close Button">jQuery Modal Dialog : Hide That Stupid X Button / Windows Close Button</a></li><li><a href="http://byatool.com/lessons/jquery-validation-adding-errors-to-the-error-containter-with-love/" title="jQuery Validation: Adding Errors to the Error Containter&#8230; With Love!">jQuery Validation: Adding Errors to the Error Containter&#8230; With Love!</a></li><li><a href="http://byatool.com/ui/jquery-grab-bag-whole-bunch-of-jquery-functionality/" title="jQuery Grab Bag &#8211; Whole bunch of jQuery Functionality">jQuery Grab Bag &#8211; Whole bunch of jQuery Functionality</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/ui/jquery-check-all-checkboxes-toggle-method-thingy/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>jQuery Validation: Adding Errors to the Error Containter&#8230; With Love!</title>
		<link>http://byatool.com/lessons/jquery-validation-adding-errors-to-the-error-containter-with-love/</link>
		<comments>http://byatool.com/lessons/jquery-validation-adding-errors-to-the-error-containter-with-love/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 21:28:49 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Lessons]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Validation]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=1178</guid>
		<description><![CDATA[
Hello again, my wonderful audience, I have something great and fun planned for this post. If you read this post you might have been left wondering how to add custom messages to the error holder. It's ok if you did, there's nothing wrong with being confused all the time. It's what makes you so adorable.
Say [...]]]></description>
			<content:encoded><![CDATA[<pre><img src="http://www.iheartvector.com/wp-content/vector/hearts.png" alt="" /></pre>
<p><span style="background-color: #FFFFFF;" title="Please send help, the Board of Directors is forcing me to be nice!">Hello again, my wonderful audience, I have something great and fun planned for this post. If you read <a href="http://byatool.com/lessons/jquery-validation-how-to-use-to-get-rid-of-even-the-toughest-stains/">this post</a> you might have been left wondering how to add custom messages to the error holder. It's ok if you did, there's nothing wrong with being confused all the time. It's what makes you so adorable.</span></p>
<p><span style="background-color: #FFFFFF;" title="I really don't mean the last part.">Say you have a form like this, and if you don't I cry endlessly for your loss. My heart goes out to you.</span></p>
<pre>&lt;<span style="color: #800000;">form</span> <span style="color: #0000ff;">id=</span><span style="color: #ff0000;">"ILoveEverythingForm"</span>&gt;
    &lt;<span style="color: #800000;">div</span> <span style="color: #0000ff;">id=</span><span style="color: #ff0000;">"NotSoNiceThingsDiv"</span> <span style="color: #0000ff;">style</span><span style="color: #0000ff;">=</span><span style="color: #ff0000;">"display:none;"</span>&gt;&lt;/<span style="color: #800000;">div</span>&gt;
	...
&lt;/<span style="color: #800000;">form</span>&gt;</pre>
<p><span style="background-color: #FFFFFF;" title="This is the cheesiest piece of...">As you can see, there is an error div to hold mean things that we have to print out because the system just doesn't like the user. As we both know, the user can't help but be dumb. It's just in his cute little nature. And that nature is just so darned cute.</span></p>
<p><span style="background-color: #FFFFFF;" title="Uhg, this really sucks.">Now let's assume that you have something that sent back a bunch of mean messages when you tried to validate server side after all the cute client side validation was done. You might have a method to take in those jerk face messages. How do you display them in the bad place?</span></p>
<pre>  <span style="color: #0000ff;">function</span> updateErrorDivContentWithLove(messages)
  {
    <span style="color: #0000ff;">if</span>(messages.length &gt; 0)
    {
      <span style="color: #0000ff;">var</span> validator = jQuery(<span style="color: #800000;">'#ILoveEverythingForm'</span>).validate();

      <span style="color: #0000ff;">for</span>(<span style="color: #0000ff;">var</span> loopCounter = 0; loopCounter &lt; messages.length; loopCounter ++)
      {
        validator.showErrors
        (
          {
             <span style="color: #800000;">'SomeWonderfulElementName'</span> : messages[loopCounter].Message
          }
        );
      }
    }
  }</pre>
<p><span style="background-color: #FFFFFF;" title="I wish I could stab my eyes right now...">Awwww kitties!</span></p>
<pre>  <img src="http://www.dailypets.co.uk/wp-content/uploads/2007/06/kittens-cups.jpg" alt="" /></pre>
<p><span style="background-color: #FFFFFF;" title="I am losing mad rep on this.">Only thing that may seem odd (And if it doesn't, don't worry you are still very special and loved in this world):</span></p>
<pre>  'SomeElementName' : messages[loopCounter].Message</pre>
<p><span style="background-color: #FFFFFF;" title="Oh for f--ks sake...">Not sure what element really needs to be here, basically anything in the form with a name tag. So if you're good like I know you are, you have at least one element in that little old form with a name property set. I would say that this is pretty useless in situations where all the errors are shown in one div, as opposed to right next to the element, but that would be mean and I don't do that.</span></p>
<p><span style="background-color: #FFFFFF;" title="I swear I'm not really a nice person, please believe me.">Now I know you wanted something special from this post so I just wanted you to know that even though most of the world considers you hideous, I say you should be proud of being hideous because it makes you who you are. A unique miracle that only really has issues with dogs and small children. Embrace yourself in whatever way you take that!</span></p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li><a href="http://byatool.com/lessons/jquery-validation-how-to-use-to-get-rid-of-even-the-toughest-stains/" title="jQuery Validation &#8211; How to Use to Get Rid Of Even The Toughest Stains">jQuery Validation &#8211; How to Use to Get Rid Of Even The Toughest Stains</a></li><li><a href="http://byatool.com/lessons/child-iframe-page-interacting-with-parent-page-yeah-i-went-there/" title="Child IFrame Page Interacting with Parent Page&#8230; Yeah I went there.">Child IFrame Page Interacting with Parent Page&#8230; Yeah I went there.</a></li><li><a href="http://byatool.com/lessons/get-the-jquery-datepicker-to-work-with-jquery-modal-dialog/" title="Get the jQuery DatePicker to Work With jQuery Modal Dialog">Get the jQuery DatePicker to Work With jQuery Modal Dialog</a></li><li><a href="http://byatool.com/ui/jquery-modal-dialog-hide-that-stupid-x-button-windows-close-button/" title="jQuery Modal Dialog : Hide That Stupid X Button / Windows Close Button">jQuery Modal Dialog : Hide That Stupid X Button / Windows Close Button</a></li><li><a href="http://byatool.com/ui/jquery-check-all-checkboxes-toggle-method-thingy/" title="jQuery &#8211; Check All Checkboxes Toggle Method Thingy">jQuery &#8211; Check All Checkboxes Toggle Method Thingy</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/lessons/jquery-validation-adding-errors-to-the-error-containter-with-love/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom Data Annotations With MVC: How to Check Multiple Properties at One Time</title>
		<link>http://byatool.com/mvc/custom-data-annotations-with-mvc-how-to-check-multiple-properties-at-one-time/</link>
		<comments>http://byatool.com/mvc/custom-data-annotations-with-mvc-how-to-check-multiple-properties-at-one-time/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 22:54:35 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[MVC]]></category>
		<category><![CDATA[Data Annotations]]></category>
		<category><![CDATA[Validation]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=1162</guid>
		<description><![CDATA[Ok so maybe you read this post and you're thinking to yourself, "I wonder if Diet Dr. Pepper really does taste like regular Dr. Pepper" which of course is silly because the ads clearly say it does. Now you should be asking yourself, "How do I check if two properties have the same value on [...]]]></description>
			<content:encoded><![CDATA[<p>Ok so maybe you read <a href="http://byatool.com/lessons/data-annotations-mvc-and-why-you-might-like-them/">this post</a> and you're thinking to yourself, "I wonder if Diet Dr. Pepper really does taste like regular Dr. Pepper" which of course is silly because the ads clearly say it does. Now you should be asking yourself, "How do I check if two properties have the same value on a class with annotation when the property level ones only can check the one property's value?" Kind of wordy way of asking that, but I get what you're asking. Better yet, like usual, I have an answer.</p>
<p>Now what I can swear is that I was no where near the Baxter Building between 1-3 am on Saturday the 15th. I was in fact I was sleeping and have 20 witnesses that can testify. What I can't swear is this is the best way to go about it but it seems to work AND make sense. It's not common for me to come up with solutions that do both.</p>
<pre>  [<span style="color: #008080;">AttributeUsage</span>(<span style="color: #008080;">AttributeTargets</span>.Class)]
  <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> <span style="color: #008080;">PropertiesMatchAttribute </span>: <span style="color: #008080;">ValidationAttribute</span>
  { 

    <span style="color: #0000ff;">public</span> <span style="color: #008080;">String</span> FirstPropertyName { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">String</span> SecondPropertyName { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; } 

    <span style="color: #008080;">/<span style="color: #008000;">/Constructor to take in the property names that are supposed to be checked</span></span>
    <span style="color: #0000ff;">public</span> PropertiesMatchAttribute(<span style="color: #008080;">String</span> firstPropertyName, <span style="color: #008080;">String</span> secondPropertyName )
    {
      FirstPropertyName = firstPropertyName;
      SecondPropertyName = secondPropertyName ;
    } 

    <span style="color: #0000ff;">p</span><span style="color: #0000ff;">ublic</span> <span style="color: #0000ff;">override</span> <span style="color: #008080;">Boolean</span> IsValid(<span style="color: #008080;">Object</span> value)
    {
      <span style="color: #008080;">Type</span> objectType = value.GetType();
      <span style="color: #008000;">//Get the property info for the object passed in.  This is the class the attribute is</span>
      <span style="color: #008000;">//  attached to</span>
      <span style="color: #008000;">//I would suggest caching this part... at least the PropertyInfo[]</span>
      <span style="color: #008080;">PropertyInfo</span>[] neededProperties =
        objectType.GetProperties()
        .Where(propertyInfo =&gt; propertyInfo.Name == FirstPropertyName || propertyInfo.Name == SecondPropertyName)
        .ToArray();

      <span style="color: #0000ff;">if</span>(neededProperties.Count() != 2)
      {
        <span style="color: #0000ff;">throw</span> <span style="color: #0000ff;">new</span> <span style="color: #008080;">ApplicationException</span>("PropertiesMatchAttribute error on " + objectType.Name);
      }

      <span style="color: #008080;">Boolean</span> isValid = <span style="color: #0000ff;">true</span>;

      <span style="color: #008000;">//Convert both values to string and compare...  Probably could be done better than this</span>
      <span style="color: #008000;">//  but let's not get bogged down with how dumb I am.  We should be concerned about</span>
      <span style="color: #008000;">//  dumb you are, jerkface.</span>
      <span style="color: #0000ff;">if</span>(!<span style="color: #008080;">Convert</span>.ToString(neededProperties[0].GetValue(value, <span style="color: #0000ff;">null</span>)).Equals(<span style="color: #008080;">Convert</span>.ToString(neededProperties[1].GetValue(value, <span style="color: #0000ff;">null</span>))))
      {
        isValid = <span style="color: #0000ff;">false</span>;
      }

      <span style="color: #0000ff;">r</span><span style="color: #0000ff;">eturn</span> isValid;
    }
  }
}</pre>
<p>And then the use:</p>
<pre>  [<span style="color: #008080;">PropertiesMatchAttribute</span>(<span style="color: #800000;">"Password"</span>, <span style="color: #800000;">"ConfirmPassword"</span>, ErrorMessage = <span style="color: #800000;">"Match the passwords, dumb--s."</span>)]
  <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> <span style="color: #008080;">UserCreateModel</span>
  {
     <span style="color: #0000ff;">public</span> <span style="color: #008080;">String</span> ConfirmPassword{ <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
     <span style="color: #0000ff;">public</span> <span style="color: #008080;">String</span> Password { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
  }</pre>
<p>Wasn't so hard was it? Normally this would be the part where I degrade you for being bumb because you didn't figure this out but I'm above that now. I guess it must be the holiday season or that I've been told by the board that I should be more gentle with my readers. Guess some were crying after reading some of my posts. Yeah whatever. Bunch of [Removed by Andre].</p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li><a href="http://byatool.com/lessons/jquery-validation-adding-errors-to-the-error-containter-with-love/" title="jQuery Validation: Adding Errors to the Error Containter&#8230; With Love!">jQuery Validation: Adding Errors to the Error Containter&#8230; With Love!</a></li><li><a href="http://byatool.com/lessons/data-annotations-mvc-and-why-you-might-like-them/" title="Data Annotations, MVC, and Why You Might Like Them">Data Annotations, MVC, and Why You Might Like Them</a></li><li><a href="http://byatool.com/lessons/jquery-validation-how-to-use-to-get-rid-of-even-the-toughest-stains/" title="jQuery Validation &#8211; How to Use to Get Rid Of Even The Toughest Stains">jQuery Validation &#8211; How to Use to Get Rid Of Even The Toughest Stains</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/mvc/custom-data-annotations-with-mvc-how-to-check-multiple-properties-at-one-time/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Data Annotations, MVC, and Why You Might Like Them</title>
		<link>http://byatool.com/lessons/data-annotations-mvc-and-why-you-might-like-them/</link>
		<comments>http://byatool.com/lessons/data-annotations-mvc-and-why-you-might-like-them/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 18:01:40 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Lessons]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Data Annotations]]></category>
		<category><![CDATA[MVC]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=1155</guid>
		<description><![CDATA[So if you were like me before I knew what Data Annotations were, you most likely would be thinking, "What are Data Annotations?".  Well I'm glad I can read your mind and therefore I am glad you asked.
Now the fun part about this post is that I might have to admit I was wrong. [...]]]></description>
			<content:encoded><![CDATA[<p>So if you were like me before I knew what Data Annotations were, you most likely would be thinking, "What are Data Annotations?".  Well I'm glad I can read your mind and therefore I am glad you asked.</p>
<p>Now the fun part about this post is that I might have to admit I was wrong.  Why would that be?  Well in <a href="http://byatool.com/pontification/asp-net-mvc-quick-overview-of-controller-structure/">this post</a> I suggested that validation rules would be set in the controller.  Turns out, there is possibly a better place, on the model itself.  How can this be done???  Well that's what you're about to find out.</p>
<p>Say you have a user create model:</p>
<pre>  <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> AddUserModel
  {
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">String</span> UserName { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">String</span> Password { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">String</span> RepeatPassword { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
  }</pre>
<p>Now you could have a method on the controller like:</p>
<pre>  <span style="color: #0000ff;">publi</span>c <span style="color: #008080;">ActionResul</span>t AddUser(<span style="color: #008080;">AddUserMode</span>l model)
  {
    <span style="color: #0000ff;">if</span>(IsValid(model))
    {
      ...
    }
  }</pre>
<p>Where you have to create the IsValid method for every model on the controller that you need to validate (And possibly on other controllers if you are sharing models between them...) Or you can have this:</p>
<pre>  <span style="color: #0000ff;">public</span> <span style="color: #008080;">ActionResult</span> AddUser(<span style="color: #008080;">AddUserModel</span> model)
  {
    <span style="color: #0000ff;">if</span>(<span style="color: #008080;">ModelState</span>.IsValid)
    {
      ...
    }
  }</pre>
<p>And that is already built in so no validation method needed.  But how is that possible?  Attributes on the model or namely the ValidationAttribute class.</p>
<p>First off you have to include the System.ComponentModel dll in the project.  Simple enough.  Please say you know how to do that or do me a favor and remind yourself to blink. OK done?  Good.</p>
<p>Now you can use some of the built in attributes which is good.  Things like required are nice:</p>
<pre>  <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> <span style="color: #008080;">AddUserModel</span>
  {
    [<span style="color: #008080;">Required</span>]
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">String</span> <span style="color: #008080;">UserName</span> { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    ...
  }</pre>
<p>There you go.  Now if the UserName is null or empty, the ModelState will no longer be valid and will fail this check:</p>
<pre>  <span style="color: #008080;">ModelState</span>.IsValid</pre>
<p>Now you might wonder what the error message will be for that?  Honest answer:  I have no f--king clue.  That's why you can actually set it.  Those guys at Microsoft thought of everything.</p>
<pre>  <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> <span style="color: #008080;">AddUserModel</span>
  {
    [<span style="color: #008080;">Required</span>(ErrorMessage = <span style="color: #800000;">"ENTER A USERNAME IDIOT!"</span>]
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">String</span> UserName { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    ...
  }</pre>
<blockquote><p>The guys in the legal department have told me I have to note that your error message should change depending on your use and you shouldn't use the one above.  Whatever.</p></blockquote>
<p>Now you might want to actually pass the errors back, and why wouldn't you?  You're a fine, upstanding, and thoughtful person and I lie like a crook.  The errors, if there are any, are in here:</p>
<pre>  ViewData.ModelState.Values</pre>
<p>And you can use two loops to get to all of them, but I think the parent loop will only run once.</p>
<pre>  <span style="color: #0000ff;">foreach</span> (<span style="color: #008080;">ModelState</span> state <span style="color: #0000ff;">in</span> ViewData.ModelState.Values)
  {
    <span style="color: #0000ff;">foreach</span> (<span style="color: #008080;">ModelErro</span>r error <span style="color: #0000ff;">in</span> state.Errors)
    {
      messageList.Add(error.ErrorMessage);
    }
  }</pre>
<p>Pretty nice huh?  Maybe if you're an idiot who just learned about this.  For cool people like me, it's old news.</p>
<p>What's the point this?  If "this" is data annotations:  Well it helps move some of the validation off the controller if you are looking for a more "Fat model, skinny controller" design which I'm told is a good idea.  This also gets rid of all the validation methods and saves time because of it.</p>
<p>If "this" is your life?  I have no idea.  But if you're to the point that you're asking me about the meaning of your life, you are in some serious trouble.</p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li><a href="http://byatool.com/mvc/custom-data-annotations-with-mvc-how-to-check-multiple-properties-at-one-time/" title="Custom Data Annotations With MVC: How to Check Multiple Properties at One Time">Custom Data Annotations With MVC: How to Check Multiple Properties at One Time</a></li><li><a href="http://byatool.com/add-on/random-add-on-automapper/" title="Random Add-On &#8211; Automapper">Random Add-On &#8211; Automapper</a></li><li><a href="http://byatool.com/pointless/state-list-in-dictionary-form/" title="State List in Dictionary Form">State List in Dictionary Form</a></li><li><a href="http://byatool.com/pontification/asp-net-mvc-quick-overview-of-controller-structure/" title="ASP.Net MVC:  Quick Overview of Controller Structure">ASP.Net MVC:  Quick Overview of Controller Structure</a></li><li><a href="http://byatool.com/pointless/asp-net-mvc-attibute-to-check-if-route-value-exists-and-and-means-something/" title="ASP.Net MVC: Attibute to Check if Route Value Exists and&#8230; and Means Something!">ASP.Net MVC: Attibute to Check if Route Value Exists and&#8230; and Means Something!</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/lessons/data-annotations-mvc-and-why-you-might-like-them/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Grab Bag &#8211; Whole bunch of jQuery Functionality</title>
		<link>http://byatool.com/ui/jquery-grab-bag-whole-bunch-of-jquery-functionality/</link>
		<comments>http://byatool.com/ui/jquery-grab-bag-whole-bunch-of-jquery-functionality/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 21:06:32 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[UI]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=1125</guid>
		<description><![CDATA[You could look at this post as a self serving block that I will use to save stuff I don't want to remember later.
Or you could see it as a knowledge transfer that you the reader can learn from because I am a generous and giving tool.
Whatever, I really don't care.  I won't sleep [...]]]></description>
			<content:encoded><![CDATA[<p>You could look at this post as a self serving block that I will use to save stuff I don't want to remember later.</p>
<p>Or you could see it as a knowledge transfer that you the reader can learn from because I am a generous and giving tool.</p>
<p>Whatever, I really don't care.  I won't sleep any differently.  I just don't feel like making 1000 posts of jquery stupidity.</p>
<p>I'll add more as I come across them.</p>
<h2>Checkbox</h2>
<p><strong>How To Check a CheckBox</strong></p>
<pre>  jQuery(<span style="color: #800000;">'#CheckBoxId'</span>).attr(<span style="color: #800000;">'checked'</span>, <span style="color: #0000ff;">false</span>);</pre>
<p><strong>How To Know if a Checkbox is Checked</strong></p>
<pre>  jQuery(<span style="color: #800000;">'#CheckBoxId'</span>).is(<span style="color: #800000;">':checked'</span>)</pre>
<p><strong>How To Find a Bunch of Like Named Checkboxes that are Checked</strong></p>
<pre>  jQuery(<span style="color: #800000;">'[id*=someCheckBox_]:checked'</span>);</pre>
<h2>Drop Down Lists</h2>
<p><strong>How to Add an Item/Option to a Drop Down List</strong></p>
<pre> jQuery(<span style="color: #800000;">'#DropDownListId'</span>).append(jQuery(<span style="color: #800000;">'&lt;option&gt;'</span>).val(1).html(<span style="color: #800000;">"SomeText"</span>));</pre>
<p>Odd Note:  Apparently jquery is smart enough to set the attributes on the option AND close the option with &lt;/option&gt;</p>
<p><strong>How to Remove an Item/Option from a Drop Down List</strong></p>
<pre>  jQuery(<span style="color: #800000;">'#DropDownListId option[value=\'3\']'</span>).remove();</pre>
<p><strong>How to Sort a Drop Down List by Option Text</strong></p>
<pre>  <span style="color: #0000ff;">var</span> sortedList = jQuery(<span style="color: #800000;">'#someDropDownList option'</span>).sort(
    <span style="color: #0000ff;">function</span> (first, second) {
      <span style="color: #0000ff;">return</span> first.text == second.text ? 0 : first.text &lt; second.text ? -1 : 1;
    }
  );

  jQuery(<span style="color: #800000;">'#someDropDownList'</span>).html(sortedList);</pre>
<h2>Elements</h2>
<p><strong> How to Filter Out an Element in a List</strong></p>
<pre>  someElementList.filter(<span style="color: #800000;">'[id=someId]'</span>);</pre>
<p>Example:</p>
<pre><span style="color: #008000;">  //Uncheck all id like someId_ and check only where id = someId_1</span>
<span style="color: #0000ff;">  var</span> someElementList = someElement.children(<span style="color: #800000;">'[id*=someId_]'</span>);
  someElementList.attr(<span style="color: #800000;">'checked'</span>, <span style="color: #0000ff;">false</span>);
  someElementList.filter(<span style="color: #800000;">'[id=someId_1]'</span>).attr(<span style="color: #800000;">'checked'</span>, <span style="color: #0000ff;">true</span>);</pre>
<p><strong>How To Find an Element Based on a Like Name/Using Wildcards</strong></p>
<pre>  jQuery(<span style="color: #800000;">'#SomeTable'</span>).children(<span style="color: #800000;">'tr[id*=SomeRowId]'</span>);</pre>
<p><strong>How To Know if a Something is Hidden</strong></p>
<pre>  jQuery(<span style="color: #800000;">'#CheckBoxId'</span>).is(<span style="color: #800000;">':hidden'</span>)</pre>
<p>Possible Use:</p>
<pre> <span style="color: #0000ff;">function</span> showOrHide(element) {
    <span style="color: #0000ff;">if</span>(jQuery(element).is(<span style="color: #800000;">':hidden'</span>)) {
      jQuery(element).show();
    }
    <span style="color: #0000ff;">else</span> {
      jQuery(element).hide();
    }
  }</pre>
<p><strong>How to Disable an Input/Select</strong></p>
<pre>  jQuery(<span style="color: #800000;">'#DropDownListId'</span>).attr(<span style="color: #800000;">'disabled'</span>, <span style="color: #800000;">'disabled'</span>);</pre>
<p><strong>How to Enable an Input/Select</strong></p>
<pre>  jQuery(<span style="color: #800000;">'#DropDownListId'</span>).removeAttr(<span style="color: #800000;">'disabled'</span>);</pre>
<p><strong>How to Know if an Element Exists</strong></p>
<pre>  jQuery(<span style="color: #800000;">'#ElementId'</span>).length &gt; 0</pre>
<p>Possible use:</p>
<pre>  <span style="color: #0000ff;">function</span> elementExists(elementId) {
    <span style="color: #0000ff;">return</span> jQuery(elementId).length &gt; 0;
  }</pre>
<h2>String</h2>
<p><strong>How To Remove the First Character from a String</strong></p>
<pre>  someString.substring(1, someString.length)</pre>
<h2>Tables</h2>
<p><strong>How to Add a Row to a Table</strong></p>
<pre>  jQuery(<span style="color: #800000;">'#TableId &gt; tbody:last'</span>).append(<span style="color: #800000;">'&lt;tr&gt;...&lt;/tr&gt;'</span>)</pre>
<p><strong>How to Remove a Table Row</strong></p>
<pre>  jQuery(<span style="color: #800000;">'#TableId &gt; tbody:last'</span>).children(someSortOfRowId).remove();</pre>
<h2>Methods</h2>
<p><strong>How to Post With a Link</strong></p>
<pre>  <span style="color: #0000ff;">function</span> postToUrl(path, params)
  {
    <span style="color: #0000ff;">var</span> method = "post"; 

    <span style="color: #0000ff;">var</span> form = document.createElement(<span style="color: #800000;">"form"</span>);
    form.setAttribute(<span style="color: #800000;">"method"</span>, method);
    form.setAttribute(<span style="color: #800000;">"action"</span>, path);
    for(<span style="color: #0000ff;">var</span> key <span style="color: #0000ff;">in</span> params)
    {
        var hiddenField = document.createElement(<span style="color: #800000;">"input"</span>);
        hiddenField.setAttribute(<span style="color: #800000;">"type"</span>, <span style="color: #800000;">"hidden"</span>);
        hiddenField.setAttribute(<span style="color: #800000;">"name"</span>, key);
        hiddenField.setAttribute(<span style="color: #800000;">"value"</span>, params[key]);
        form.appendChild(hiddenField);
    }
    document.body.appendChild(form);    

    form.submit();
  }</pre>
<p>Use:</p>
<pre>&lt;a href="javascript:postToUrl('/SomeController/SomeAction/', { 'id', '1' })"&gt;link&lt;/a&gt;</pre>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li><a href="http://byatool.com/lessons/child-iframe-page-interacting-with-parent-page-yeah-i-went-there/" title="Child IFrame Page Interacting with Parent Page&#8230; Yeah I went there.">Child IFrame Page Interacting with Parent Page&#8230; Yeah I went there.</a></li><li><a href="http://byatool.com/lessons/get-the-jquery-datepicker-to-work-with-jquery-modal-dialog/" title="Get the jQuery DatePicker to Work With jQuery Modal Dialog">Get the jQuery DatePicker to Work With jQuery Modal Dialog</a></li><li><a href="http://byatool.com/ui/jquery-modal-dialog-hide-that-stupid-x-button-windows-close-button/" title="jQuery Modal Dialog : Hide That Stupid X Button / Windows Close Button">jQuery Modal Dialog : Hide That Stupid X Button / Windows Close Button</a></li><li><a href="http://byatool.com/ui/jquery-check-all-checkboxes-toggle-method-thingy/" title="jQuery &#8211; Check All Checkboxes Toggle Method Thingy">jQuery &#8211; Check All Checkboxes Toggle Method Thingy</a></li><li><a href="http://byatool.com/lessons/jquery-validation-adding-errors-to-the-error-containter-with-love/" title="jQuery Validation: Adding Errors to the Error Containter&#8230; With Love!">jQuery Validation: Adding Errors to the Error Containter&#8230; With Love!</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/ui/jquery-grab-bag-whole-bunch-of-jquery-functionality/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery Validation &#8211; How to Use to Get Rid Of Even The Toughest Stains</title>
		<link>http://byatool.com/lessons/jquery-validation-how-to-use-to-get-rid-of-even-the-toughest-stains/</link>
		<comments>http://byatool.com/lessons/jquery-validation-how-to-use-to-get-rid-of-even-the-toughest-stains/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 18:17:29 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Lessons]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Validation]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=1092</guid>
		<description><![CDATA[So you want to use jQuery validation, huh?
What is it?  Something that was added to the holy jquery site and is an easy way to validate input from users. Now this should in no way take over for server side validation, but it helps to at least catch a few things without having to [...]]]></description>
			<content:encoded><![CDATA[<p>So you want to use jQuery validation, huh?</p>
<p>What is it?  Something that was added to the<a href="http://jquery.com/"> <strong>holy jquery site</strong></a> and is an easy way to validate input from users. Now this should in no way take over for server side validation, but it helps to at least catch a few things without having to send anything to the server.  So how do ya do it?</p>
<p>Well to start, you need some files:</p>
<p><a href="http://docs.jquery.com/Release:jQuery_1.3.2">jquery-1.3.2.js</a> and <a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/">jquery.validate.js</a>.</p>
<p>Now oddly enough the validation file isn't hosted on the <a href="http://jquery.com/"> <strong>holy jquery site</strong></a> but <a href="http://docs.jquery.com/Plugins/Validation">how to use it is</a>.</p>
<p>Ok now you have the files, what's next?  Well you need form, and <a href="http://byatool.com/hosted/LiveDemos/jQueryValidation/SimpleRequired.html">I can do that for you.</a></p>
<p>So basically it's a simple form with one input that is required.</p>
<pre>jQuery(document).ready
    (
      <span style="color: #0000ff;">function</span>()
      {
        jQuery(<span style="color: #800000;">"#PrimaryForm"</span>).validate
        (
          {
            errorLabelContainer: <span style="color: #800000;">"#ErrorDiv"</span>,
            wrapper: <span style="color: #800000;">"div"</span>,
            rules:
            {
              FirstName :
              {
                required : <span style="color: #0000ff;">true</span>
              }
            },
            messages:
            {
              FirstName:
              {
                required : <span style="color: #800000;">'First Name is required.'</span>
              }
            },
            onfocusout : false,
            onkeyup: false,
            submitHandler: <span style="color: #0000ff;">function</span>(label)
            {
              postSubmit();
            }
          }
        );
      }</pre>
<pre>jQuery(<span style="color: #800000;">"#PrimaryForm"</span>).validate</pre>
<p>Real simple, just setting the validator to the primary form on the page.</p>
<pre> errorLabelContainer: <span style="color: #800000;">"#ErrorDiv"</span>,</pre>
<p>This sets the errors to show up in the ErrorDiv.  Now this is optional, as you can have it show the errors next to the FirstName text box but personally I think that looks horrible.  Setting up the ErrorDiv puts all the errors in one central location and allows for styling the actual div.</p>
<pre> rules:
 {
    FirstName :
    {
      required : <span style="color: #0000ff;">true</span>
    }
  },</pre>
<p>This matches an element with the id of FirstName to the required rule, meaning that FirstName is required.  Rocket science.</p>
<pre>  messages:
  {
    FirstName:
    {
       required : <span style="color: #800000;">'First Name is required.'</span>
    }
  },</pre>
<p>If you can't figure this out, I hear circus is hiring for the "World's Dumbest Person".  You'll fit in with Jub Jub the Dog Boy.</p>
<pre>  onfocusout : <span style="color: #0000ff;">false</span>,
  onkeyup: <span style="color: #0000ff;">false</span>,</pre>
<p>Basically this prevents the validation when leaving the textbox or on every key press.  This is just another preference.</p>
<pre>  submitHandler: <span style="color: #0000ff;">function</span>(label)
  {
    postSubmit();
  }</pre>
<p>If the submit is successful, call this method.</p>
<p><strong>But... BUT WHAT IF IT'S AN EMAIL?!??! WHAT WILL I DO???!?!?</strong></p>
<p>Well for one, stop being such a child.  <a href="http://byatool.com/hosted/LiveDemos/jQueryValidation/EmailRequired.html">And two, look here.</a></p>
<p>Some what different, as you can see it's now email and there is one extra requirement in the rules:</p>
<pre>  rules:
  {
    EmailAddress :
    {
      email : <span style="color: #0000ff;">true</span>,
      required : <span style="color: #0000ff;">true</span>
    }
  },
  messages:
  {
    EmailAddress:
    {
      required : <span style="color: #800000;">'Yo, email fool.'</span>,
      email : <span style="color: #800000;">'So not an email address.'</span>
    },
  },</pre>
<p>See?  It has nice built in rule for email.  Simple.</p>
<p><strong>BUT WHAT IF I NEED A REGULAR EXPRESSION?!??! WHAT WILL I DO???!?!?</strong></p>
<p>I swear if you don't stop that, I'm turning this post around and going home.</p>
<p><a href="http://byatool.com/hosted/LiveDemos/jQueryValidation/ZipCodeRequired.html">Fine here it is.</a></p>
<pre>  jQuery.validator.addMethod
  (
    <span style="color: #800000;">"isZipCode"</span>,
    <span style="color: #0000ff;">function</span>(value, element)
    {
      <span style="color: #0000ff;">return</span> value.match(<span style="color: #0000ff;">new</span> RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/));
    }
  );</pre>
<p>Just have to create a method and "add it" to the validator itself. And then there's the use:</p>
<pre>  rules:
  {
    ZipCode :
    {
      required : <span style="color: #0000ff;">true</span>,
      isZipCode : <span style="color: #0000ff;">true</span>
    }
  },
  messages:
  {
    ZipCode:
    {
      required : <span style="color: #800000;">'For the love of me, enter a zip code!.'</span>,
      isZipCode : <span style="color: #800000;">'Serioulsy?  Do you know what a zip code is?'</span>
    },
  },</pre>
<p>Woo hoo right?</p>
<p>Don't do it... Don't you yell.</p>
<p><strong>But what if one input depends on another?</strong></p>
<p>Much better.  Well that's not as hard as it may seem and <a href="http://byatool.com/hosted/LiveDemos/jQueryValidation/TwoRequired.html">here's the example</a>.</p>
<pre>  rules:
  {
    InputB :
    {
      required :
      {
        depends : <span style="color: #0000ff;">function</span>(element) { <span style="color: #0000ff;">return</span> jQuery(<span style="color: #800000;">'#InputA'</span>).val() != <span style="color: #800000;">""</span> }
      }
    }
  },</pre>
<p>As you can see, you can change how the required method works by adding in a depends handler.  Works out pretty well.</p>
<p>Yes I will show you how to make sure two inputs match.  <a href="http://byatool.com/hosted/LiveDemos/jQueryValidation/EqualTo.html">I swear you ask for a lot.</a></p>
<pre>  rules:
  {
    Password :
    {
      equalTo : <span style="color: #800000;">"#ConfirmPassword"
</span>    },
  },</pre>
<p>Couldn't be easier unless I wrote it out for you.  Wait, I did.</p>
<p>So here you've either learned a bit about jQuery validation or have just spent the last few minutes drooling uncontrollably. Either way, I'm done with this post and you're left to do whatever it is you do, you sick f---.</p>
<p>Side note:  I haven't actually been to <a href="http://www.htmlgoodies.com">Htmlgoodies</a> since eh college?  but wow did that place sell out.  How fitting that an introduction to html page now looks like it was designed by someone just starting out... in the 90s.</p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li><a href="http://byatool.com/lessons/child-iframe-page-interacting-with-parent-page-yeah-i-went-there/" title="Child IFrame Page Interacting with Parent Page&#8230; Yeah I went there.">Child IFrame Page Interacting with Parent Page&#8230; Yeah I went there.</a></li><li><a href="http://byatool.com/lessons/jquery-validation-adding-errors-to-the-error-containter-with-love/" title="jQuery Validation: Adding Errors to the Error Containter&#8230; With Love!">jQuery Validation: Adding Errors to the Error Containter&#8230; With Love!</a></li><li><a href="http://byatool.com/ui/556/" title="jQuery: Add a Pop Up Div to a Link Dynamically">jQuery: Add a Pop Up Div to a Link Dynamically</a></li><li><a href="http://byatool.com/ui/jquery-position-absolute-and-how-to-make-it-all-work/" title="JQuery, Position : Absolute, and How to Make It All Work">JQuery, Position : Absolute, and How to Make It All Work</a></li><li><a href="http://byatool.com/lessons/get-the-jquery-datepicker-to-work-with-jquery-modal-dialog/" title="Get the jQuery DatePicker to Work With jQuery Modal Dialog">Get the jQuery DatePicker to Work With jQuery Modal Dialog</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/lessons/jquery-validation-how-to-use-to-get-rid-of-even-the-toughest-stains/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Off Topic Sunday: Does Not Liking Quentin Tarantino Make Me  A Mutant?</title>
		<link>http://byatool.com/pointless/off-topic-sunday-does-not-liking-quentin-tarantino-make-me-a-mutant/</link>
		<comments>http://byatool.com/pointless/off-topic-sunday-does-not-liking-quentin-tarantino-make-me-a-mutant/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 16:17:23 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Pointless]]></category>
		<category><![CDATA[Off Topic]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=1095</guid>
		<description><![CDATA[COMPLETELY NOT PROGRAMMING RELATED

Any time I declare this I always get the same look people had when that one dude in Total Recall took off his glove and had that weird chicken wing arm thing.  I can't think of many directors that get the same free pass as he does for making, in my [...]]]></description>
			<content:encoded><![CDATA[<p><strong>COMPLETELY NOT PROGRAMMING RELATED<br />
</strong></p>
<p>Any time I declare this I always get the same look people had when that one dude in Total Recall took off his glove and had that weird chicken wing arm thing.  I can't think of many directors that get the same free pass as he does for making, in my crazy mutant opinion, two good movies: Pulp Fiction and that one part of Four Rooms with the Zippo lighter bet.  Ok so one movie and a section of another.  Maybe Kill Bill 2 could be in there.  Maybe.</p>
<p>Now I have to admit that I've been accused of having less than main stream opinions on movies.  I'm not one of those people that only like a movie if it's made on a 10k dollar budget and ends up just as depressing as it started.  (IE Every independent movie ever.) I enjoy movies that are thought provoking and relevant as questions like "What would green smell like?" or "Why do I have 10 ten toes?"  However, I liked Star Trek: The Motion Picture the most out of the six because I felt it was very Star Trek like and the most intense of the bunch.  I liked Alien 3 more than Aliens (Only after watching the Director's cut version though) because it had more thought out undertones.  I think that Kill Bill 2 is far more interesting than 1 because it had story minus a bunch of tools running around like they're athletic (See The Matrix).  I also still find Godzilla versus Mechagodzilla to be the best, even though Godzilla 2000 is far superior in ever aspect, because that one part where Gozilla and King Caesar are standing in front of and behind, respectively, Mechagodzilla and they think they have it flanked when it turns it's head around to look at King (With it's laser eyes) and swings out it's missle hands at Godzilla almost as if it was sayin, "You thought you got me, but I got missles b--ch.  You ain't got s--t. "</p>
<p>Three things you can take from that:  I probably don't line up with your tastes, I do have thought out excuses for my "condition", and I am a massive geek.  I honestly feel that at this point I need to boost a car, take some E, and bench press 800 pounds at the same time to offset the horrendous black hole of geek I just created that threatens to pull us all in to an alternate, more geeky version of the world.  No one wants that.  No one but <a href="http://dsc.discovery.com/fansites/mythbusters/mythbusters.html">Adam Savage</a> wants that.</p>
<p>At this point, you might see where I'm coming from.  I'm clinically insane.  However, that doesn't mean I'm not entitled to an opinion on Tarentino.  The guy is like a 12 year old with a budget.</p>
<p>Remember when you were 12, watching Power Rangers, sitting in a rocking chair, while lathering yourself in a mixture of peanut butter and motor oil?  Probably not (But if you do, call me) but you might remember watching a movie like Aliens and thinking "What if the aliens could talk?" or "What if the Aliens could use guns, that would be sweet cause they would be all like 'What up!' BLAM BLAM  'Screw you Marines!'" And let's be honest, there's a reason why you weren't making films at 12... or probably even now.  (Honestly?  Aliens using guns?  What the hell were you on at 12?)  Every time I see one of his movies now, that's all I can see:  Tarantino lathered up in pean... Wait...  I see Tarantino sitting around writing some movie, probably a masterpiece about a child who is taken from his family, forced into slavery, and then finds a way to unite the slaves against the slavers and bring peace to the his people.  Followed by weeks of "What if aliens some how helped him free his people?" and then  "What if the aliens give him awesome laser weapons and then there's a scene where he's all like 'I'm gonna make them pay' while standing on a mound of dead slavers and then he points the gun at one that's still sort of alive and shoots him and his head explodes and the aliens start dancing in joy! Oh man that'd be cool." (You might also call this the "Lucas effect")  Somewhere, at some point, the good ideas he may have go from a smooth riding train to a train that just lost a wheel, jumped the track, and is plowing through some childrens' hospital.</p>
<p>And guess maybe that's the problem I have with him.  It's clear that the guy is good with conversations and characters.  It's clear that he could be a premier writer.  It just seems like the 12 year old side of him takes over at some point.  Oh well, that 12 year old has done him well financially so who am I to say what's good?</p>
<p>In the end, it just comes down to preference.  Maybe I don't have the part of the mind that gets satisfaction from way over the top insanity in movie form (I think it's seated somewhere in between the part that enjoys chili cheese fries and the part that makes people stop and stare at highway accidents.), and if you do well more power to you.  Just don't judge me based on my thinking he's straight up overrated or that he isn't a god of filming.  Then again I'm not the kind of person who looks for religious overtones in the Star Wars series, so maybe I'm just too dumb to see the brilliance.</p>
<p>Oh and side note:  HE HAD NOTHING TO DO WITH HERO EXCEPT WITH HELPING WITH PUSHING UP THE TIME LINE OF THE US RELEASE.  Don't f--king even think he had any real hand in what's probably the best epic movie in existence.</p>
<p>Other Note:  Apparently resident "computer wiz" Andre refused to read more than the title of this post.  He's one of them... </p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li>No Related Posts</li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/pointless/off-topic-sunday-does-not-liking-quentin-tarantino-make-me-a-mutant/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Random Add-On &#8211; Automapper</title>
		<link>http://byatool.com/add-on/random-add-on-automapper/</link>
		<comments>http://byatool.com/add-on/random-add-on-automapper/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 16:23:16 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Add On]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=1071</guid>
		<description><![CDATA[So if you've bothered reading my posts in the past, and don't worry cause I haven't, you might have seen me express my rule about not wanting to use third party stuff. Well things change. Actually they don't, as I'm not bending the rule because I'm becoming a better person, just more lazy. This is [...]]]></description>
			<content:encoded><![CDATA[<p>So if you've bothered reading my posts in the past, and don't worry cause I haven't, you might have seen me express my rule about not wanting to use third party stuff. Well things change. Actually they don't, as I'm not bending the rule because I'm becoming a better person, just more lazy. This is where <span style="font-size:20px;font-weight:bold;"><a href="http://automapper.codeplex.com/">Automapper</a></span> comes in.</p>
<p><span style="font-size:20px;font-weight:bold;"><a href="http://automapper.codeplex.com/">Automapper</a></span> is pretty much what it sounds like, it maps class properties automatically. Maybe a more clevererest name would have been ClassPropertyAutoMapper, but the guys who made it shouldn't be persecuted for lacking creativity.</p>
<p>How simple is <span style="font-size:20px;font-weight:bold;"><a href="http://automapper.codeplex.com/">Automapper</a></span>? Simple enough that even you can use it. Now that's simple! Say you have two classes, a entity class and a model, and you want to map the model to the entity in the constructor. You could do:</p>
<pre>  <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> <span style="color: #008080;">SomeModel</span>
  {
    <span style="color: #0000ff;">public</span> SomeModel(<span style="color: #008080;">SomeEntity</span> someEntity)
   {
     SomeProperty = someEntity.SomeProperty;
   }
  }</pre>
<p>But where's the lazyiness? I expect so much less from you. But it's ok, salvation is right here:</p>
<pre>  <span style="color: #0000ff;">public</span> SomeModel(<span style="color: #008080;">SomeEntity</span> someEntity)
  {
    <span style="color: #008080;">Mapper</span>.CreateMap();
    <span style="color: #008080;">Mapper</span>.Map(someEntity, <span style="color: #0000ff;">this</span>);
  }</pre>
<p>But... but what if there are properties on SomeModel that don't directly map by name? Well, there's an ap...i for that. (Not sure that even makes sense but it was clever.)</p>
<pre>  <span style="color: #0000ff;">public</span> SomeModel(<span style="color: #008080;">SomeEntity</span> someEntity)
  {
    <span style="color: #008080;">Mapper</span>.CreateMap&lt;<span style="color: #008080;">FiftyPostUser</span>, <span style="color: #008080;">UserInfoViewModel</span>&gt;()
     .ForMember(test =&gt; test.Status, tester =&gt; tester.MapFrom(item =&gt; item.Status.ToString()));
    <span style="color: #008080;">Mapper</span>.Map(someEntity, <span style="color: #0000ff;">this</span>);
  }</pre>
<p>So I know you're thinking that there's a catch, well there is. You have to actually get the <a href="http://automapper.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=32994">dll and reference in your project</a>. I know! Work is hard. Why can't these guys just come to your place of work/home/mom's basement and do it for you? What kind of world is it when you can't get all that for free? Personally, I hate it.</p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li><a href="http://byatool.com/lessons/data-annotations-mvc-and-why-you-might-like-them/" title="Data Annotations, MVC, and Why You Might Like Them">Data Annotations, MVC, and Why You Might Like Them</a></li><li><a href="http://byatool.com/pointless/state-list-in-dictionary-form/" title="State List in Dictionary Form">State List in Dictionary Form</a></li><li><a href="http://byatool.com/pontification/entity-framework-possible-lazy-loading-solution/" title="Entity Framework: Possible Lazy Loading Solution">Entity Framework: Possible Lazy Loading Solution</a></li><li><a href="http://byatool.com/general-coding/by-reference-in-c-and-how-to-get-schooled-by-it/" title="By Reference in C# and How to Get Schooled By It">By Reference in C# and How to Get Schooled By It</a></li><li><a href="http://byatool.com/pontification/c-var-and-objec-propert-i-have-no-idea-what-the-term-is/" title="C#, Var, and Objec-  Propert-  I have no idea what the term is">C#, Var, and Objec-  Propert-  I have no idea what the term is</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/add-on/random-add-on-automapper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>State List in Dictionary Form</title>
		<link>http://byatool.com/pointless/state-list-in-dictionary-form/</link>
		<comments>http://byatool.com/pointless/state-list-in-dictionary-form/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 14:55:34 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Pointless]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Stupid]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=1077</guid>
		<description><![CDATA[Tired of having to look this up from time to time, so I'm putting this here for my own use.  If you get something out of it, good for you.  In the end, I really don't care.

    public Dictionary GetAllStates()
    {
      if(_stateList [...]]]></description>
			<content:encoded><![CDATA[<p>Tired of having to look this up from time to time, so I'm putting this here for my own use.  If you get something out of it, good for you.  In the end, I really don't care.</p>
<pre>
    public Dictionary<string, string> GetAllStates()
    {
      if(_stateList == null)
      {
        _stateList = new Dictionary<string, string>();

        _stateList.Add("Alabama","AL");
        _stateList.Add("Alaska","AK");
        _stateList.Add("American Samoa","AS");
        _stateList.Add("Arizona","AZ");
        _stateList.Add("Arkanas","AR");
        _stateList.Add("California","CA");
        _stateList.Add("Colorado","CO");
        _stateList.Add("Connecticut","CT");
        _stateList.Add("Delaware","DE");
        _stateList.Add("District Of Colombia","DC");
        _stateList.Add("Federated States Of Micronesia","FM");
        _stateList.Add("Florida","FL");
        _stateList.Add("Georgia","GA");
        _stateList.Add("Guam","GU");
        _stateList.Add("Hawaii","HI");
        _stateList.Add("Idaho","ID");
        _stateList.Add("Illinois","IL");
        _stateList.Add("Indiana","IN");
        _stateList.Add("Iowa","IA");
        _stateList.Add("Kansas","KS");
        _stateList.Add("Kentucky","KY");
        _stateList.Add("Lousiana","LA");
        _stateList.Add("Maine","ME");
        _stateList.Add("Marshall Islands","MH");
        _stateList.Add("Maryland","MD");
        _stateList.Add("Massachusetts","MA");
        _stateList.Add("Michigan","MI");
        _stateList.Add("Minnesota","MN");
        _stateList.Add("Mississippi","MS");
        _stateList.Add("Missouri","MO");
        _stateList.Add("Montana","MT");
        _stateList.Add("Nebraska","NE");
        _stateList.Add("Nevada","NV");
        _stateList.Add("New Hampshire","NH");
        _stateList.Add("New Jersey","NJ");
        _stateList.Add("New Mexico","NM");
        _stateList.Add("New York","NY");
        _stateList.Add("North Carolina","NC");
        _stateList.Add("North Dakota","ND");
        _stateList.Add("Northern Mariana Islands","MP");
        _stateList.Add("Ohio","OH");
        _stateList.Add("Oklahoma","OK");
        _stateList.Add("Oregon","OR");
        _stateList.Add("Palau","PW");
        _stateList.Add("Pennsylvania","PA");
        _stateList.Add("Puerto Rico","PR");
        _stateList.Add("Rhode Island","RI");
        _stateList.Add("South Carolina","SC");
        _stateList.Add("South  Dakota","SD");
        _stateList.Add("Tennessee","TN");
        _stateList.Add("Texas","TX");
        _stateList.Add("Utah","UT");
        _stateList.Add("Varmont","VT");
        _stateList.Add("Virgin Islands","VI");
        _stateList.Add("Virginia","VA");
        _stateList.Add("Washington","WA");
        _stateList.Add("West Virginia","WV");
        _stateList.Add("Wisconsin","WI");
        _stateList.Add("Wyoming","WY");
      }

      return _stateList;
    }
</pre>
<p>So there.  Hope you're happy.</p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li><a href="http://byatool.com/general-coding/by-reference-in-c-and-how-to-get-schooled-by-it/" title="By Reference in C# and How to Get Schooled By It">By Reference in C# and How to Get Schooled By It</a></li><li><a href="http://byatool.com/pontification/static-abstract-should-i-bother/" title="Static Abstract &#8230; should I bother?">Static Abstract &#8230; should I bother?</a></li><li><a href="http://byatool.com/utilities/quick-linq-thing-string-to-number-string/" title="Convert a String to a Number String With Linq&#8230; YAY">Convert a String to a Number String With Linq&#8230; YAY</a></li><li><a href="http://byatool.com/c/i-are-tupid/" title="I are tupid">I are tupid</a></li><li><a href="http://byatool.com/lessons/data-annotations-mvc-and-why-you-might-like-them/" title="Data Annotations, MVC, and Why You Might Like Them">Data Annotations, MVC, and Why You Might Like Them</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/pointless/state-list-in-dictionary-form/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Back, Back from the Dead&#8230; Again</title>
		<link>http://byatool.com/pointless/back-back-from-the-dead-again/</link>
		<comments>http://byatool.com/pointless/back-back-from-the-dead-again/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 12:36:26 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Pointless]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=1068</guid>
		<description><![CDATA[So Andre, the only person I know to argue with a toaster and lose, has mostly completed moving the site over to the new hosting.  Issues?  Well there are some lost comments.  It's sad, I know.  Your 15 minutes of fame just got washed away like sand on a body of [...]]]></description>
			<content:encoded><![CDATA[<p>So Andre, the only person I know to argue with a toaster and lose, has mostly completed moving the site over to the new hosting.  Issues?  Well there are some lost comments.  It's sad, I know.  Your 15 minutes of fame just got washed away like sand on a body of land that is within sufficient proximity of a body of water so that it is carried away if said body of water has the needed tide to carry it away.  I'd cry for you but I have no tear ducts.  </p>
<p>Going forward, you can feel confident that if you leave a comment it will exist until we change hosts and Andre has control of moving it again. </p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li>No Related Posts</li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/pointless/back-back-from-the-dead-again/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>.Net 4.0 Beta 2 Entity Framework &#8211; How To Set Up Complex Types, Now With More POCO</title>
		<link>http://byatool.com/lessons/net-4-0-beta-2-entity-framework-how-to-set-up-complex-types-now-with-more-poco/</link>
		<comments>http://byatool.com/lessons/net-4-0-beta-2-entity-framework-how-to-set-up-complex-types-now-with-more-poco/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 15:41:52 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Lessons]]></category>
		<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[Entity Framework]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=1043</guid>
		<description><![CDATA[So something I've seen but just have now conquered is the whole complex type thing in Entity Framework.  Not only that, but with the cool new Persistence Ignorance thing all the kids are talking about.  (And boy am I glad there's a new kind of ignorance on this site now.)  You might [...]]]></description>
			<content:encoded><![CDATA[<p>So something I've seen but just have now conquered is the whole complex type thing in Entity Framework.  Not only that, but with the cool new Persistence Ignorance thing all the kids are talking about.  (And boy am I glad there's a new kind of ignorance on this site now.)  You might ask:  What's a complex type?  Course you might ask:  Why is it so hard to make a decent movie about huge robots that transform into cool vehicles and have really big guns?  Well I can answer the first question.</p>
<p>Complex types, in the simple minded way I see them, are a way to split information retrieved from a table into a object within an object.  Confused yet?  I hope so.</p>
<p>Say you have a User table and on that table you have the typical user information including a bunch of stuff like Name, Sex, City, State, and Zip.  Now you could set up the user class to look like this:</p>
<pre>  <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> <span style="color: #008080;">User</span>
  {
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">String</span> Name { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">String</span> City { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">String</span> State { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">String</span> Zip { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
  }</pre>
<p>Nothing wrong with that, but what if you have an Address class:</p>
<pre>  <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> <span style="color: #008080;">Address</span>
  {
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">String</span> City { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">String</span> State { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">String</span> Zip { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
  }</pre>
<p>That you wanted to map the values from the User table to the User class to so that the User class looked more like this:</p>
<pre>  <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> <span style="color: #008080;">User</span>
  {
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">String</span> Name { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">Address</span> Address { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
  }</pre>
<p>Well I'm here to tell you that you can and I have plenty of pictures to back it up.</p>
<p>Keeping with the design <a href="http://byatool.com/index.php/lessons/net-4-0-beta-2-entity-framework-many-to-one-and-poco-insert-statement-conflicted-with-the-foreign-key-constraint-issue/">from this guy</a>, I am going to add a new class called AdDimension which will have Height and Width, effectively replacing the Height and Width properties on the Ad class.</p>
<p>RECAP - Old class diagram:</p>
<pre><img class="alignnone size-full wp-image-1054" title="AddAdtype" src="http://byatool.com/wp-content/uploads/2009/10/AddAdtype.png" alt="AddAdtype" width="421" height="528" /></pre>
<p>So the first thing I have to do is is create the complex type in the Model Browser.  That's pretty easy.  There's a section called "Complex Types" and you just add one.</p>
<pre><img class="alignnone size-full wp-image-1055" title="ComplexTypeAdd" src="http://byatool.com/wp-content/uploads/2009/10/ComplexTypeAdd.png" alt="ComplexTypeAdd" width="527" height="364" /></pre>
<p>See, there's a picture.  Next step is adding properties to the newly created complex type.</p>
<pre><img class="alignnone size-full wp-image-1062" title="ComplexTypePropertyAdd" src="http://byatool.com/wp-content/uploads/2009/10/ComplexTypePropertyAdd3.png" alt="ComplexTypePropertyAdd" width="537" height="494" /></pre>
<p>Another picture!  Ok so now you've created on, big deal.  Now what?  Well you have to add a complex type property to the main class, Ad in this case.</p>
<pre><img class="alignnone size-full wp-image-1065" title="ComplexTypeAddToEntity" src="http://byatool.com/wp-content/uploads/2009/10/ComplexTypeAddToEntity1.png" alt="ComplexTypeAddToEntity" width="643" height="525" /></pre>
<p>Now if you have more than one complex type, you might have to set the property type to the correct one.  Just right click the complex property and click on properties:</p>
<pre><img class="alignnone size-full wp-image-1063" title="ComplexTypePropertyProperties" src="http://byatool.com/wp-content/uploads/2009/10/ComplexTypePropertyProperties.png" alt="ComplexTypePropertyProperties" width="307" height="268" /></pre>
<p>Now, you'll have to adjust the mapping for the entity itself.  So click on the object and bring up mapping properties.  From there, select the correct mapping for the correct column.  In this example it's width and as you can see in the drop down there is a AdDimension.Width property to set it to.  Cool huh?</p>
<pre><img class="alignnone size-full wp-image-1059" title="ComplexTypeSetMapping" src="http://byatool.com/wp-content/uploads/2009/10/ComplexTypeSetMapping.png" alt="ComplexTypeSetMapping" width="800" height="195" /></pre>
<p>And that's it for the object model.  Next you have to add the AdDimension class and add a property to the Ad class.</p>
<pre>  <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> <span style="color: #008080;">AdDimension</span>
  {
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">Int32</span> Height { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">Int32</span> Width { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
  }</pre>
<pre>  <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> <span style="color: #008080;">Ad</span>
  {
    ...
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">AdDimension</span> <span style="color: #000000;">AdDimension</span> { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    ...
  }</pre>
<p>And then how do you set it?</p>
<pre>  someAd.AdDimension = <span style="color: #0000ff;">new</span> <span style="color: #008080;">AdDimension</span>();
  someAd.AdDimension.Height = 10;
  someAd.AdDimension.Width = 10;</pre>
<p>And it can even be used in queries:</p>
<pre>  context.Ads.Where(ad =&gt; ad.Width &gt; 10);</pre>
<p>Now there are things to be aware of.  Complex types can't inherit from other complex types and the property can't be null when saving.  Just be aware of that.</p>
<p>I'm telling you man, this s-- is the s--- man.  It's the s---.</p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li><a href="http://byatool.com/lessons/net-4-0-beta-2-entity-framework-many-to-one-and-poco-insert-statement-conflicted-with-the-foreign-key-constraint-issue/" title=".Net 4.0 Beta 2 Entity Framework &#8211; Many To One and POCO / INSERT statement conflicted with the FOREIGN KEY constraint issue">.Net 4.0 Beta 2 Entity Framework &#8211; Many To One and POCO / INSERT statement conflicted with the FOREIGN KEY constraint issue</a></li><li><a href="http://byatool.com/lessons/net-4-0-beta-2-entity-framework-how-to-start/" title=".Net 4.0 Beta 2 Entity Framework &#8211; How To Start">.Net 4.0 Beta 2 Entity Framework &#8211; How To Start</a></li><li><a href="http://byatool.com/pontification/entity-framework-am-i-just-being-stubborn/" title="Entity Framework:  Am I Just Being Stubborn?">Entity Framework:  Am I Just Being Stubborn?</a></li><li><a href="http://byatool.com/net-issues/entity-framework-linq-to-entities-only-supports-casting-entity-data-model-primitive-types/" title="Entity Framework: LINQ to Entities only supports casting Entity Data Model primitive types">Entity Framework: LINQ to Entities only supports casting Entity Data Model primitive types</a></li><li><a href="http://byatool.com/c/entity-framework-reusable-paging-method/" title="Entity Framework: Reusable Paging Method">Entity Framework: Reusable Paging Method</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/lessons/net-4-0-beta-2-entity-framework-how-to-set-up-complex-types-now-with-more-poco/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.Net 4.0 Beta 2 Entity Framework &#8211; Many To One and POCO / INSERT statement conflicted with the FOREIGN KEY constraint issue</title>
		<link>http://byatool.com/lessons/net-4-0-beta-2-entity-framework-many-to-one-and-poco-insert-statement-conflicted-with-the-foreign-key-constraint-issue/</link>
		<comments>http://byatool.com/lessons/net-4-0-beta-2-entity-framework-many-to-one-and-poco-insert-statement-conflicted-with-the-foreign-key-constraint-issue/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 17:34:08 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Lessons]]></category>
		<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[Entity Framework]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=1036</guid>
		<description><![CDATA[So the next step in the New Entity Framework saga was to make a many to one relationship and get it to save. After all, with the last version I had far more issues with many to one than any other kind of relationship. Turns out, the steak is still in tact.
Taking the structure from [...]]]></description>
			<content:encoded><![CDATA[<p>So the next step in the New Entity Framework saga was to make a many to one relationship and get it to save. After all, with the last version I had far more issues with many to one than any other kind of relationship. Turns out, the steak is still in tact.</p>
<p><a href="http://byatool.com/index.php/lessons/net-4-0-beta-2-entity-framework-how-to-start/">Taking the structure from the last post</a>, I added an AdType. It's very simple. Columns are AdTypeId (Int Primary) and Description (Varchar). I added a AdTypeId column to the Ad table and created a foreign key to the AdType table with it.</p>
<p>Basically Many Ads to One AdType.</p>
<p>Then I did the usual Update Model From Database with the .edmx file. Same old same old. Well this added the AdType class and the relationship:</p>
<pre><img class="alignnone size-full wp-image-1054" title="AddAdtype" src="http://byatool.com/wp-content/uploads/2009/10/AddAdtype.png" alt="AddAdtype" width="421" height="528" /></pre>
<p>So far, so good. Now with this it also means that I need to create the AdType class and add the AdType property to the Ad class along with the AdTypeId property.</p>
<blockquote><p>Side Note:</p>
<p>Far as I can tell, you need the AdTypeId property despite also having the AdType property. Don't forget this.</p></blockquote>
<p>Here's the AdType class:</p>
<pre>  <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> <span style="color: #008080;">AdType
</span>  {
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">Int32</span> Id { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">String</span> Description { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }

    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">virtual</span> <span style="color: #008080;">IList</span>&lt;<span style="color: #008080;">Ad</span>&gt; Ads { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
  }</pre>
<p>And on the Ad class I had to "Ad" (HARHRHARHR) the AdType property along with the AdTypeId property:</p>
<pre>  <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> <span style="color: #008080;">Ad</span>
  {
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">Int32</span> Id { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">DateTime</span> CreatedDate { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">String</span> Name { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">DateTime</span>? LastUpdated { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">Int32</span> Height { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">Int32</span> Width { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }

    <span style="color: #008000;">//Interesting note: Works even if this is private and non virtual</span>
    <span style="color: #0000ff;">private</span> <span style="color: #008080;">Int32</span> AdTypeId { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }

    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">virtual</span> <span style="color: #008080;">AdType</span> AdType { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    <span style="color: #008000;">//Note:</span>
    <span style="color: #008000;">//If properties are to be lazy loaded, must be virtual</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">virtual</span> <span style="color: #008080;">IList</span>&lt;<span style="color: #008080;">Newpaper</span>&gt; Newspapers { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
  }</pre>
<p>Classes are done. Should be good to go right? WRONG YOU ARE SO F-ING WRONG! Just try this, I dare you:</p>
<pre>   <span style="color: #008080;">Ad</span> ad = <span style="color: #0000ff;">new</span> <span style="color: #008080;">Ad</span>();

   ...
   ad.AdType = someAdType();
   context.Ads.Add(ad);
   context.SaveChanges();</pre>
<p><strong>DUN DUN DUUUUN INSERT statement conflicted with the FOREIGN KEY constraint.</strong></p>
<p>You try it? Idiot. You just got stuffed by a foreign key error. Why? <a href="http://blogs.msdn.com/adonet/archive/2009/06/10/poco-in-the-entity-framework-part-3-change-tracking-with-poco.aspx">Well The Big M has an answer:</a></p>
<blockquote><p>In this example, Customer is a pure POCO type. Unlike with EntityObject or IPOCO based entities, making changes to the entity doesn't automatically keep the state manager in sync because there is no automatic notification between your pure POCO entities and the Entity Framework. Therefore, upon querying the state manager, it thinks that the customer object state is Unchanged even though we have explicitly made a change to one of the properties on the entity.</p></blockquote>
<p>Basically because these objects aren't really being watched by the State Manager, it has no idea anything has changed and should be persisted. Therefore, it has no idea that the AdType property has changed and that the AdTypeId should be updated to reflect this. That's right, it just ignored the AdType property and left the AdTypeId to it's default... 0 (That's a Zero or as the English say, Zed).  How do you get around this? <a href="http://msdn.microsoft.com/en-us/library/system.data.objects.saveoptions(VS.100).aspx">This little option.</a></p>
<pre>  context.SaveChanges(System.Data.Objects.SaveOptions.AcceptAllChangesAfterSave);</pre>
<p>This tells it to persist the changes that it didn't know about.  Now I'm still picking this up as I go so bare with me as I might have the best explanations yet on why things work with the New Entity Framework.  Then again, this is a site by a tool.</p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li><a href="http://byatool.com/lessons/net-4-0-beta-2-entity-framework-how-to-set-up-complex-types-now-with-more-poco/" title=".Net 4.0 Beta 2 Entity Framework &#8211; How To Set Up Complex Types, Now With More POCO">.Net 4.0 Beta 2 Entity Framework &#8211; How To Set Up Complex Types, Now With More POCO</a></li><li><a href="http://byatool.com/lessons/net-4-0-beta-2-entity-framework-how-to-start/" title=".Net 4.0 Beta 2 Entity Framework &#8211; How To Start">.Net 4.0 Beta 2 Entity Framework &#8211; How To Start</a></li><li><a href="http://byatool.com/pontification/entity-framework-am-i-just-being-stubborn/" title="Entity Framework:  Am I Just Being Stubborn?">Entity Framework:  Am I Just Being Stubborn?</a></li><li><a href="http://byatool.com/net-issues/entity-framework-linq-to-entities-only-supports-casting-entity-data-model-primitive-types/" title="Entity Framework: LINQ to Entities only supports casting Entity Data Model primitive types">Entity Framework: LINQ to Entities only supports casting Entity Data Model primitive types</a></li><li><a href="http://byatool.com/c/entity-framework-reusable-paging-method/" title="Entity Framework: Reusable Paging Method">Entity Framework: Reusable Paging Method</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/lessons/net-4-0-beta-2-entity-framework-many-to-one-and-poco-insert-statement-conflicted-with-the-foreign-key-constraint-issue/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Sql 2008 &#8211; You have either made changes to a table that can&#8217;t be re-created or enabled the option Prevent saving changes that require the table to be re-created</title>
		<link>http://byatool.com/sql-issue/sql-2008-you-have-either-made-changes-to-a-table-that-cant-be-re-created-or-enabled-the-option-prevent-saving-changes-that-require-the-table-to-be-re-created/</link>
		<comments>http://byatool.com/sql-issue/sql-2008-you-have-either-made-changes-to-a-table-that-cant-be-re-created-or-enabled-the-option-prevent-saving-changes-that-require-the-table-to-be-re-created/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 13:40:23 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Sql Issue]]></category>
		<category><![CDATA[Sql 2008]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=1031</guid>
		<description><![CDATA[If you've run into this issue:
Saving changes is not permitted. The changes that you have made require the following tables to be dropped and re-created. You have either made changes to a table that can't be re-created or enabled the option Prevent saving changes that require the table to be re-created.
Normally I don't like copy/paste [...]]]></description>
			<content:encoded><![CDATA[<p>If you've run into this issue:</p>
<blockquote><p>Saving changes is not permitted. The changes that you have made require the following tables to be dropped and re-created. You have either made changes to a table that can't be re-created or enabled the option Prevent saving changes that require the table to be re-created.</p></blockquote>
<p>Normally I don't like copy/paste solutions but I also can't stand wading through Microsoft issue explanations. This is how you fix it in quick picture form:</p>
<pre><img src="http://www.iamwebproject.com/PhotoView/Photo/ShowPhoto/15" alt="Here it is." /></pre>
<p>Tools -&gt; Options -&gt; Designers</p>
<p><a href="http://support.microsoft.com/kb/956176">The worded Solution is from here.</a></p>
<p>While trying to save changes to a table, it's because you've done this:</p>
<ul>
<li>You change the Allow Nulls setting for a column.</li>
<li>You reorder columns in the table.</li>
<li>You change the column data type.</li>
<li>You add a new column.</li>
</ul>
<p>And there it is folks, simple and done with.</p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li>No Related Posts</li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/sql-issue/sql-2008-you-have-either-made-changes-to-a-table-that-cant-be-re-created-or-enabled-the-option-prevent-saving-changes-that-require-the-table-to-be-re-created/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.Net 4.0 Beta 2 Entity Framework &#8211; How To Start</title>
		<link>http://byatool.com/lessons/net-4-0-beta-2-entity-framework-how-to-start/</link>
		<comments>http://byatool.com/lessons/net-4-0-beta-2-entity-framework-how-to-start/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 20:41:19 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Lessons]]></category>
		<category><![CDATA[4.0]]></category>
		<category><![CDATA[Entity Framework]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=1017</guid>
		<description><![CDATA[So I just recently turned my laptop into a 4.0 workstation since it is kind of expendable and I won't feel inclined to nerd rage if it gets tooled. With this step forward, I decided that I probably won't be doing much with the old Entity Framework version since the new one is supposed to [...]]]></description>
			<content:encoded><![CDATA[<p>So I just recently turned my laptop into a 4.0 workstation since it is kind of expendable and I won't feel inclined to nerd rage if it gets tooled. With this step forward, I decided that I probably won't be doing much with the old Entity Framework version since the new one is supposed to be the end all/be all until the next end all/be all version comes out. What does this mean for you? This post could be filled with useful information or f--- all. Just depends on what you care about.</p>
<p>After doing a little reading, and by little I mean as little as humanly possible while still having an idea of what I'm doing, I got the new EF to persist an object. Mind you, it took a bit of patience followed by slamming my head into my desk and then more patience, but I did it.</p>
<p>First off, the actual creating of the edmx file is the same, there's really no difference. You still go through the wizard, you still go through the connection set up, and you still grab the tables you want. No change there.</p>
<p>However, once you have it created, click on the .edmx file in your solution explorer, right click, then click properties. You'll see something like this:</p>
<pre><img class="alignnone size-full wp-image-1021" title="BAT - EntityFramework_RemoveCustomTool" src="http://byatool.com/wp-content/uploads/2009/10/BAT-EntityFramework_RemoveCustomTool.png" alt="BAT - EntityFramework_RemoveCustomTool" width="380" height="355" /></pre>
<p>You can see where there is nothing in the Custom Tool area of properties. That's because I deleted the text. That's the first part of what you need to do. Next is creating the needed classes. For this example I have two, Ad and Newspaper:</p>
<pre><span style="color: #0000ff;">namespace</span> Beta2Test.Data.Entity
{
  <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> <span style="color: #008080;">Ad</span>
  {
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">Int32</span> Id { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">DateTime</span> CreatedDate { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">String</span> Name { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">DateTime</span>? LastUpdated { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">Int32</span> Height { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">Int32</span> Width { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }

    <span style="color: #008000;">//Note:</span>
    <span style="color: #008000;">//If properties are to be lazy loaded, must be virtual</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">virtual</span> <span style="color: #008080;">IList</span>&lt;<span style="color: #008080;">Newspaper</span>&gt; Newspapers { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
  }
}</pre>
<p>and</p>
<pre><span style="color: #0000ff;">namespace</span> Beta2Test.Data.Entity
{
  <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> <span style="color: #008080;">Newspaper</span>
  {
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">Int32</span> Id { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">Int32</span> Circulation { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">DateTime</span> CreatedDate { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">DateTime</span> LastUpdated { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">String</span> Name { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }

    <span style="color: #008000;">//Note:
</span>    <span style="color: #008000;">//If properties are to be lazy loaded, must be virtual</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">virtual</span> <span style="color: #008080;">IList</span>&lt;<span style="color: #008080;">Ad</span>&gt; Ads { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
  }
}</pre>
<p>Three things you might notice:</p>
<ol>
<li>The classes don't inherit from anything. Yay</li>
<li>The namespace is Beta2Test.Data.Entity. Fact is, I left it there to show that the namespace can now be anything. Yay</li>
<li>Both collection properties are virtual. This is a must when dealing with collections that represent a relationship and you have lazy loading enabled (See below context class). For this, there is a many to many relationship between Ads and Newpapers. The Ads and Newspapers collection represent that. Why do that have to be virtual? Has to do with Entity Framework needing a way to override the properties so it can tell when they are accessed. (Read: Lazy Loading)</li>
<li>There is no fourth thing. You are wrong if you think there is.</li>
</ol>
<p>So far so good, but what about that like whole linking to that persistence layer stuff. You know like them entity objects yo.</p>
<p>Thank you for that poorly worded inquiry, but valid none the less. Remember those entity context classes that it used to generate for you? Well that whole "custom tool" dohickey I removed would have built it for me. However, that's not the path we're going down anymore. It's now time to brave the unknown. We, yes we, will build the context. Yes the context.</p>
<pre><span style="color: #0000ff;">using</span> System.Data.Objects;
<span style="color: #0000ff;">using</span> Beta2Test.Data.Entity;

<span style="color: #0000ff;">namespace</span> Beta2Test.Data
{
  <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> <span style="color: #008080;">Beta2TestContext</span> : <span style="color: #008080;">ObjectContext</span>
  {
    <span style="color: #0000ff;">private</span> <span style="color: #008080;">ObjectSet</span>&lt;<span style="color: #008080;">Ad</span>&gt; _ads;
    <span style="color: #0000ff;">private</span> <span style="color: #008080;">ObjectSet</span>&lt;<span style="color: #008080;">Newspaper</span>&gt; _newspapers;

    <span style="color: #0000ff;">public</span> <span style="color: #008080;">Beta2TestContext</span>() : <span style="color: #0000ff;">base</span>(<span style="color: #800000;">"name=InterviewDemoEntities"</span>, <span style="color: #800000;">"InterviewDemoEntities"</span>)
    {
      _ads = <span style="color: #008080;">CreateObjectSet</span>&lt;<span style="color: #008080;">Ad</span>&gt;();
      _newspapers = <span style="color: #008080;">CreateObjectSet</span>&lt;<span style="color: #008080;">Newspaper</span>&gt;();

      <span style="color: #008000;">//This makes sure the context lazy loads by default</span>
      ContextOptions.LazyLoadingEnabled = <span style="color: #0000ff;">true</span>;
    }

    <span style="color: #008000;">///
</span>    <span style="color: #008000;">/// This is used to set up the "queryable" collection.</span>
    <span style="color: #008000;">///</span>
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">ObjectSet</span>&lt;<span style="color: #008080;">Ad</span>&gt; Ads
    {
      <span style="color: #0000ff;">get</span>
      {
        <span style="color: #0000ff;">return</span> _ads;
      }
    }

    <span style="color: #0000ff;">public</span> <span style="color: #008080;">ObjectSet</span>&lt;<span style="color: #008080;">Newspaper</span>&gt; Newspapers
    {
      <span style="color: #0000ff;">get</span>
      {
        <span style="color: #0000ff;">return</span> _newspapers;
      }
    }

    <span style="color: #008000;">///</span>
    <span style="color: #008000;">/// This creates an ad that allows it "to be used with the Entity Framework."</span>
    <span style="color: #008000;">///</span>
    <span style="color: #008000;">///</span>
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">Ad</span> CreateAttachedAd()
    {
      <span style="color: #0000ff;">return</span> <span style="color: #008080;">EntityContext</span>.Context.CreateObject&lt;<span style="color: #008080;">Ad</span>&gt;();
    }

    <span style="color: #0000ff;">public</span> <span style="color: #008080;">Newspaper</span> CreateAttachedNewspaper()
    {
      <span style="color: #0000ff;">return</span> <span style="color: #008080;">EntityContext</span>.Context.CreateObject&lt;<span style="color: #008080;">Newspaper</span>&gt;();
    }
  }
}</pre>
<p>The CreateAttached methods aren't needed on the Context class itself, I just put them there. They could go on the Ad/Newspaper class but at this point I'm not sure if that blurs the lines or not. Haven't gotten into best practices mode yet.</p>
<p>You may notice the ObjectSet collections on the context. These are the collections you will query to get items most likely, much like the old context class from the last version:</p>
<pre>Context.Ads.Where(ad =&gt; ad.Id == 1)</pre>
<p>Pretty nice, huh?</p>
<p>Also, I noted above about the virtual properties on the Ad/Newspaper classes and how it had to do with lazy loading.</p>
<pre>ContextOptions.LazyLoadingEnabled = <span style="color: #0000ff;">true</span>;</pre>
<p>That line and the virtual properties ensure that lazy loading will occur when the property is used. Both have to be used together. Now you don't have to put that line in the constructor if you do create a context every time you are retrieving things, you could just set it on a case by case basis. Up to you. I use a <a href="http://byatool.com/index.php/pontification/singleton-objectcontext-the-remix/">singleton like context</a> so I just set it true in the constructor and don't worry about it.</p>
<p>The main thing I had trouble with was this line:</p>
<pre><span style="color: #0000ff;">public</span> <span style="color: #008080;">Beta2TestContext</span>() : <span style="color: #0000ff;">base</span>(<span style="color: #800000;">"name=InterviewDemoEntities"</span>, <span style="color: #800000;">"InterviewDemoEntities"</span>)</pre>
<p>Because I wasn't sure what the second string should be. First one is easy, it's whatever the key in the config file for the connection string. Second, chances are, is the same depending on how you set it all up in the wizard. I think it's the same name when you right click on the opened .edmx file and view properties. There should be a property named "Entity Container Name".</p>
<p>Here's a method I used for testing to create an Ad:</p>
<pre>  <span style="color: #0000ff;">public</span> <span style="color: #008080;">Ad</span> CreateAd(<span style="color: #008080;">Boolean</span> persist)
  {
    <span style="color: #008080;">Ad</span> ad = <span style="color: #0000ff;">null</span>;

    <span style="color: #0000ff;">if</span> (persist)
    {
      ad = <span style="color: #008080;">EntityContext</span>.Context.CreateAttachedAd();  <span style="color: #008000;">//This is the CreateAttachedAd method above in use
</span>    }
    <span style="color: #0000ff;">else
</span>    {
      ad = <span style="color: #0000ff;">new</span> <span style="color: #008080;">Ad</span>();
    }

    ad.CreatedDate = <span style="color: #008080;">DateTime</span>.UtcNow;
    ad.Height = <span style="color: #008080;">RandomTool</span>.RandomInt32(0, 10);
    ad.LastUpdated = <span style="color: #008080;">DateTime</span>.UtcNow;
    ad.Name = <span style="color: #008080;">RandomTool</span>.RandomString(10);
    ad.Width = <span style="color: #008080;">RandomTool</span>.RandomInt32(0, 10);

    <span style="color: #0000ff;">if</span> (persist)
    {
      AddEntityForRemoval(ad);  <span style="color: #008000;">//Ignore, for persistence removal after testing is completed</span>
      <span style="color: #008080;">EntityContext</span>.Context.Ads.AddObject(ad);  <span style="color: #008000;">//Ad the ... ad to the context</span>
      <span style="color: #008080;">EntityContext</span>.Context.SaveChanges();  <span style="color: #008000;">//Persist</span>
    }

    <span style="color: #0000ff;">return</span> ad;
  }</pre>
<p>There are some things you can ignore because I didn't feel like removing code. As you can see though, it's not very complicated. Use the CreateAttachedAd, fill in the properties, ad to the Ad collection on the context, and save.</p>
<p><strong>The End</strong></p>
<p>Sure you had to do more work than in the earlier version of Entity Framework, but on the other hand I have a fully detached class that can inherit from any class I WANT it to as opposed to the EntityObject class. Not to mention I now have an easy way to do lazy loading. Far cleaner than the <a href="http://byatool.com/index.php/pontification/entity-framework-possible-lazy-loading-solution/">old way I did it</a>. The other interesting thing to note, and this may not be a big deal to anyone else, but above I have a note about this:</p>
<pre>  AddEntityForRemoval(ad);  <span style="color: #008000;">//Ignore, for persistence removal after testing is completed</span></pre>
<p>This method just adds the object to a collection of EntityObjects that later I use to delete the object from the database on test cleanup. After moving to this version of EF, I had to change it to a collection of Objects. Interesting thing is:</p>
<pre>  <span style="color: #008080;">EntityContext</span>.Context.DeleteObject(currentObject);</pre>
<p>Didn't care. It still knew that the object was attached to the context somehow, despite the CLASS not being an EntityObject. Just an odd note.</p>
<p>Two Errors I came across:</p>
<blockquote><p>System.InvalidOperationException: Mapping and metadata information could not be found for EntityType 'Beta2Test.Data.Ad'.</p></blockquote>
<p>If you get this, there is a really good chance you screwed up a property name or are missing it completely. If the property name doesn't exactly match one in the .edmx class designer template, you're screwed. If you don't have it on the class but it's on the class designer template, you're screwed. If you add it to the class designer template, it has to be on the class as far as I can tell. Now, it doesn't have to be public. I have tested it as private and it works just fine.</p>
<blockquote><p>The required property 'Newspapers' does not exist on the type 'Beta2Test.Data.Ad'.</p></blockquote>
<p>This most likely happens if you didn't remember to make it a property:</p>
<pre><span style="color: #0000ff;">public</span> <span style="color: #008080;">IList</span>&lt;<span style="color: #008080;">Newpaper</span>&gt; Newpapers;  <span style="color: #008000;">//Forgot the { get; set; }</span></pre>
<pre><span style="color: #0000ff;">public</span> <span style="color: #008080;">IList</span>&lt;<span style="color: #008080;">Newpaper</span>&gt; Newpapers { get; set; };  <span style="color: #008000;">//Forgot the Virtual</span></pre>
<p>Opps.</p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li><a href="http://byatool.com/lessons/net-4-0-beta-2-entity-framework-how-to-set-up-complex-types-now-with-more-poco/" title=".Net 4.0 Beta 2 Entity Framework &#8211; How To Set Up Complex Types, Now With More POCO">.Net 4.0 Beta 2 Entity Framework &#8211; How To Set Up Complex Types, Now With More POCO</a></li><li><a href="http://byatool.com/lessons/net-4-0-beta-2-entity-framework-many-to-one-and-poco-insert-statement-conflicted-with-the-foreign-key-constraint-issue/" title=".Net 4.0 Beta 2 Entity Framework &#8211; Many To One and POCO / INSERT statement conflicted with the FOREIGN KEY constraint issue">.Net 4.0 Beta 2 Entity Framework &#8211; Many To One and POCO / INSERT statement conflicted with the FOREIGN KEY constraint issue</a></li><li><a href="http://byatool.com/pontification/entity-framework-am-i-just-being-stubborn/" title="Entity Framework:  Am I Just Being Stubborn?">Entity Framework:  Am I Just Being Stubborn?</a></li><li><a href="http://byatool.com/net-issues/entity-framework-linq-to-entities-only-supports-casting-entity-data-model-primitive-types/" title="Entity Framework: LINQ to Entities only supports casting Entity Data Model primitive types">Entity Framework: LINQ to Entities only supports casting Entity Data Model primitive types</a></li><li><a href="http://byatool.com/c/entity-framework-reusable-paging-method/" title="Entity Framework: Reusable Paging Method">Entity Framework: Reusable Paging Method</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/lessons/net-4-0-beta-2-entity-framework-how-to-start/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.Net MVC:  Quick Overview of Controller Structure</title>
		<link>http://byatool.com/pontification/asp-net-mvc-quick-overview-of-controller-structure/</link>
		<comments>http://byatool.com/pontification/asp-net-mvc-quick-overview-of-controller-structure/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 16:37:47 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Pontification]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[MVC]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=1012</guid>
		<description><![CDATA[Wow, that's a mouthful far as titles go, but couldn't think of a better way to say it.  Now what I'm about to go through is the "system" I have found that works pretty well when it comes to structuring controllers knowing that there will be asynchronous operations.  Why is that a big [...]]]></description>
			<content:encoded><![CDATA[<p>Wow, that's a mouthful far as titles go, but couldn't think of a better way to say it.  Now what I'm about to go through is the "system" I have found that works pretty well when it comes to structuring controllers knowing that there will be asynchronous operations.  Why is that a big deal?  Well where you put certain methods can depend on which controller actually owns the action.</p>
<p>When I started using MVC, I had some issues on figuring out how to build controllers so that they made sense from a structural point of view.  <a href="http://byatool.com/index.php/pontification/what-i-hate-about-programming/">I slightly touched on it</a> but I wanted to show where I progressed to in the vain hope that I can help prevent stumbling on your part.</p>
<p>One thing to be noted is the asynchronous part.  I've become a firm believer that MVC is pointless without asynchronous operations.  Why?  Simply put, you can use them or you can come up with some annoying post and redirect for any create, update, or delete operations.  If you're going to do that, you might as well just be institutionalized because you are one masochistic mother f---er.  For everyone else in the happy world, go with something like jQuery that makes it real easy to perform said operations.</p>
<p>With the last paragraph in mind, the part I had trouble with the most was figuring out where the actions go.  You see, when I started using MVC, I grouped stuff in an ultra simple manor.  Say I have a site for handling pictures.  Well there would be a view controller that would have anything to do with viewing images and an admin controller that took care of the uploading, changing, deleting, ecting.  As you can imagine, this was not what you might call ideal.</p>
<p>Once I got a feeling for MVC and how it worked, I started having things a little more separated but still didn't feel right.  I had actions for viewing a list of images on the image controller no matter if public or admin side which wasn't really ideal to me since it kind of blurred what was public and what was restricted from a conceptual point of view.  </p>
<p>It wasn't until I started thinking in terms of unit testing that it started to make more sense.  If I were creating controllers as if they were classes instead of pages like with WebForms, maybe it would work out better.  Seems real profound right?  Well it was at the time since I still had WebForms state of mind.  All of a sudden, it made way more sense on how the controllers should be set up.  In an odd way, the controllers almost became almost business layer like.  If I wanted to update an Image, there would be an Update method on the image controller responsible for taking in the changes, validating, and dealing with the entity objects.  Everything that had to do strictly with displaying information would be handled by a display controller like the before mentioned Admin controller.  So something like:</p>
<pre>
<img src="http://www.iamwebproject.com/PhotoView/Photo/ShowPhoto/14" alt="Controller Outline" />
</pre>
<p>As you can see, the Admin controller has something to show all users.  The User controller has the methods for things like updating, creating, and validation.  Basically anything that would change an image is on one controller.  Anything for showing it on the main section controller.  That is, a controller that embodies an overall concept like say an Admin section of a site or possibly a controller for viewing galleries.  </p>
<p>The sequence of events (bad word choice...) would be something like:</p>
<p>Open Admin/UserList/<br />
Admin controller uses User Entity to retrieve list<br />
Admin View shows User List<br />
User clicks delete button/link on Admin View<br />
Javascript/jQuery method invoked to send id to User/Delete<br />
User controller receives id<br />
User controller validates id to make sure it is valid<br />
User controller validates current user to see if allowed to delete<br />
User entity Delete method invoked by User Controller<br />
Result of Delete Method is returned by User Controller (JSon preferably)<br />
Admin View displays the result</p>
<p>Treating controllers like classes (and the use of anonymous actions) allows a very clean separation of actions resulting in a nice logical layout.  Beyond this, it also allows for a greater separation between controllers which means its possible to do multiple parts of the entire project in parallel.</p>
<p>Maybe this is just stating the obvious, something I'm pretty good at, but my hope was to give a quick over view of laying out controllers for those who are just starting out.</p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li><a href="http://byatool.com/pontification/aspnet-mvc-is-the-use-of-jquery-asynchronous-calls-a-must/" title="ASP.Net MVC:  Is the Use of jQuery/Asynchronous calls a Must?">ASP.Net MVC:  Is the Use of jQuery/Asynchronous calls a Must?</a></li><li><a href="http://byatool.com/pontification/are-jquery-and-asynchronous-calls-against-mvc/" title="Are jQuery and Asynchronous Calls against MVC?">Are jQuery and Asynchronous Calls against MVC?</a></li><li><a href="http://byatool.com/lessons/child-iframe-page-interacting-with-parent-page-yeah-i-went-there/" title="Child IFrame Page Interacting with Parent Page&#8230; Yeah I went there.">Child IFrame Page Interacting with Parent Page&#8230; Yeah I went there.</a></li><li><a href="http://byatool.com/lessons/get-the-jquery-datepicker-to-work-with-jquery-modal-dialog/" title="Get the jQuery DatePicker to Work With jQuery Modal Dialog">Get the jQuery DatePicker to Work With jQuery Modal Dialog</a></li><li><a href="http://byatool.com/ui/jquery-modal-dialog-hide-that-stupid-x-button-windows-close-button/" title="jQuery Modal Dialog : Hide That Stupid X Button / Windows Close Button">jQuery Modal Dialog : Hide That Stupid X Button / Windows Close Button</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/pontification/asp-net-mvc-quick-overview-of-controller-structure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Do It Yourself</title>
		<link>http://byatool.com/pontification/do-it-yourself/</link>
		<comments>http://byatool.com/pontification/do-it-yourself/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 13:12:48 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Pontification]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=983</guid>
		<description><![CDATA[A question came up about an earlier post on how I construct my grids shown in a few examples.



Now as you can see, it looks like a table, acts like a table, so it must be a table right?  Well it isn't.  It's actually done with divs and styles, something I've worked hard [...]]]></description>
			<content:encoded><![CDATA[<p>A question came up about an earlier post on how I construct my grids shown in a few examples.</p>
<pre>
<img src="http://www.iamwebproject.com/PhotoView/Photo/ShowPhoto/13"></img>
</pre>
<p>Now as you can see, it looks like a table, acts like a table, so it must be a table right?  Well it isn't.  It's actually done with divs and styles, something I've worked hard on getting right since moving to MVC.  </p>
<p>I'm not bagging on the question asked because I'm probably a mutant and the only person that thinks the way I do (and have written below).  I just have a philosophy that if you can do it yourself, do it yourself.</p>
<p>For starters, I'm not against new stuff, I think that's pretty obvious.  I'm also not completely against third party stuff seeing as a lot of my newer posts deal with jQuery.  I do, however, avoid third party tools I don't need, namely grid builders or things of that nature.  I figure that if I can do it myself, I'll do it myself.  This kind of hits on the debate of using Visual Studios's drag and drop feature for designing pages or not.  Sure it's easy and for the most part works, but you are really doing yourself a disservice.  Why?  Because most of the time you can get away with it, it's those few times that it just won't do what you want it to do that kill you.</p>
<p><strong>When you use helper tools, you could be cheating yourself out of knowledge</strong></p>
<p>Now I'm not saying that you should develop your own tools for rendering 3d graphs.  Some things you just don't have the time or the ability to create, but when it comes to simple things like markup, do the work.  The knowledge you gain from this is substantial.  Hell, I used to hate style sheets.  I used to hate javascript.  Quite frankly, they were a pain in the a-- at first.  However, taking the road less travelled has given me a new perspective on both.  I no longer fear them and in fact would rather just type the markup out myself than trust some third part thing that I can't fix when something goes wrong.  I know that if I have to create a quick mock up that looks like the real deal, I can do that with notepad and a browser.  I know that if I have to teach someone how to use style sheets or javascript, I can do that without just telling them to go to some page or to use some random tool.  I have confidence in my knowledge.</p>
<p><strong>More time now, less time later.</strong></p>
<p>Now I know in Perfectworld, there is always enough time allotted to doing what needs to be done.  In Realworld (Not the stupid MTV show) everyone is running around, heads a blaze.  So the biggest excuse to not learn proper markup is that there isn't time.  A company isn't going to pay you to learn when things need to be done.  Well sure, but flash forward a couple months when someone tells you that you have to adjust the grid you didn't build yourself to add something you have no idea how to add or else the world is going to end.  Last thing that person will want to hear is "It can't be done."  In fact, most business people have some crazy allergic reaction to that phrase that causes them to turn really, really red.  It's weird but happens a lot.  At this point you can either:</p>
<p>Laugh and lose your job.</p>
<p>Go on the forums and hope there is a solution.</p>
<p>Die a quick and painful death.</p>
<p>Always expect people to want 20% more than what was originally written.  Unless you have one of the best project managers that says the phrase "Work request form" on instinct, you will run into this situation.  That's where doing it yourself comes in real handy.  It may have taken you a while to figure it all out, but you will for certain be able to fix the issue quickly.</p>
<p><strong>You never know when you'll actually have to know how to build things from scratch</strong></p>
<p>Tech Interviews.  When looking for a job, you'll probably run into these.  Best way to be prepared for these?  Have the real world knowledge.  How do you get that?  By doing a lot of the work yourself.  I have been through interviews where I was given a simulated work item and told to produce code for it on the spot.  Some of it had to do with the actual markup needed to display the data.  (This was before MVC days, WebForm stuff)  The people were far more impressed that I was typing out the mark up than if I had just done drag and drop stuff.  Why?  Because there is a stigma, fair or not, that drag and drop people are displaced VB Weenies, and the real programmers don't bother with it.  Knowing how to hand code mark up on the spot is far more impressive than using visual tools or completely blanking out because you've had to rely on third party software.</p>
<p>At this point I realize I've mostly talked about markup, but this whole idea extends to a lot of the programming world.  Digging in and forcing yourself to do the work will substantially improve you abilities over time.  If you can't do this at work then find some time on your own to work on a side project to learn.  Build your own error handling system.  Build your own pager creating method.  Build your own Url creating method for MVC.  I promise that you will be in a much better position.</p>
<p><strong>Final Note</strong></p>
<p>You could argue that coming to a site like this and using copy/paste is against my spiel.  Fact is, I've copy and pasted plenty of code to get to where I want to go.  Difference between this and third party tools is you can learn from what you copy and paste.  Actually I would argue that you have the responsibility to learn about what you are copying before you do anything with it.  If you copy AND you take time to understand what you are copying, that can be just as helpful.  If nothing else, it's better than just using some third party method.</p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li>No Related Posts</li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/pontification/do-it-yourself/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.Net MVC: Attibute to Check if Route Value Exists and&#8230; and Means Something!</title>
		<link>http://byatool.com/pointless/asp-net-mvc-attibute-to-check-if-route-value-exists-and-and-means-something/</link>
		<comments>http://byatool.com/pointless/asp-net-mvc-attibute-to-check-if-route-value-exists-and-and-means-something/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 12:48:31 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Pointless]]></category>
		<category><![CDATA[Attributes]]></category>
		<category><![CDATA[MVC]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=930</guid>
		<description><![CDATA[Get ready for a roller coaster ride around the insanity that is me. You might actually find it amusing but most likely you'll just leave sick or underwhelmed. Don't feel bad if you do, you wouldn't be the first and, thanks to somehow being impervious to Natural Selection, you won't be the last. Be proud.
Here's [...]]]></description>
			<content:encoded><![CDATA[<p>Get ready for a roller coaster ride around the insanity that is me. You might actually find it amusing but most likely you'll just leave sick or underwhelmed. Don't feel bad if you do, you wouldn't be the first and, thanks to somehow being impervious to Natural Selection, you won't be the last. Be proud.</p>
<p>Here's what this post is about: Say you have a url like eh:</p>
<pre>/User/View/1</pre>
<p>Where 1 represents a UserId to a user that exists in some matter of context. (Does that makes sense?) Well there are a couple of things that could go wrong here. For one, if you don't want to have a nullable id in your signature:</p>
<pre>  <span style="color: #0000ff;">public</span> <span style="color: #008080;">ActionResult</span> View(<span style="color: #008080;">Int32</span>? userId)</pre>
<p>This could cause ouch:</p>
<pre>/User/View/</pre>
<p>But this problem is deeper. Much deeper. In fact so deep it deeper than even Piper Perabo has ever deeped before. Yrraaaahh!</p>
<p>What if the id doesn't even refer to anything? Say the id is 101 but there's no user with the id of 101? Beyond that, what if the id could be Id in some routes but UserId in others? WHAT WOULD YOU DO???</p>
<p>The idea here is to have something neato like this:</p>
<pre>  [<span style="color: #008080;">UserExistsById</span>]
  <span style="color: #0000ff;">public</span> <span style="color: #008080;">ActionResult</span> View(<span style="color: #008080;">Int32</span> userId)</pre>
<p>And if that id is junk, then you redirect to an error page. Well if this sounds interesting, I'd be surprised, but read on in the event that it does.</p>
<p>Now this isn't accomplished in the most simple manor, but for good reason: The more time in means the less time repeating. First method we need is something to simply check the route data to see if something exists:</p>
<pre>  <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #008080;">Boolean</span> RouteDataValueExists(<span style="color: #008080;">ActionExecutingContext</span> filterContext, <span style="color: #008080;">String</span> idToCheck)
  {
    <span style="color: #0000ff;">return</span> filterContext.RouteData.Values.ContainsKey(idToCheck);
  }</pre>
<p>Real easy. It either has been digested by MVC and regurgitated into some kind of route value or it hasn't. Basically this is the first check. After all, if it doesn't exist why bother going further?</p>
<p>Next is the method that will be calling this one. Mainly one that uses the RouteDataValueExists and if returns true, then it actually checks the value against where ever the user is persisted.</p>
<pre>  <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #008080;">Boolean</span> ValueFoundAndItemExists
  (
    <span style="color: #008080;">ActionExecutingContext</span> filterContext,
    <span style="color: #008080;">Enum</span> idToUse,
    <span style="color: #008080;">Func</span>&lt;<span style="color: #008080;">ActionExecutingContext</span>, <span style="color: #008080;">Enum</span>, <span style="color: #008080;">Func</span>&lt;<span style="color: #008080;">Int32</span>, <span style="color: #008080;">Boolean</span>&gt;, <span style="color: #008080;">Boolean</span>&gt; check,
    <span style="color: #008080;">Func</span>&lt;<span style="color: #008080;">Int32</span>, <span style="color: #008080;">Boolean</span>&gt; exists
  )
  {
    <span style="color: #008080;">Boolean</span> checksOut = <span style="color: #0000ff;">false</span>;
    <span style="color: #008080;">String</span> convertedId = idToUse.ToString();

    <span style="color: #0000ff;">if</span> (RouteDataValueExists(filterContext, convertedId))
    {
      checksOut = check(filterContext, idToUse, exists);
    }

    <span style="color: #0000ff;">return</span> checksOut;
  }</pre>
<p>Ok so kind of a lot at first and it's hard to decide how to present this system, so just go with it.</p>
<pre>  <span style="color: #008080;">Enum</span> idToUse,</pre>
<p>This is a design choice. In reality this will be turned into a string anyhow, but the idea is it will be what to check the route values for. So if you are checking for UserId, you will pass in UserRequestTypes.UserId. Again this was a choice on my part as I hate passing text around.</p>
<pre>  <span style="color: #008080;">Func</span>&lt;<span style="color: #008080;">ActionExecutingContext</span>, <span style="color: #008080;">Enum</span>, <span style="color: #008080;">Func</span>&lt;<span style="color: #008080;">Int32</span>, <span style="color: #008080;">Boolean</span>&gt;, <span style="color: #008080;">Boolean</span>&gt; check,</pre>
<p>This is the method that will be used by ValueFoundAndItemExists to delegate out the actual checking if the id is an integer and is a real user.</p>
<pre><span style="color: #008080;">Func</span>&lt;<span style="color: #008080;">Int32</span>, <span style="color: #008080;">Boolean</span>&gt; exists</pre>
<p>This will be the method that you will use to delegate the whole checking if it exists in the database. Something like:</p>
<pre>  <span style="color: #0000ff;">class</span> <span style="color: #008080;">User</span>
  {
    <span style="color: #0000ff;">public</span> Exists(<span style="color: #008080;">Int32</span> id)
    {
       <span style="color: #0000ff;">return</span> EntityContext.Context.User.Any(user =&gt; user.Id == id);
    }
  }</pre>
<p>Still with me? No? Greeeeat. Next up is the base class that contains the</p>
<pre>  <span style="color: #008080;">Func</span>&lt;<span style="color: #008080;">ActionExecutingContext</span>, <span style="color: #008080;">Enum</span>, <span style="color: #008080;">Func</span>&lt;<span style="color: #008080;">Int32</span>, <span style="color: #008080;">Boolean</span>&gt;, <span style="color: #008080;">Boolean</span>&gt; check,</pre>
<p>parameter from above.</p>
<pre><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">abstract</span> <span style="color: #0000ff;">class</span> <span style="color: #008080;">BaseExistsAttribute</span> : <span style="color: #008080;">ActionFilterAttribute</span>
{
  <span style="color: #0000ff;">protected</span> <span style="color: #008080;">Boolean</span> Exists
  (
    <span style="color: #008080;">ActionExecutingContext</span> filterContext,
    <span style="color: #008080;">Enum</span> idToUse,
    <span style="color: #008080;">Func</span>&lt;<span style="color: #008080;">Int32</span>, <span style="color: #008080;">Boolean</span>&gt; exists
  )
  {
    <span style="color: #008080;">Int32</span>? id = <span style="color: #008080;">Convert</span>.ToString(filterContext.RouteData.Values[idToUse.ToString()]).ConvertTo&lt;<span style="color: #008080;">Int32</span>&gt;();
    <span style="color: #0000ff;">return</span> id.HasValue &amp;&amp; exists(id.Value);
  }
}</pre>
<p>Ok so something might look familiar like well basically all the parameters. The reason for this is that there is a little bit of delegate passing going on with this whole system. One method passes on methods to other method in some kind of crazy method hoe down without the flanel shirts.</p>
<p>You will notice the use of the enum in this part:</p>
<pre>  idToUse.ToString()</pre>
<p>Again, you can easily just pass in a string instead of an enum, I just did this to stay away from strings.</p>
<p>Only thing that might be of interest is the ToConvert method that you <a href="http://byatool.com/index.php/utilities/duck-typing-my-way-to-a-universal-string-convert/">can find here</a>. You don't have to use it, you can simply just do a try parse on the</p>
<pre>  filterContext.RouteData.Values[idToUse.ToString()])</pre>
<p>To get an integer. That's up to you. I could have just put that in the code for you to see but then I couldn't randomly plug another post of mine.</p>
<p>Finally you have the actual attribute class:</p>
<pre>  [<span style="color: #008080;">AttributeUsage</span>(<span style="color: #008080;">AttributeTargets</span>.Method)]
  <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> <span style="color: #008080;">QuoteExistsByQuoteId</span> : <span style="color: #008080;">BaseExistsAttribute</span>
  {
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">override</span> <span style="color: #0000ff;">void</span> OnActionExecuting(<span style="color: #008080;">ActionExecutingContext</span> filterContext)
    {
      base.OnActionExecuting(filterContext);

      <span style="color: #0000ff;">if</span>
      (
        !<span style="color: #008080;">MvcMethods</span>.ValueFoundAndItemExists
        (
          filterContext,
          <span style="color: #008080;">UserRequestTypes</span>.UserId,
          Exists,
          <span style="color: #008080;">UserEntity</span>.Exists
        )
      )
      {
        filterContext.Result = <span style="color: #008080;">SiteMethods</span>.ErrorOut(<span style="color: #008080;">ErrorNames</span>.General_PageError);
      }
    }
  }</pre>
<p>And now it all comes together.</p>
<pre>  <span style="color: #008080;">UserRequestTypes</span>.UserId</pre>
<p>This is the enum I've been talking about this entire post! Now that I think of it, not really exciting.</p>
<pre>  Exists</pre>
<p>That's the method on the base class that checks for everything.</p>
<pre>  <span style="color: #008080;">UserEntity</span>.Exists</pre>
<p>And that's the method I need to check the persistence if the user is real. Remember? Takes in an integer and returns a boolean? Yes? Yes? No?</p>
<p>What's ErrorOut? Again this is just a method I made to create an ActionResult that is an redirect to an error page. Not hugely important. It's just what handles the situation when the value is bogus.... dude.</p>
<pre>  [<span style="color: #008080;">UserExistsById</span>]
  <span style="color: #0000ff;">public</span> <span style="color: #008080;">ActionResult</span> View(<span style="color: #008080;">Int32</span> userId)</pre>
<p>And there you have it. Hopefully it was useful in some way but I'm not of touch with reality.</p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li><a href="http://byatool.com/c/asp-net-mvc-attributes-and-semi-dynamic-check-for-request-parameters/" title="ASP.NET MVC:  Attributes and Semi Dynamic Check for Request Parameters">ASP.NET MVC:  Attributes and Semi Dynamic Check for Request Parameters</a></li><li><a href="http://byatool.com/lessons/asp-net-mvc-attributes-actionfilterattribute-and-why-you-might-want-to-use-them/" title="ASP.Net MVC: Attributes, ActionFilterAttribute, and Why You Might Want To Use Them">ASP.Net MVC: Attributes, ActionFilterAttribute, and Why You Might Want To Use Them</a></li><li><a href="http://byatool.com/lessons/data-annotations-mvc-and-why-you-might-like-them/" title="Data Annotations, MVC, and Why You Might Like Them">Data Annotations, MVC, and Why You Might Like Them</a></li><li><a href="http://byatool.com/pontification/asp-net-mvc-quick-overview-of-controller-structure/" title="ASP.Net MVC:  Quick Overview of Controller Structure">ASP.Net MVC:  Quick Overview of Controller Structure</a></li><li><a href="http://byatool.com/mvc/asp-net-mvc-htmlhelper-method-for-creating-buttons-with-forms-and-optional-images-part-1/" title="ASP.Net MVC HtmlHelper Method for Creating Buttons With Forms and Optional Images: Part 1">ASP.Net MVC HtmlHelper Method for Creating Buttons With Forms and Optional Images: Part 1</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/pointless/asp-net-mvc-attibute-to-check-if-route-value-exists-and-and-means-something/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery: Find All Checked Checkboxes</title>
		<link>http://byatool.com/ui/jquery-find-all-checked-checkboxes/</link>
		<comments>http://byatool.com/ui/jquery-find-all-checked-checkboxes/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 15:14:27 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[UI]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=909</guid>
		<description><![CDATA[So this is sort of a repeat of another post, but I figured it has some use on its own.
Say you have this:
  &#60;div&#62;
    &#60;input type="checkbox" name="JqueryIdList" value="1"  /&#62;
    &#60;input type="checkbox" name="JqueryIdList" value="2" /&#62;
    &#60;input type="checkbox" name="JqueryIdList" value="3" /&#62;
    &#60;input type="checkbox" [...]]]></description>
			<content:encoded><![CDATA[<p>So this is sort of a repeat of another post, but I figured it has some use on its own.</p>
<p>Say you have this:</p>
<pre>  &lt;<span style="color: #800000;">div</span>&gt;
    &lt;<span style="color: #800000;">input</span> <span style="color: #ff0000;">type</span><span style="color: #0000ff;">="checkbox"</span> <span style="color: #ff0000;">name</span><span style="color: #0000ff;">="JqueryIdList"</span> <span style="color: #ff0000;">value</span><span style="color: #0000ff;">="1"</span>  /&gt;
    &lt;<span style="color: #800000;">input</span> <span style="color: #ff0000;">type</span><span style="color: #0000ff;">="checkbox"</span> <span style="color: #ff0000;">name</span><span style="color: #0000ff;">="JqueryIdList"</span> <span style="color: #ff0000;">value</span><span style="color: #0000ff;">="2"</span> /&gt;
    &lt;<span style="color: #800000;">input</span> <span style="color: #ff0000;">type</span><span style="color: #0000ff;">="checkbox"</span> <span style="color: #ff0000;">name</span><span style="color: #0000ff;">="JqueryIdList"</span> <span style="color: #ff0000;">value</span><span style="color: #0000ff;">="3"</span> /&gt;
    &lt;<span style="color: #800000;">input</span> <span style="color: #ff0000;">type</span><span style="color: #0000ff;">="checkbox"</span> <span style="color: #ff0000;">name</span><span style="color: #0000ff;">="JqueryIdList"</span> <span style="color: #ff0000;">value</span><span style="color: #0000ff;">="4"</span> /&gt;
  &lt;/<span style="color: #800000;">div</span>&gt;
  &lt;<span style="color: #800000;">div</span> <span style="color: #ff0000;">onclick</span><span style="color: #0000ff;">="getIds('JqueryIdList');"</span>&gt;
    CLICK
  &lt;/<span style="color: #800000;">div</span>&gt;</pre>
<p>And you need the getIds method to find all the checked checkboxes from that markup. Well it's actually fairly simple, or at least it wil be once I enlighten you. I should get paid for this...</p>
<pre>  <span style="color: #0000ff;">function</span> getIds(checkList)
  {
    <span style="color: #0000ff;">var</span> idList = <span style="color: #0000ff;">new</span> <span style="color: #008080;">Array</span>();
    <span style="color: #0000ff;">var</span> loopCounter = 0;
    <span style="color: #008000;">//find all the checked checkboxes</span>
    jQuery(<span style="color: #800000;">"input[name="</span> + checkList + <span style="color: #800000;">"]:checked"</span>).each
    (
      <span style="color: #0000ff;">function</span>()
      {
        <span style="color: #008000;">//fill the array with the values</span>
        idList[loopCounter] = jQuery(<span style="color: #0000ff;">this</span>).val();
        loopCounter += 1;
      }
    );
    ...
  }</pre>
<p>The important part is this:</p>
<pre>
 jQuery(<span style="color: #800000;">"input[name="</span> + checkList + <span style="color: #800000;">"]:checked"</span>).</pre>
<p>As you can see, it is very simple.  Give it the name of the checkboxes, add on the ":checked" and boom you have a list of checked checkboxes.  Could it be more simple?  I think not.</p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li><a href="http://byatool.com/lessons/child-iframe-page-interacting-with-parent-page-yeah-i-went-there/" title="Child IFrame Page Interacting with Parent Page&#8230; Yeah I went there.">Child IFrame Page Interacting with Parent Page&#8230; Yeah I went there.</a></li><li><a href="http://byatool.com/lessons/get-the-jquery-datepicker-to-work-with-jquery-modal-dialog/" title="Get the jQuery DatePicker to Work With jQuery Modal Dialog">Get the jQuery DatePicker to Work With jQuery Modal Dialog</a></li><li><a href="http://byatool.com/ui/jquery-modal-dialog-hide-that-stupid-x-button-windows-close-button/" title="jQuery Modal Dialog : Hide That Stupid X Button / Windows Close Button">jQuery Modal Dialog : Hide That Stupid X Button / Windows Close Button</a></li><li><a href="http://byatool.com/ui/jquery-check-all-checkboxes-toggle-method-thingy/" title="jQuery &#8211; Check All Checkboxes Toggle Method Thingy">jQuery &#8211; Check All Checkboxes Toggle Method Thingy</a></li><li><a href="http://byatool.com/lessons/jquery-validation-adding-errors-to-the-error-containter-with-love/" title="jQuery Validation: Adding Errors to the Error Containter&#8230; With Love!">jQuery Validation: Adding Errors to the Error Containter&#8230; With Love!</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/ui/jquery-find-all-checked-checkboxes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>jQuery, Hidden Elements, and Why At Times I Hate It</title>
		<link>http://byatool.com/pontification/jquery-hidden-elements-and-why-at-times-i-hate-it/</link>
		<comments>http://byatool.com/pontification/jquery-hidden-elements-and-why-at-times-i-hate-it/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 14:23:29 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Pontification]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=914</guid>
		<description><![CDATA[So this is your situation, or at least it might be someday if you use jQuery:
You have a comment area that allows a user to view comments. Now this comment area is created using javascript (Read jQuery) only. When a user clicks on some kind of pager, a method is called to get a list [...]]]></description>
			<content:encoded><![CDATA[<p>So this is your situation, or at least it might be someday if you use jQuery:</p>
<p>You have a comment area that allows a user to view comments. Now this comment area is created using javascript (Read jQuery) only. When a user clicks on some kind of pager, a method is called to get a list of comments and recreate the comment table. Now you would think it would be a good idea to hide the table, recreate it, and then show it. Sounds like a decent way to go. So you try something like this:</p>
<pre>  ...

  jQuery(commentTable).hide(<span style="color: #800000;">"slide"</span>, { direction: <span style="color: #800000;">"up"</span> }, 200 );

  ...

  <span style="color: #008000;">//Get the comments and call a method to build the table.
</span>
  ...

  <span style="color: #0000ff;">function</span> buildTable(commentList, commentTable)
  {
    ...

    <span style="color: #008000;">//Take the list and iterate.  Create a row</span>

   ...

     jQuery(commentTable).appendChild(someCreatedDivRowWithAComment)  <span style="color: #008000;">//BOOM</span>

   ...
  }</pre>
<p>Then you run it and bam you get an error saying that basically commentTable doesn't exist. Now if this were WebForms and you did some kind of visible="false" you would know that the markup for that table wouldn't exist. However, in javascript style="display:none;" doesn't remove the element from the markup, it just hides it from the viewer. If you look at the source (Provided it's not dynamically created) you will still see it in the mark up. So what's the deal?</p>
<p>Well for some reason the creators of jQuery decided that there is a difference between a hidden element and a non hidden element to the point where you have to change your search (the jQuery() method is basically a search that looks for the element within the parenthesis) by adding on a "parameter".</p>
<pre>  jQuery(<span style="color: #800000;">".someElement:hidden"</span>)</pre>
<p>So if you do use the hide() method (Or fadeOut for that matter) you have to use the :hidden addon to find the stupid element. This can cause a big problem when things aren't timed correctly. What does that mean? Well that 200 value I have in the hide method, that's the time I want it to take to hide the element. Far as I can tell, and I've done some testing on this, the element is not :hidden until the animation completes. Which means there are 200 time units where it is not :hidden. Now if the time that it takes to get your comment list and start building the table is less than the time it takes to hide the element you've got an issue. Or conversely, if the 200 time units are up and it is now hidden, you're really screwed because the normal search won't work. You can try something like this:</p>
<pre>   <span style="color: #0000ff;">if</span>(jQuery(<span style="color: #0000ff;">this</span>).children(<span style="color: #800000;">".categoryBlockContainer"</span>).is(<span style="color: #800000;">":hidden"</span>))
  {
    categoryBlockContainer = jQuery(<span style="color: #0000ff;">this</span>).children(<span style="color: #800000;">".categoryBlockContainer:hidden"</span>);
  }
  <span style="color: #0000ff;">else
</span>  {
    categoryBlockContainer = jQuery(<span style="color: #0000ff;">this</span>).children(<span style="color: #800000;">".categoryBlockContainer"</span>);
  }</pre>
<p>And this works ok most of the time, but you still might run into a situation where it's still trying to finish the hide animation. Beyond that, it seems kind of asinine to have something like that in the code. It should find the element at all times, hidden or not.</p>
<p>This really kills the whole idea of animation.</p>
<p>Between this and javascript's bizarre variable scope, I've had some thoughts of changing my profession.</p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li>No Related Posts</li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/pontification/jquery-hidden-elements-and-why-at-times-i-hate-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.Net MVC How To Handle Multiple Checkboxes With Views/Actions&#8230; jQuery too!</title>
		<link>http://byatool.com/mvc/asp-net-mvc-how-to-handle-multiple-checkboxes-with-viewsactions-jquery-too/</link>
		<comments>http://byatool.com/mvc/asp-net-mvc-how-to-handle-multiple-checkboxes-with-viewsactions-jquery-too/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 20:33:06 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[MVC]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=902</guid>
		<description><![CDATA[Just a note, this is kind of an add on to this post but it's a much more simple (HOSTED) example and also deals with doing the whole check box thing with jQuery.
So one of the things I ran into some what recently was a grid... a grid with a death wish and a thirst [...]]]></description>
			<content:encoded><![CDATA[<p>Just a note, this is kind of an add on <a href="http://byatool.com/index.php/mvc/asp-net-mvc-multiple-checkboxes-and-strongly-typed-views/">to this post</a> but it's a much more simple (HOSTED) example and also deals with doing the whole check box thing with jQuery.</p>
<p>So one of the things I ran into some what recently was a grid... a grid with a death wish and a thirst for revenge. It also has a bunch of check boxes to allow multiple row deletes as seen here:</p>
<pre><img src="http://www.iamwebproject.com/PhotoView/Photo/ShowPhoto/13" alt="TURN YOUR IMAGES ON" /></pre>
<p>Now there might be a moment of panic and doubt (Or doubt and panic, everyone reacts differently) when you realize you no longer have those cushy grid postback events. WHAT ARE YOU GOING TO DO???? Well first you're going to feel disgust over your profuse sweating, cause lets be honest you're pretty gross. Then you're going to read on and find that all your panic, fun as it can be, was for nothing. Why? Because you have me... and not in some weird love kind of way because I don't even know you. More of a "You can count on me because I'm like that cool older brother you never had and because of which you ended up a social degenerate ie a programmer" kind of way.</p>
<p>Now to start I've already hosted both the code and a working example:</p>
<p><a href="http://www.iamwebproject.com/IdList/Test/CheckForIds/">Actual running thing on teh webz.</a></p>
<p><a href="http://www.iamwebproject.com/BAT/IdListLive.zip">Hosted code</a></p>
<p>Because I'm such a nice guy. (And that's true, I can list at least five people who aren't my mom who can attest to that.) However, I wouldn't be the nice guy that I am if I weren't going to at least explain some of the code.</p>
<p>There are two ways I handle this situation in the example I hosted, one is with a form, action, and post back. The other is with jquery and an asynchronous call. Both are actually pretty easy to pull off.</p>
<p>First let's look at the post back version. The mark up looks a little somethin' like dis:</p>
<pre>  &lt;<span style="color: #800000;">form</span> <span style="color: #ff0000;">action</span><span style="color: #0000ff;">="/Test/CheckForIds/"</span> <span style="color: #ff0000;">method</span><span style="color: #0000ff;">="post"</span>&gt;
    &lt;<span style="color: #800000;">div</span>&gt;
      &lt;<span style="color: #800000;">input</span> <span style="color: #ff0000;">type</span><span style="color: #0000ff;">="checkbox"</span> <span style="color: #ff0000;">name</span><span style="color: #0000ff;">="IdList"</span> <span style="color: #ff0000;">value</span><span style="color: #0000ff;">="1"</span>  /&gt;
      &lt;<span style="color: #800000;">input</span> <span style="color: #ff0000;">type</span><span style="color: #0000ff;">="checkbox"</span> <span style="color: #ff0000;">name</span><span style="color: #0000ff;">="IdList"</span> <span style="color: #ff0000;">value</span><span style="color: #0000ff;">="2"</span> /&gt;
      &lt;<span style="color: #800000;">input</span> <span style="color: #ff0000;">type</span><span style="color: #0000ff;">="checkbox"</span> <span style="color: #ff0000;">name</span><span style="color: #0000ff;">="IdList"</span> <span style="color: #ff0000;">value</span><span style="color: #0000ff;">="3"</span> /&gt;
      &lt;<span style="color: #800000;">input</span> <span style="color: #ff0000;">type</span><span style="color: #0000ff;">="checkbox"</span> <span style="color: #ff0000;">name</span><span style="color: #0000ff;">="IdList"</span> <span style="color: #ff0000;">value</span><span style="color: #0000ff;">="4"</span> /&gt;
    &lt;/<span style="color: #800000;">div</span>&gt;
    &lt;<span style="color: #800000;">div</span>&gt;
      &lt;<span style="color: #800000;">input</span> <span style="color: #ff0000;">type</span><span style="color: #0000ff;">="submit"</span> <span style="color: #ff0000;">value</span><span style="color: #0000ff;">="go"</span> /&gt;
    &lt;/<span style="color: #800000;">div</span>&gt;
  &lt;/<span style="color: #800000;">form</span>&gt;</pre>
<p>Looks like your standard form and if you've used MVC at all, you should be used to seeing something like that. The only thing of interest is that the checkboxes don't have ids and do share the same name. There's a good reason for the second one. Here's the action method:</p>
<pre>  [<span style="color: #008080;">AcceptVerbs</span>(<span style="color: #008080;">HttpVerbs</span>.Post)]
  <span style="color: #0000ff;">public</span> <span style="color: #008080;">ActionResult</span> CheckForIds(<span style="color: #008080;">Int32</span>[] idList)
  {
     <span style="color: #0000ff;">return</span> View(idList);
  }</pre>
<p>Now it makes more sense, doesn't it? The name attribute on the checkbox directly corresponds to the name of the array parameter. THAT'S AMAZING!!!1 Actually, kidding aside it is kind of nice. Not only does it match the checkboxes to the parameter, it also treats the values of the checkboxes (Checked ones) as a list of integers. Pretty slick.</p>
<p>And honestly, that's about all it takes for traditional posting.</p>
<p>Now for the jQuery part:</p>
<pre>  &lt;<span style="color: #800000;">div</span>&gt;
    &lt;<span style="color: #800000;">input</span> <span style="color: #ff0000;">type</span><span style="color: #0000ff;">="checkbox"</span> <span style="color: #ff0000;">name</span><span style="color: #0000ff;">="JqueryIdList"</span> <span style="color: #ff0000;">value</span><span style="color: #0000ff;">="1"</span>  /&gt;
    &lt;<span style="color: #800000;">input</span> <span style="color: #ff0000;">type</span><span style="color: #0000ff;">="checkbox"</span> <span style="color: #ff0000;">name</span><span style="color: #0000ff;">="JqueryIdList"</span> <span style="color: #ff0000;">value</span><span style="color: #0000ff;">="2"</span> /&gt;
    &lt;<span style="color: #800000;">input</span> <span style="color: #ff0000;">type</span><span style="color: #0000ff;">="checkbox"</span> <span style="color: #ff0000;">name</span><span style="color: #0000ff;">="JqueryIdList"</span> <span style="color: #ff0000;">value</span><span style="color: #0000ff;">="3"</span> /&gt;
    &lt;<span style="color: #800000;">input</span> <span style="color: #ff0000;">type</span><span style="color: #0000ff;">="checkbox"</span> <span style="color: #ff0000;">name</span><span style="color: #0000ff;">="JqueryIdList"</span> <span style="color: #ff0000;">value</span><span style="color: #0000ff;">="4"</span> /&gt;
  &lt;/<span style="color: #800000;">div</span>&gt;
  &lt;<span style="color: #800000;">div</span> <span style="color: #ff0000;">onclick</span><span style="color: #0000ff;">="getIds('JqueryIdList');"</span>&gt;
    CLICK
  &lt;/<span style="color: #800000;">div</span>&gt;</pre>
<p>Wow, looks about the same. Go figure. Well that's pretty much because the way hard part is the javascript itself.</p>
<pre>  <span style="color: #0000ff;">function</span> getIds(checkList)
  {
    <span style="color: #0000ff;">var</span> idList = <span style="color: #0000ff;">new</span> <span style="color: #008080;">Array</span>();
    <span style="color: #0000ff;">var</span> loopCounter = 0;
    <span style="color: #008000;">//find all the checked checkboxes</span>
    jQuery(<span style="color: #800000;">"input[name="</span> + checkList + <span style="color: #800000;">"]:checked"</span>).each
    (
      <span style="color: #0000ff;">function</span>()
      {
        <span style="color: #008000;">//fill the array with the values</span>
        idList[loopCounter] = jQuery(<span style="color: #0000ff;">this</span>).val();
        loopCounter += 1;
      }
    );
    <span style="color: #008000;">//Send the list off</span>
    jQuery.getJSON(<span style="color: #800000;">"/Test/CheckForIdsJson/"</span>, { idList: idList }, idsGotten);
  }</pre>
<p>Ok maybe it wasn't that hard or hard at all. But um... And here's the action method:</p>
<pre>  [<span style="color: #008080;">AcceptVerbs</span>(<span style="color: #008080;">HttpVerbs</span>.Get)]
  <span style="color: #0000ff;">public</span> <span style="color: #008080;">ActionResult</span> CheckForIdsJson(<span style="color: #008080;">Int32</span>[] idList)
  {
    <span style="color: #008080;">JsonResult</span> <span style="color: #000000;">result</span> = <span style="color: #0000ff;">new</span> <span style="color: #008080;">JsonResult</span>();
    result.Data = idList;

    <span style="color: #0000ff;">return</span> result;
  }</pre>
<p>So again, the same signature. Amazing huh?</p>
<p>Side note:</p>
<p>When I was eating this morning in front of the television (Chocolate shredded mini wheats if you must know.) I came upon the good ole classic Iron Eagle. I never really thought about how utterly f-ing insane that movie was until now though, mostly because I haven't seen it since I was a kid. I guess back then I could completely buy into the idea of some 17 year old, who can't make it into the Air Force Academy, suiting up and learning to use (At the time) the most complicated fighter the US had to offer within what? one whole montage, steal a 18 million dollar plane (Planes were cheap back then), fly into crazy dangerous territory, get past who knows how many trained professionals, save his dad, and nothing really comes of it. Actually I think if I remember (as I didn't get to watch the whole thing this time) he gets a place in the academy from this. IT'S A COMPLETELY BELIEVABLE STORY! The best part about it is that apparently between the time of the first and second movie his skills had depleted so fast that he gets popped at the beginning of the second one.  I guess without the Saving Dad mojo, he's just not the same.  Tip your glass to good ole Thumper.</p>
<p>I really miss the 80s where movies didn't really need to make any sense as long as they had some soundtrack filled with crazy obscure bands playing at random times in the movies itself followed by the movie characters commenting how great the music is.</p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li><a href="http://byatool.com/lessons/child-iframe-page-interacting-with-parent-page-yeah-i-went-there/" title="Child IFrame Page Interacting with Parent Page&#8230; Yeah I went there.">Child IFrame Page Interacting with Parent Page&#8230; Yeah I went there.</a></li><li><a href="http://byatool.com/lessons/get-the-jquery-datepicker-to-work-with-jquery-modal-dialog/" title="Get the jQuery DatePicker to Work With jQuery Modal Dialog">Get the jQuery DatePicker to Work With jQuery Modal Dialog</a></li><li><a href="http://byatool.com/ui/jquery-modal-dialog-hide-that-stupid-x-button-windows-close-button/" title="jQuery Modal Dialog : Hide That Stupid X Button / Windows Close Button">jQuery Modal Dialog : Hide That Stupid X Button / Windows Close Button</a></li><li><a href="http://byatool.com/ui/jquery-check-all-checkboxes-toggle-method-thingy/" title="jQuery &#8211; Check All Checkboxes Toggle Method Thingy">jQuery &#8211; Check All Checkboxes Toggle Method Thingy</a></li><li><a href="http://byatool.com/lessons/jquery-validation-adding-errors-to-the-error-containter-with-love/" title="jQuery Validation: Adding Errors to the Error Containter&#8230; With Love!">jQuery Validation: Adding Errors to the Error Containter&#8230; With Love!</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/mvc/asp-net-mvc-how-to-handle-multiple-checkboxes-with-viewsactions-jquery-too/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ASP.Net MVC:  Multiple Checkboxes and Strongly Typed Views</title>
		<link>http://byatool.com/mvc/asp-net-mvc-multiple-checkboxes-and-strongly-typed-views/</link>
		<comments>http://byatool.com/mvc/asp-net-mvc-multiple-checkboxes-and-strongly-typed-views/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 13:05:26 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[MVC]]></category>
		<category><![CDATA[Views]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=899</guid>
		<description><![CDATA[This might be a first, but I actually stole this from myself off Stackoverflow. Posted it and thought it might be useful to share with the 1 live person who reads this blog and the 90 other bots... And I'm not sure about the 1 live person.
So here's the situation, it's late, you've got a [...]]]></description>
			<content:encoded><![CDATA[<p>This might be a first, but I actually stole this from myself off Stackoverflow. Posted it and thought it might be useful to share with the 1 live person who reads this blog and the 90 other bots... And I'm not sure about the 1 live person.</p>
<p>So here's the situation, it's late, you've got a strongly typed view that has a checkbox list, and you are desperate for an answer on how to handle it.... and now you're scraping the bottom of the barrel. Well, good news is, I have the answer.</p>
<p>Let's say you have a Book class that has a list of Categories. The Category class is simple, just has an id and name.</p>
<pre>  <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> <span style="color: #008080;">Book
</span>  {
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">Int32</span> BookId { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">IList</span>&lt;<span style="color: #008080;">Category</span>&gt; Categories { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
  }

  <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> Category
  {
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">Int32</span> Id { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">String</span> Name { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
  }</pre>
<p>Now you could try and figure out a way to create a typed view using the Book class. You could also stomp on your left foot until it bleeds. Who am I to judge you for liking pain? (Sick f---) For those who don't want to go through that nightmare, I have an alternative: Create two new classes, one to set the view and one to handle the post back.</p>
<pre><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> <span style="color: #008080;">ViewBookModel</span>
{
  <span style="color: #0000ff;">public</span> ViewBookModel(<span style="color: #008080;">Book</span> book, <span style="color: #008080;">IList</span>&lt;<span style="color: #008080;">Categories</span>&gt; categoryList)
  {
    BookId = book.Id;
    CategoryList = categoryList;
  }

  <span style="color: #0000ff;">public</span> <span style="color: #008080;">Int32</span> <span style="color: #008080;">BookId</span> { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">set</span>; }
  <span style="color: #008080;">IList</span>&lt;<span style="color: #008080;">Categories</span>&gt; CategoryList { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
}</pre>
<p>First the class to set the view. As you can see, there is a book id that corresponds to a book object's id (DUH) and the category list which you will set in the original action.</p>
<pre>  [<span style="color: #008080;">AcceptVerbs</span>(<span style="color: #008080;">HttpVerbs</span>.Get)]
  <span style="color: #0000ff;">public</span> <span style="color: #008080;">ActionResult</span> EditBook(<span style="color: #008080;">Int32</span> bookId)
  {
     <span style="color: #008080;">Book</span> foundBook = <span style="color: #008080;">Book</span>.GetById(bookId);
     <span style="color: #008080;">IList</span>&lt;<span style="color: #008080;">Category</span>&gt; categoryList = <span style="color: #008080;">Category</span>.GetAll();
     <span style="color: #008080;">ViewBookModel</span> model = <span style="color: #0000ff;">new</span> <span style="color: #008080;">ViewBookModel</span>(foundBook, categoryList);
     <span style="color: #0000ff;">return</span> View(model);
  }</pre>
<p>And then your markup for the checkbox list will be something like this:</p>
<pre>  <span style="color: #efc20f;">&lt;%</span>
    <span style="color: #0000ff;">foreach</span>(<span style="color: #0000ff;">var</span> category <span style="color: #0000ff;">in</span> <span style="color: #008080;">Model</span>.CategoryList)
    {
  <span style="color: #efc20f;">%&gt;</span>
      &lt;<span style="color: #800000;">input</span> <span style="color: #ff0000;">type</span><span style="color: #0000ff;">="checkbox"</span> <span style="color: #ff0000;">name</span><span style="color: #0000ff;">="CategoryIds"</span> <span style="color: #ff0000;">value</span><span style="color: #0000ff;">="</span><span style="color: #efc20f;">&lt;%=</span> category.Id <span style="color: #efc20f;">%&gt;</span><span style="color: #0000ff;">"</span> /&gt;
  <span style="color: #efc20f;">&lt;%</span>
    }
  <span style="color: #efc20f;">%&gt;</span></pre>
<p>Notice that the name for every input is CategoryIds. This is because this will be the name of the collection of ids on the model for posting:</p>
<pre>  <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> <span style="color: #008080;">ViewBookInModel</span>
  {
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">String</span> BookId { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">Int32</span>[] CategoryIds { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
  }</pre>
<p>And the action method would look like:</p>
<pre>  [<span style="color: #008080;">AcceptVerbs</span>(<span style="color: #008080;">HttpVerbs</span>.Post)]
  <span style="color: #0000ff;">public</span> <span style="color: #008080;">ActionResult</span> UpdateBook(<span style="color: #008080;">ViewBookInModel</span> book)
  {
    <span style="color: #0000ff;">foreach</span>(<span style="color: #008080;">Int32</span> id <span style="color: #0000ff;">in</span> book.CategoryIds)
    {
      ...
    }
  }</pre>
<p>And boom, problem solved. You can now use a strongly typed View with a checkbox list. Go forth and be fruitful.</p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li>No Related Posts</li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/mvc/asp-net-mvc-multiple-checkboxes-and-strongly-typed-views/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>ASP.Net MVC: PhotoView Lessons &#8211; Getting Around A Master Page Model</title>
		<link>http://byatool.com/photoview/asp-net-mvc-photoview-lessons-getting-around-a-master-page-model/</link>
		<comments>http://byatool.com/photoview/asp-net-mvc-photoview-lessons-getting-around-a-master-page-model/#comments</comments>
		<pubDate>Mon, 14 Sep 2009 14:38:34 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[PhotoView]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=894</guid>
		<description><![CDATA[Original About PhotoView Here
I've started to take the PhotoView site and move it toward a full blow site application. Not sure why, but then again why shouldn't I? Don't have a good reason? Pbbbbbbtttt jog off.
One thing I ran into yesterday while working on it, as I've added authentication to the site (An update I'll [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://byatool.com/index.php/mvc/now-hosting-my-photoview-project-be-afraid/">Original About PhotoView Here</a></p>
<p>I've started to take the PhotoView site and move it toward a full blow site application. Not sure why, but then again why shouldn't I? Don't have a good reason? Pbbbbbbtttt jog off.</p>
<p>One thing I ran into yesterday while working on it, as I've added authentication to the site (An update I'll post sometime this week I think), is having a menu show or not show based on the user being logged in or and admin or whatever. What I don't like doing is having to call methods from the "framework" if I can just add a property to a model. There are various reasons why, ranging from the fact mark up errors don't blow up compile time to the idea that the model should take care of those things. Now you can't always follow this rule as it's obvious I use the CreateUrl method like it's a bat in a shed. (I have no idea what that means) However, a certain amount of lock down is nice and the Create method is an extension method so it doesn't look like I'm cheating... Am I right?</p>
<p>So here's the situation, I would like to have a model that has two properties UserIsLoggedIn and UserIsAdmin so I can do magic like:</p>
<pre>  <span style="color: #e1d809;">&lt;%</span>
    <span style="color: #0000ff;">if</span>(Model.UserIsAdmin)
    {
  <span style="color: #e1d809;">%&gt;</span>
      &lt;<span style="color: #800000;">a</span> <span style="color: #ff0000;">href</span><span style="color: #0000ff;">="Admin/DoStuff"</span> &gt; Admin Stuff &lt;/<span style="color: #800000;">a</span>&gt;
  <span style="color: #e1d809;">&lt;%
</span>    }
  <span style="color: #e1d809;">%&gt;</span></pre>
<p>Now this would seem to be simple, you would think having the master page inherit from the generic version of ViewMastePage:</p>
<pre>  Inherits="System.Web.Mvc.ViewMasterPage&lt;SomeModelClass&gt;"</pre>
<p>And the class would be something like this:</p>
<pre>  <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> <span style="color: #008080;">SomeModelClass</span>()
  {
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">Boolean</span> UserIsAdmin { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
    <span style="color: #0000ff;">public</span> <span style="color: #008080;">Boolean</span> UserIsLoggedIn { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
  }</pre>
<p>And the flowers would bloom, the sun would shine, and dogs and cats would live in harmony. And it works that way up until you actually run any given page with a strongly typed view. Then you get this error:</p>
<blockquote><p>Sorry bro, but you need a hella cool model that is all like "Hey mom" to SomeModelClass.</p></blockquote>
<p>I think I'm paraphrasing a bit but the idea to take from this is that all view models will have to inherit from the same model the master page is using. Yeah, basically a bit "go f--- yourself" written into MVC. So either you follow this obviously easy and unhindering design choice or you do what all programmers must do at some point: Compromise. And I mean that in the real sense, not the in the relationship, better to bend than break even though you're already broken sort of way.</p>
<p>Remember that little bit of self comfort I gave myself for the HtmlHelper extension CreateUrl, well it's time to do that once again. So in a <a href="http://www.imdb.com/title/tt1001508/">He's Just Not That In To You</a> sort of way (Yes I saw that movie. That's the other version of compromise), I'm going to tell myself that it's ok and that though it may be bad for most situations, I've heard that Sally's friend in New York who is a programmer got away with it so I'll most like get away with it too.</p>
<pre>  <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">class</span> <span style="color: #008080;">ViewMasterPageExtension</span>
  {
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #008080;">String</span> CurrentUrl(this <span style="color: #008080;">ViewMasterPage</span> page)
    {
      <span style="color: #0000ff;">return</span> <span style="color: #008080;">SiteMethods</span>.GetCurrentUrl();
    }

    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #008080;">Boolean</span> UserIsAdmin(this <span style="color: #008080;">ViewMasterPage</span> page)
    {
      <span style="color: #0000ff;">return</span> <span style="color: #008080;">State</span>.CurrentUser != <span style="color: #0000ff;">null</span> &amp;&amp; <span style="color: #008080;">State</span>.CurrentUser.UserType == <span style="color: #008080;">PhotoViewUserType</span>.GetAdminType();
    }

    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #008080;">Boolean</span> UserIsLoggedIn(this <span style="color: #008080;">ViewMasterPage</span> page)
    {
      return <span style="color: #008080;">State</span>.CurrentUser != null;
    }
  }</pre>
<p>Yes it's not on a model, yes it's a work around, but I'd rather do this:</p>
<pre>  <span style="color: #0000ff;">if</span>(<span style="color: #0000ff;">this</span>.UserIsAdmin())</pre>
<p>Than this:</p>
<pre>  <span style="color: #0000ff;">if</span>(<span style="color: #008080;">State</span>.CurrentUser != <span style="color: #0000ff;">null</span> &amp;&amp; <span style="color: #008080;">State</span>.CurrentUser.UserType == <span style="color: #008080;">PhotoViewUserType</span>.GetAdminType();)</pre>
<p>And in the end, isn't what make my life easier the main goal of existence?</p>
<p>Is it me or does Sam Neil look <a href="http://www.imdb.com/media/rm1038196480/nm0000554">beyond creepy in this imdb photo</a>?</p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li>No Related Posts</li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/photoview/asp-net-mvc-photoview-lessons-getting-around-a-master-page-model/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.Net MVC:  Show Picture Dynamically Using jQuery</title>
		<link>http://byatool.com/mvc/asp-net-mvc-show-picture-dynamically-using-jquery/</link>
		<comments>http://byatool.com/mvc/asp-net-mvc-show-picture-dynamically-using-jquery/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 13:25:51 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[MVC]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=886</guid>
		<description><![CDATA[Ready for the next step to this guy? Can't sleep lately because of it? Ignoring your day to day tasks due to anticipation? Well wait no longer. I have just the cure for you. In fact, steady use has shown to improve both self esteem and popularity. Behold Jquepictuax:
function showPicture(imageHolder, id)
{
  jQuery(imageHolder).attr("src", "/Photo/ShowPhoto/" + [...]]]></description>
			<content:encoded><![CDATA[<p>Ready for the next step to <a href="http://byatool.com/index.php/mvc/asp-net-mvc-upload-image-to-database-and-show-image-dynamically-using-a-view/">this guy?</a> Can't sleep lately because of it? Ignoring your day to day tasks due to anticipation? Well wait no longer. I have just the cure for you. In fact, steady use has shown to improve both self esteem and popularity. Behold Jquepictuax:</p>
<pre><span style="color: #0000ff;">function</span> showPicture(imageHolder, id)
{
  jQuery(imageHolder).attr(<span style="color: #800000;">"src"</span>, <span style="color: #800000;">"/Photo/ShowPhoto/"</span> + id);
}</pre>
<p>And you can't forget to try:</p>
<pre>&lt;<span style="color: #800000;">img</span> <span style="color: #ff0000;">id</span><span style="color: #0000ff;">="holder"</span> <span style="color: #ff0000;">alt</span><span style="color: #0000ff;">=""</span> /&gt;
&lt;<span style="color: #800000;">div</span> <span style="color: #ff0000;">onclick</span><span style="color: #0000ff;">="showPicture('#holder', '79');"</span>&gt;Show!&lt;/<span style="color: #800000;">div</span>&gt;</pre>
<p>And with that your life will be far better than it was before. You can once again start enjoying the simple things in life. Enjoy the birds singing, the sun setting, and those noisy little things that run around your house.<br />
<small><br />
Disclaimer: Id may vary. Image results also very. Though proven to be better when tested again a placebo, Jquepictuax may not improve your self esteem or make you more popular. Jquepictuax is not guaranteed to improve your life in any way. Use Jquepictuax in small quantities. People with low blood pressure or who are pregnant should avoid using Jquepictuax. If you consume more than 3 alcoholic drinks per day, please seek medical attention before use. May cause certain side effects such as dizziness, nausea, overwhelming chills, headaches, muscle soreness, dry mouth, light headedness, sleepiness, drop in appetite, and death. If you notice any these side effects, stop use of Jquepictuax immediately and seek medical attention. Please consult physician before Jquepictuax use.<br />
</small><br />
You happiness is right around the corner, why not turn it with Jquepictuax?</p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li><a href="http://byatool.com/lessons/child-iframe-page-interacting-with-parent-page-yeah-i-went-there/" title="Child IFrame Page Interacting with Parent Page&#8230; Yeah I went there.">Child IFrame Page Interacting with Parent Page&#8230; Yeah I went there.</a></li><li><a href="http://byatool.com/lessons/get-the-jquery-datepicker-to-work-with-jquery-modal-dialog/" title="Get the jQuery DatePicker to Work With jQuery Modal Dialog">Get the jQuery DatePicker to Work With jQuery Modal Dialog</a></li><li><a href="http://byatool.com/ui/jquery-modal-dialog-hide-that-stupid-x-button-windows-close-button/" title="jQuery Modal Dialog : Hide That Stupid X Button / Windows Close Button">jQuery Modal Dialog : Hide That Stupid X Button / Windows Close Button</a></li><li><a href="http://byatool.com/ui/jquery-check-all-checkboxes-toggle-method-thingy/" title="jQuery &#8211; Check All Checkboxes Toggle Method Thingy">jQuery &#8211; Check All Checkboxes Toggle Method Thingy</a></li><li><a href="http://byatool.com/lessons/jquery-validation-adding-errors-to-the-error-containter-with-love/" title="jQuery Validation: Adding Errors to the Error Containter&#8230; With Love!">jQuery Validation: Adding Errors to the Error Containter&#8230; With Love!</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/mvc/asp-net-mvc-show-picture-dynamically-using-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.Net MVC: Upload Image to Database and Show Image &#8220;Dynamically&#8221; Using a View</title>
		<link>http://byatool.com/mvc/asp-net-mvc-upload-image-to-database-and-show-image-dynamically-using-a-view/</link>
		<comments>http://byatool.com/mvc/asp-net-mvc-upload-image-to-database-and-show-image-dynamically-using-a-view/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 13:00:28 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[MVC]]></category>
		<category><![CDATA[Dynamic]]></category>
		<category><![CDATA[Image]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=881</guid>
		<description><![CDATA[Oddly enough this came about from me wanting to do this, figuring it out, and then deciding not to bother with it. So there's a possibility this will happen to you too. Well that's not completely true. The first half where I was uploading and showing from a database, but showing an image through a [...]]]></description>
			<content:encoded><![CDATA[<p>Oddly enough this came about from me wanting to do this, figuring it out, and then deciding not to bother with it. So there's a possibility this will happen to you too. Well that's not completely true. The first half where I was uploading and showing from a database, but showing an image through a view to mimic the .ashx functionality of WebForms is still pretty useful.</p>
<p><strong>Saving the Image</strong></p>
<p>First off, here's the look of the table:</p>
<pre><img class="alignnone size-full wp-image-883" title="Table" src="http://byatool.com/wp-content/uploads/2009/09/Table.PNG" alt="Table" width="357" height="172" /></pre>
<p>So pretty simple table. Most important parts are the ImageData and ContentType. Why? Well let's look at the action needed to save the image:</p>
<pre>[<span style="color: #008080;">AcceptVerbs</span>(<span style="color: #008080;">HttpVerbs</span>.Post)]
<span style="color: #0000ff;">public</span> <span style="color: #008080;">ActionResult</span> Upload(<span style="color: #008080;">PhotoForSingleItem</span> photo)
{
  <span style="color: #008000;">//PhotoForSingleItem is just a class that has properties</span>
  <span style="color: #008000;">// Name and Alternate text.  I use strongly typed Views and Actions</span>
  <span style="color: #008000;">//  because I'm not a fan of using string to get the posted data from the</span>
  <span style="color: #008000;">//  FormCollection.  That just seems ugly and unreliable to me.</span>

  <span style="color: #008000;">//PhotoViewImage is just a Entityframework class that has</span>
  <span style="color: #008000;">// String Name, String AlternateText, Byte[] ActualImage,</span>
  <span style="color: #008000;">//  and String ContentType</span>
  <span style="color: #008080;">PhotoViewImage</span> newImage = <span style="color: #0000ff;">new</span> <span style="color: #008080;">PhotoViewImage</span>();
  <span style="color: #008080;">HttpPostedFileBase</span> file = Request.Files["OriginalLocation"];
  newImage.Name = photo.Name;
  newImage.Alt = photo.AlternateText;

  <span style="color: #008000;">//Here's where the ContentType column comes in handy.  By saving</span>
  <span style="color: #008000;">//  this to the database, it makes it infinitely easier to get it back</span>
  <span style="color: #008000;">//  later when trying to show the image.</span>
  newImage.ContentType = file.ContentType;

  <span style="color: #008080;">Int32</span> length = file.ContentLength;
  <span style="color: #008000;">//This may seem odd, but the fun part is that if</span>
  <span style="color: #008000;">//  I didn't have a temp image to read into, I would</span>
  <span style="color: #008000;">//  get memory issues for some reason.  Something to do</span>
  <span style="color: #008000;">//  with reading straight into the object's ActualImage property.</span>
  <span style="color: #0000ff;">byte</span>[] tempImage = <span style="color: #0000ff;">new</span> <span style="color: #0000ff;">byte</span>[length];
  file.InputStream.Read(tempImage, 0, length);
  newImage.ActualImage = tempImage ;

  newImage.Save();

  <span style="color: #008000;">//This part is completely optional.  You could redirect on success</span>
  <span style="color: #008000;">// or handle errors ect.  Just wanted to keep this simple for the example.</span>
  <span style="color: #0000ff;">return</span> View();
}</pre>
<p>And here's the mark up to get this ball a rollin':</p>
<pre>&lt;<span style="color: #800000;">form</span> <span style="color: #ff0000;">method</span><span style="color: #0000ff;">="post"</span> <span style="color: #ff0000;">enctype</span><span style="color: #0000ff;">="multipart/form-data"</span> <span style="color: #ff0000;">action</span><span style="color: #0000ff;">="Photo/Upload"</span>&gt;
  &lt;<span style="color: #800000;">div</span>&gt;
    &lt;<span style="color: #800000;">span</span>&gt;
     Name:
   &lt;/<span style="color: #800000;">span</span>&gt;
   &lt;<span style="color: #800000;">span</span>&gt;
     &lt;<span style="color: #800000;">input</span> <span style="color: #ff0000;">type</span><span style="color: #0000ff;">="text"</span> <span style="color: #ff0000;">id</span><span style="color: #0000ff;">="Name"</span> <span style="color: #ff0000;">name</span><span style="color: #0000ff;">="Name"</span> /&gt;
   &lt;/<span style="color: #800000;">span</span>&gt;
  &lt;/<span style="color: #800000;">div</span>&gt;
  &lt;<span style="color: #800000;">div</span>&gt;
    &lt;<span style="color: #800000;">span</span>&gt;
      Alternate Text:
    &lt;/<span style="color: #800000;">span</span>&gt;
    &lt;<span style="color: #800000;">span</span>&gt;
     &lt;<span style="color: #800000;">input</span> <span style="color: #ff0000;">type</span><span style="color: #0000ff;">="text"</span> <span style="color: #ff0000;">id</span><span style="color: #0000ff;">="AlternateText"</span> <span style="color: #ff0000;">name</span><span style="color: #0000ff;">="AlternateText"</span> /&gt;
    &lt;/<span style="color: #800000;">span</span>&gt;
  &lt;/<span style="color: #800000;">div</span>&gt;
  &lt;<span style="color: #800000;">div</span>&gt;
    &lt;<span style="color: #800000;">span</span>&gt;
      Image
    &lt;/<span style="color: #800000;">span</span>&gt;
    &lt;<span style="color: #800000;">span</span>&gt;
      &lt;<span style="color: #800000;">input</span> <span style="color: #ff0000;">type</span><span style="color: #0000ff;">="file"</span> <span style="color: #ff0000;">id</span><span style="color: #0000ff;">="OriginalLocation"</span> <span style="color: #ff0000;">name</span><span style="color: #0000ff;">="OriginalLocation"</span> /&gt;
    &lt;/<span style="color: #800000;">span</span>&gt;
  &lt;/<span style="color: #800000;">div</span>&gt;
  &lt;<span style="color: #800000;">div</span>&gt;
    &lt;<span style="color: #800000;">input</span> <span style="color: #ff0000;">type</span><span style="color: #0000ff;">="submit"</span> <span style="color: #ff0000;">value</span><span style="color: #0000ff;">="Upload"</span> /&gt;
  &lt;/<span style="color: #800000;">div</span>&gt;
&lt;/<span style="color: #800000;">form</span>&gt;</pre>
<p>Biggest thing to notice in the markup is the enctype="multipart/form-data". This is a must to upload images. It was something I was missing originally and annoyed the hell out of me.</p>
<p><strong>Showing the Image</strong></p>
<p>So now that we have a we to upload the image, how the hell do you use it? Well that's not too hard. It just involves a new type of result, an action, and an img element.</p>
<p>So the first thing you need is an image result, and in using my superior intellect I came up with such a thing. And by superior intellect I mean I used <a href="http://stackoverflow.com/questions/636179/how-to-use-generic-handlers-ashx-in-asp-net-mvc">StackOverflow</a>. Oddly enough though, it's actually the second post that I got it from and I changed it a little. However, it was very useful.</p>
<pre><span style="color: #0000ff;">using</span> System.Web;
<span style="color: #0000ff;">using</span> System.Web.Mvc;
<span style="color: #0000ff;">using</span> System.IO;

<span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> <span style="color: #008080;">ImageResult</span> : <span style="color: #008080;">ActionResult</span>
{
  <span style="color: #0000ff;">public</span> <span style="color: #008080;">String</span> ContentType { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
  <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">byte</span>[] ImageBytes { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }
  <span style="color: #0000ff;">public</span> <span style="color: #008080;">String</span> SourceFilename { <span style="color: #0000ff;">get</span>; <span style="color: #0000ff;">set</span>; }

  <span style="color: #008000;">//This is used for times where you have a physical location</span>
  <span style="color: #0000ff;">public</span> ImageResult(<span style="color: #008080;">String</span> sourceFilename, <span style="color: #008080;">String</span> contentType)
  {
    SourceFilename = sourceFilename;
    ContentType = contentType;
  }

  <span style="color: #008000;">//This is used for when you have the actual image in byte form</span>
  <span style="color: #008000;">//  which is more important for this post.</span>
  <span style="color: #0000ff;">public</span> ImageResult(<span style="color: #0000ff;">byte</span>[] sourceStream, <span style="color: #008080;">String</span> contentType)
  {
    ImageBytes = sourceStream;
    ContentType = contentType;
  }

  <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">override</span> <span style="color: #0000ff;">void</span> ExecuteResult(<span style="color: #008080;">ControllerContext</span> context)
  {
    <span style="color: #0000ff;">var</span> response = context.HttpContext.Response;
    response.Clear();
    response.Cache.SetCacheability(<span style="color: #008080;">HttpCacheability</span>.NoCache);
    response.ContentType = ContentType;

    <span style="color: #008000;">//Check to see if this is done from bytes or physical location</span>
    <span style="color: #008000;">//  If you're really paranoid you could set a true/false flag in</span>
    <span style="color: #008000;">//  the constructor.</span>
    <span style="color: #0000ff;">if</span> (ImageBytes != null)
    {
      <span style="color: #0000ff;">var</span> stream = <span style="color: #0000ff;">new</span> <span style="color: #008080;">MemoryStream</span>(ImageBytes);
      stream.WriteTo(response.OutputStream);
      stream.Dispose();
    }
    <span style="color: #0000ff;">else</span>
    {
      response.TransmitFile(SourceFilename);
    }
  }
}</pre>
<p>And here's how you use the actual result.</p>
<pre>[<span style="color: #008080;">AcceptVerbs</span>(<span style="color: #008080;">HttpVerbs</span>.Get)]
<span style="color: #0000ff;">public</span> <span style="color: #008080;">ActionResult</span> ShowPhoto(Int32 id)
{
  <span style="color: #008000;">//This is my method for getting the image information</span>
  <span style="color: #008000;">// including the image byte array from the image column in</span>
  <span style="color: #008000;">// a database.</span>
  <span style="color: #008080;">PhotoViewImage</span> image = <span style="color: #008080;">PhotoViewImage</span>.GetById(id);
  <span style="color: #008000;">//As you can see the use is stupid simple.  Just get the image bytes and the</span>
  <span style="color: #008000;">//  saved content type.  See this is where the contentType comes in real handy.</span>
  <span style="color: #008080;">ImageResult</span> result = <span style="color: #0000ff;">new</span> <span style="color: #008080;">ImageResult</span>(image.ActualImage, image.ContentType);

  <span style="color: #0000ff;">return</span> result;
}</pre>
<p>And the markup would go a little sumthin' like dis:</p>
<pre>  &lt;<span style="color: #800000;">img</span> <span style="color: #ff0000;">src</span><span style="color: #0000ff;">="/Photo/ShowPhoto/1"</span> <span style="color: #ff0000;">alt</span><span style="color: #0000ff;">=""</span> /&gt;</pre>
<p>And now you too can upload an image to a database, show it, and then decide just to physically host the images anyway. Next post will be about how to use this with jQuery and asynchronously. I bet you can't wait!</p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li><a href="http://byatool.com/ui/jquery-slide-menu-another-cause-i-can-experiment/" title="jQuery Slide Menu&#8230;  Another Cause I Can Experiment">jQuery Slide Menu&#8230;  Another Cause I Can Experiment</a></li><li><a href="http://byatool.com/c/asp-net-mvc-attributes-and-semi-dynamic-check-for-request-parameters/" title="ASP.NET MVC:  Attributes and Semi Dynamic Check for Request Parameters">ASP.NET MVC:  Attributes and Semi Dynamic Check for Request Parameters</a></li><li><a href="http://byatool.com/ui/jquery-slide-and-pairing-a-divs-hover-with-a-divs-slide/" title="jQuery Slide and Pairing a Div&#8217;s Hover With a Div&#8217;s Slide">jQuery Slide and Pairing a Div&#8217;s Hover With a Div&#8217;s Slide</a></li><li><a href="http://byatool.com/net-issues/entity-framework-linq-to-entities-only-supports-casting-entity-data-model-primitive-types/" title="Entity Framework: LINQ to Entities only supports casting Entity Data Model primitive types">Entity Framework: LINQ to Entities only supports casting Entity Data Model primitive types</a></li><li><a href="http://byatool.com/ui/aspnet-mvc-jquery-json-and-paging-hows-that-for-a-soe-title/" title="ASP.Net MVC, jQuery, JSon, and paging&#8230;  how&#8217;s that for a SOE title?">ASP.Net MVC, jQuery, JSon, and paging&#8230;  how&#8217;s that for a SOE title?</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/mvc/asp-net-mvc-upload-image-to-database-and-show-image-dynamically-using-a-view/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
