<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: ASP.NET MVC: Using Ajax, Json and PartialViews</title>
	<atom:link href="http://www.atlanticbt.com/blog/asp-net-mvc-using-ajax-json-and-partialviews/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.atlanticbt.com/blog/asp-net-mvc-using-ajax-json-and-partialviews/</link>
	<description>Internet Marketing and Web Development in Raleigh</description>
	<lastBuildDate>Tue, 07 Feb 2012 18:36:11 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Gibson Les Paul Supreme Reviews</title>
		<link>http://www.atlanticbt.com/blog/asp-net-mvc-using-ajax-json-and-partialviews/comment-page-1/#comment-5293</link>
		<dc:creator>Gibson Les Paul Supreme Reviews</dc:creator>
		<pubDate>Wed, 30 Nov 2011 16:46:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.atlanticbt.com/blog/?p=2235#comment-5293</guid>
		<description>&lt;strong&gt;Gibson Les Paul Supreme Reviews...&lt;/strong&gt;

[...]ASP.NET MVC: Using Ajax, Json and PartialViews &#124; Atlantic BT[...]...</description>
		<content:encoded><![CDATA[<p><strong>Gibson Les Paul Supreme Reviews&#8230;</strong></p>
<p>[...]ASP.NET MVC: Using Ajax, Json and PartialViews | Atlantic BT[...]&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://www.atlanticbt.com/blog/asp-net-mvc-using-ajax-json-and-partialviews/comment-page-1/#comment-4073</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Thu, 04 Aug 2011 20:59:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.atlanticbt.com/blog/?p=2235#comment-4073</guid>
		<description>So as far as I know, I have pretty much followed your advice here and it seems that when the JsonResult is called to add the &quot;Person&quot;, in the result method the wrapped ViewModel&#039;s field are all null, or default. So can you think of anything I have done wrong or some pitfalls that I may have fallen into? I cannot seem to hash out the issue here.</description>
		<content:encoded><![CDATA[<p>So as far as I know, I have pretty much followed your advice here and it seems that when the JsonResult is called to add the &#8220;Person&#8221;, in the result method the wrapped ViewModel&#8217;s field are all null, or default. So can you think of anything I have done wrong or some pitfalls that I may have fallen into? I cannot seem to hash out the issue here.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Demetrios</title>
		<link>http://www.atlanticbt.com/blog/asp-net-mvc-using-ajax-json-and-partialviews/comment-page-1/#comment-3748</link>
		<dc:creator>Demetrios</dc:creator>
		<pubDate>Tue, 16 Nov 2010 14:17:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.atlanticbt.com/blog/?p=2235#comment-3748</guid>
		<description>First of all ... great post, Josh!  Thank you.

Bryan, you have a lot of reading to do ... when starting from scratch, asking novice, incremental questions will take too long (for everyone involved).  There are many examples out there for MVC, AJAX, jQuery, etc.  Granted, not quite as polished as this one! :)

To (hopefully) answer your question, you need to define a Model.  You can relatively quickly add a new model based on an existing database by using the wizard (right-click Models (folder), add New item, Data category, ADO.NET Entity Data Model).  If that&#039;s not an option, create your own model classes and look up how to create repositories (aka, your data layer).

Using LINQ (whether against your ADO.NET model or your repository data), generate a data set like this:
var results = from rec in (model name)
                     where rec.ColumnName.Equals(someArgument)
                     select rec;
return Json(results.ToList());

I hope this helps you along.  Seriously, hit the books and the online sample code (both from MS and the community).

DCC</description>
		<content:encoded><![CDATA[<p>First of all &#8230; great post, Josh!  Thank you.</p>
<p>Bryan, you have a lot of reading to do &#8230; when starting from scratch, asking novice, incremental questions will take too long (for everyone involved).  There are many examples out there for MVC, AJAX, jQuery, etc.  Granted, not quite as polished as this one! <img src='http://d1rvlzmuzboe2s.cloudfront.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>To (hopefully) answer your question, you need to define a Model.  You can relatively quickly add a new model based on an existing database by using the wizard (right-click Models (folder), add New item, Data category, ADO.NET Entity Data Model).  If that&#8217;s not an option, create your own model classes and look up how to create repositories (aka, your data layer).</p>
<p>Using LINQ (whether against your ADO.NET model or your repository data), generate a data set like this:<br />
var results = from rec in (model name)<br />
                     where rec.ColumnName.Equals(someArgument)<br />
                     select rec;<br />
return Json(results.ToList());</p>
<p>I hope this helps you along.  Seriously, hit the books and the online sample code (both from MS and the community).</p>
<p>DCC</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bryan</title>
		<link>http://www.atlanticbt.com/blog/asp-net-mvc-using-ajax-json-and-partialviews/comment-page-1/#comment-3741</link>
		<dc:creator>Bryan</dc:creator>
		<pubDate>Thu, 11 Nov 2010 03:24:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.atlanticbt.com/blog/?p=2235#comment-3741</guid>
		<description>Hi Josh - great post.  I downloaded the code and its exactly what I&#039;m looking for.  However, trying to incorporate into my project, I want to use an actual database to populate the Person list.  How do I do that?  What is the best way to do that.  I see you use a List - however how would I do this using Linq?  Sorry I&#039;m pretty new to MVC and C#.  I&#039;ve tried many different ways Cast....ToList()....but I can&#039;t seem to get it to work.  I get messages such as &quot;Cannot implicitly convert type &#039;System.Collections.Generic.List&#039; to &#039;System.Collections.Generic.List&quot;, or Cannot implicitly convert type &#039;System.Collections.Generic.List&#039; to &#039;System.Collections.Generic.List&#039;.  Any help would be greatly appreciated.

Thanks in advance.
-Bryan</description>
		<content:encoded><![CDATA[<p>Hi Josh &#8211; great post.  I downloaded the code and its exactly what I&#8217;m looking for.  However, trying to incorporate into my project, I want to use an actual database to populate the Person list.  How do I do that?  What is the best way to do that.  I see you use a List &#8211; however how would I do this using Linq?  Sorry I&#8217;m pretty new to MVC and C#.  I&#8217;ve tried many different ways Cast&#8230;.ToList()&#8230;.but I can&#8217;t seem to get it to work.  I get messages such as &#8220;Cannot implicitly convert type &#8216;System.Collections.Generic.List&#8217; to &#8216;System.Collections.Generic.List&#8221;, or Cannot implicitly convert type &#8216;System.Collections.Generic.List&#8217; to &#8216;System.Collections.Generic.List&#8217;.  Any help would be greatly appreciated.</p>
<p>Thanks in advance.<br />
-Bryan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh</title>
		<link>http://www.atlanticbt.com/blog/asp-net-mvc-using-ajax-json-and-partialviews/comment-page-1/#comment-3578</link>
		<dc:creator>Josh</dc:creator>
		<pubDate>Thu, 12 Aug 2010 14:00:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.atlanticbt.com/blog/?p=2235#comment-3578</guid>
		<description>Shawn,

That&#039;s a good question.  Maybe you could ask the original poster at http://craftycodeblog.com/2010/05/15/asp-net-mvc-render-partial-view-to-string/.

When you say it &quot;blows up,&quot; what does it do?  Are you getting a particular exception?  (are you using MVC 2?)</description>
		<content:encoded><![CDATA[<p>Shawn,</p>
<p>That&#8217;s a good question.  Maybe you could ask the original poster at <a href="http://craftycodeblog.com/2010/05/15/asp-net-mvc-render-partial-view-to-string/" rel="nofollow">http://craftycodeblog.com/2010/05/15/asp-net-mvc-render-partial-view-to-string/</a>.</p>
<p>When you say it &#8220;blows up,&#8221; what does it do?  Are you getting a particular exception?  (are you using MVC 2?)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shawn</title>
		<link>http://www.atlanticbt.com/blog/asp-net-mvc-using-ajax-json-and-partialviews/comment-page-1/#comment-3577</link>
		<dc:creator>Shawn</dc:creator>
		<pubDate>Wed, 11 Aug 2010 19:11:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.atlanticbt.com/blog/?p=2235#comment-3577</guid>
		<description>How do you unit test the JsonAdd method?  For me the RenderPartialViewToString method blows up.  I&#039;ve been trying to use mocks etc, to work around it, but so far no luck.</description>
		<content:encoded><![CDATA[<p>How do you unit test the JsonAdd method?  For me the RenderPartialViewToString method blows up.  I&#8217;ve been trying to use mocks etc, to work around it, but so far no luck.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mazhar</title>
		<link>http://www.atlanticbt.com/blog/asp-net-mvc-using-ajax-json-and-partialviews/comment-page-1/#comment-3482</link>
		<dc:creator>mazhar</dc:creator>
		<pubDate>Sun, 13 Jun 2010 04:25:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.atlanticbt.com/blog/?p=2235#comment-3482</guid>
		<description>was a great help</description>
		<content:encoded><![CDATA[<p>was a great help</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh</title>
		<link>http://www.atlanticbt.com/blog/asp-net-mvc-using-ajax-json-and-partialviews/comment-page-1/#comment-3235</link>
		<dc:creator>Josh</dc:creator>
		<pubDate>Tue, 01 Jun 2010 13:18:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.atlanticbt.com/blog/?p=2235#comment-3235</guid>
		<description>Daniel,

In the actual project that I was working on, I did use jQuery dialog Modal to pop up and then add the person.  I did the same for the &quot;Edit&quot; as well.</description>
		<content:encoded><![CDATA[<p>Daniel,</p>
<p>In the actual project that I was working on, I did use jQuery dialog Modal to pop up and then add the person.  I did the same for the &#8220;Edit&#8221; as well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel</title>
		<link>http://www.atlanticbt.com/blog/asp-net-mvc-using-ajax-json-and-partialviews/comment-page-1/#comment-3203</link>
		<dc:creator>Daniel</dc:creator>
		<pubDate>Fri, 28 May 2010 15:49:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.atlanticbt.com/blog/?p=2235#comment-3203</guid>
		<description>First of all, awesome post =)

Now for some personal ranting: Just spent the full week trying to implement something similar and when I finally reach the add part on Friday i found your post =P

You could use the jQuery UI dialog to add a Person. a quick example:

On the View that call the add Person View put the following script:

$(&quot;#dialog-form&quot;).dialog({
	autoOpen: false,
	modal: true,
	title: &#039;Add Person&#039;,
	buttons: {
		Cancel: function() {
			$(this).dialog(&#039;close&#039;);
		},
		&#039;Ok&#039;: function() {
			$(this).dialog(&#039;close&#039;);
			$.ajax({
                        	type: &quot;POST&quot;,
                        	url: &quot;/Person/JsonAdd&quot;,
                        	data: &quot;FirstName =&quot; + $(&#039;#FirstName &#039;).val() + &quot;&amp;LastName =&quot; + $(&#039;#LastName &#039;).val(),
                        	success: function(result) {
				    $(&quot;#contactlistform&quot;).html(result.PartialViewHtml);
				}               
			});
		}
	},
});

and place the AddPerson partial view inside a div with id=dialog-form.
This should do the trick =)</description>
		<content:encoded><![CDATA[<p>First of all, awesome post =)</p>
<p>Now for some personal ranting: Just spent the full week trying to implement something similar and when I finally reach the add part on Friday i found your post =P</p>
<p>You could use the jQuery UI dialog to add a Person. a quick example:</p>
<p>On the View that call the add Person View put the following script:</p>
<p>$(&#8220;#dialog-form&#8221;).dialog({<br />
	autoOpen: false,<br />
	modal: true,<br />
	title: &#8216;Add Person&#8217;,<br />
	buttons: {<br />
		Cancel: function() {<br />
			$(this).dialog(&#8216;close&#8217;);<br />
		},<br />
		&#8216;Ok&#8217;: function() {<br />
			$(this).dialog(&#8216;close&#8217;);<br />
			$.ajax({<br />
                        	type: &#8220;POST&#8221;,<br />
                        	url: &#8220;/Person/JsonAdd&#8221;,<br />
                        	data: &#8220;FirstName =&#8221; + $(&#8216;#FirstName &#8216;).val() + &#8220;&amp;LastName =&#8221; + $(&#8216;#LastName &#8216;).val(),<br />
                        	success: function(result) {<br />
				    $(&#8220;#contactlistform&#8221;).html(result.PartialViewHtml);<br />
				}<br />
			});<br />
		}<br />
	},<br />
});</p>
<p>and place the AddPerson partial view inside a div with id=dialog-form.<br />
This should do the trick =)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 1/14 queries in 0.009 seconds using disk: basic
Object Caching 355/356 objects using disk: basic
Content Delivery Network via d1rvlzmuzboe2s.cloudfront.net

Served from: www.atlanticbt.com @ 2012-02-08 16:53:04 -->
