<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Jigar Desai : Prototype.js</title><link>http://weblogs.asp.net/jigardesai/archive/tags/Prototype.js/default.aspx</link><description>Tags: Prototype.js</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>AJAX Get Request using ASP.NET MVC &amp; Prototype</title><link>http://weblogs.asp.net/jigardesai/archive/2008/01/26/Simple-AJAX-Get-Request-using-ASP.NET-MVC-and-Prototype.aspx</link><pubDate>Sun, 27 Jan 2008 04:38:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:5658178</guid><dc:creator>jigar</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/jigardesai/rsscomments.aspx?PostID=5658178</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/jigardesai/commentapi.aspx?PostID=5658178</wfw:comment><comments>http://weblogs.asp.net/jigardesai/archive/2008/01/26/Simple-AJAX-Get-Request-using-ASP.NET-MVC-and-Prototype.aspx#comments</comments><description>I have been itching to work with ASP.NET MVC since first preview came out. In past I have used &lt;A href="http://www.rubyonrails.com/" mce_href="http://www.rubyonrails.com/"&gt;ROR&lt;/A&gt; and &lt;A href="http://www.castleproject.org/monorail/index.html" mce_href="http://www.castleproject.org/monorail/index.html"&gt;MonoRail&lt;/A&gt; frame work for prototyping small sample applications. I was really impressed with AJAX implementation in both frameworks, so it seemed logical to start with AJAX, However to make it more interesting I decided to use &lt;A href="http://www.prototypejs.org/" mce_href="http://www.prototypejs.org/"&gt;Prototype Javascript Framework&lt;/A&gt; instead of Microsoft AJAX implementation. 
&lt;H2&gt;About Prototype&lt;/H2&gt;
&lt;P&gt;&lt;A href="http://www.prototypejs.org/" mce_href="http://www.prototypejs.org/"&gt;Prototype JavaScript Framework&lt;/A&gt; enables you to deal with Ajax calls in a very easy way and it is also cross-browser. It provides few simple functions to encapsulate AJAX request.&lt;/P&gt;
&lt;H2&gt;Simple MasterDetail Page.&lt;/H2&gt;
&lt;P&gt;Very simple master detail page which will display list of users, when you click on "Show Details" link it will display user details. It’s simple and done lot of time before but this time we will do that with Prototype and ASP.NET MVC Framework.&lt;/P&gt;
&lt;P&gt;&lt;IMG title="Simple Master detail page" height=438 alt="Simple Master detail page" src="http://weblogs.asp.net/blogs/jigardesai/SimpleAJAX-01.jpg" width=271 mce_src="http://weblogs.asp.net/blogs/jigardesai/SimpleAJAX-01.jpg"&gt;&amp;nbsp;&lt;/P&gt;
&lt;H2&gt;The Controller&lt;/H2&gt;
&lt;P&gt;I have a User controller which has two actions, Index action is responsible for getting list of users and UserDetail&amp;nbsp;action is responsible for getting single user.&lt;/P&gt;
&lt;P&gt;&lt;IMG title="Simple AJAX Controller" height=251 alt="Simple AJAX Controller" src="http://weblogs.asp.net/blogs/jigardesai/SimpleAjaxController.jpg" width=476 mce_src="http://weblogs.asp.net/blogs/jigardesai/SimpleAjaxController.jpg"&gt; &lt;/P&gt;
&lt;H2&gt;The User listing View&lt;/H2&gt;
&lt;P&gt;I have Index.aspx view in /Views/SimpleAjax folder, this view is responsible for displaying list of users and link to JavaScript function which renders user details. I have used Ajax.Updater function to call remote page. Ajax.Updater can make request to remote page to receive HTML fragment that updates parts of the document.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;IMG title="User Listing View" height=407 alt="User Listing View" src="http://weblogs.asp.net/blogs/jigardesai/SimpleAjaxUserListView.jpg" width=647 mce_src="http://weblogs.asp.net/blogs/jigardesai/SimpleAjaxUserListView.jpg"&gt;&lt;/P&gt;
&lt;H2&gt;The User Detail View&lt;/H2&gt;
&lt;P&gt;Finally I have User.aspx view in /Views/SimpleAjax folder it can be used&amp;nbsp; as either partial view or AJAX callable, this view will simply spit out HTML without html,head and body tags. &lt;/P&gt;&lt;IMG title="User View" height=239 alt="User View" src="http://weblogs.asp.net/blogs/jigardesai/SimpleAjaxUserView.jpg" width=618 mce_src="http://weblogs.asp.net/blogs/jigardesai/SimpleAjaxUserView.jpg"&gt;&lt;BR&gt;
&lt;H2&gt;What’s Next&lt;/H2&gt;
&lt;P&gt;Instead of calling Prototype functions directly you also can create UI Helper methods to emit appropriate JavaScript and HTML. I will try to touch on UI Helper methods and more AJAX samples with prototype in my future blogs.&lt;/P&gt;
&lt;P&gt;Full sample source code is available &lt;A href="http://weblogs.asp.net/blogs/jigardesai/ExperimentsWithMVCAJAX.zip" mce_href="http://weblogs.asp.net/blogs/jigardesai/ExperimentsWithMVCAJAX.zip"&gt;here&lt;/A&gt; &lt;BR&gt;&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=5658178" width="1" height="1"&gt;</description><enclosure url="http://weblogs.asp.net/jigardesai/attachment/5658178.ashx" length="61342" type="application/zip" /><category domain="http://weblogs.asp.net/jigardesai/archive/tags/Ajax.Updater/default.aspx">Ajax.Updater</category><category domain="http://weblogs.asp.net/jigardesai/archive/tags/Prototype.js/default.aspx">Prototype.js</category><category domain="http://weblogs.asp.net/jigardesai/archive/tags/ASP.Net+MVC/default.aspx">ASP.Net MVC</category><category domain="http://weblogs.asp.net/jigardesai/archive/tags/AJAX/default.aspx">AJAX</category></item></channel></rss>