<?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>Rick Schott :: devlpr.net</title>
	<atom:link href="http://blog.devlpr.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.devlpr.net</link>
	<description></description>
	<lastBuildDate>Tue, 30 Apr 2013 15:40:21 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Supporting WebForm Postbacks in a Non-WebForms application</title>
		<link>http://blog.devlpr.net/2013/04/30/supporting-webform-postbacks-in-anon-webforms-application/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=supporting-webform-postbacks-in-anon-webforms-application</link>
		<comments>http://blog.devlpr.net/2013/04/30/supporting-webform-postbacks-in-anon-webforms-application/#comments</comments>
		<pubDate>Tue, 30 Apr 2013 15:40:21 +0000</pubDate>
		<dc:creator>rick schott</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://blog.devlpr.net/?p=735</guid>
		<description><![CDATA[This is a little crazy but it does work. I have a mobile application framework to uses a couple legacy ASP.NET controls. I had a need for them to support postbacks. The real problem I have is that I don&#8217;t support ViewState, I don&#8217;t have a ScriptManager and my pages load via AJAX inside the [...]]]></description>
				<content:encoded><![CDATA[<p>This is a little crazy but it does work.  I have a mobile application framework to uses a couple legacy ASP.NET controls.  I had a need for them to support postbacks.  The real problem I have is that I don&#8217;t support <code>ViewState</code>, I don&#8217;t have a <code>ScriptManager </code>and my pages load via AJAX inside the jQuery Mobile framework.  </p>
<p>So, even when ASP.NET recognized these controls needs more, my mobile framework ignores its, so what do to? I added some ASP.NET shims for <code>__doPostBack </code>and <code>WebForm_FireDefaultButton</code>.</p>
<p>[sourcecode language="html"]<br />
&lt;!doctype html&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
     &#8230;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
    &lt;form id=&quot;Form1&quot; runat=&quot;server&quot; action=&quot;&quot;&gt;<br />
         &#8230;<br />
    &lt;/form&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
[/sourcecode]</p>
<p>[sourcecode language="javascript"]<br />
var theForm; //stupid .net shim</p>
<p>$(function () {<br />
    try {<br />
        theForm = document.forms['Form1'];<br />
        if (!theForm) {<br />
            theForm = document.Form1;<br />
        }<br />
    } catch (e) {<br />
    }<br />
});</p>
<p>var __defaultFired = false;<br />
function WebForm_FireDefaultButton(event, target) {<br />
    var __nonMSDOMBrowser = (window.navigator.appName.toLowerCase().indexOf(&#8216;explorer&#8217;) == -1);<br />
    if (!__defaultFired &amp;&amp; event.keyCode == 13 &amp;&amp; !(event.srcElement &amp;&amp; (event.srcElement.tagName.toLowerCase() == &quot;textarea&quot;))) {<br />
        var defaultButton;<br />
        if (__nonMSDOMBrowser) {<br />
            defaultButton = document.getElementById(target);<br />
        } else {<br />
            defaultButton = document.all[target];<br />
        }<br />
        if (defaultButton &amp;&amp; typeof(defaultButton.click) != &quot;undefined&quot;) {<br />
            __defaultFired = true;<br />
            defaultButton.click();<br />
            event.cancelBubble = true;<br />
        if (event.stopPropagation) event.stopPropagation();<br />
            return false;<br />
        }<br />
    }<br />
    return true;<br />
}</p>
<p>function __doPostBack(eventTarget, eventArgument) {<br />
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {<br />
        if (!theForm.__EVENTTARGET) {<br />
            var _eventtarget = &#8216;&lt;input type=&quot;hidden&quot; name=&quot;__EVENTTARGET&quot; id=&quot;__EVENTTARGET&quot; value=&quot;&quot; /&gt;&#8217;;<br />
            $(&#8216;.aspNetHidden&#8217;).append(_eventtarget);<br />
        }<br />
        if (!theForm.__EVENTARGUMENT) {<br />
             var _eventarg = &#8216;&lt;input type=&quot;hidden&quot; name=&quot;__EVENTARGUMENT&quot; id=&quot;__EVENTARGUMENT&quot; value=&quot;&quot; /&gt;&#8217;;</p>
<p>            $(&#8216;.aspNetHidden&#8217;).append(_eventarg);<br />
        }<br />
        theForm.__EVENTTARGET.value = eventTarget;<br />
        theForm.__EVENTARGUMENT.value = eventArgument;<br />
        theForm.submit();<br />
    }<br />
}<br />
[/sourcecode]</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.devlpr.net/2013/04/30/supporting-webform-postbacks-in-anon-webforms-application/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to set the ASP.NET Form Action with jQuery Mobile AJAX requests that redirect</title>
		<link>http://blog.devlpr.net/2013/02/20/how-to-set-the-asp-net-form-action-with-jquery-mobile-ajax-requests-that-redirect/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-set-the-asp-net-form-action-with-jquery-mobile-ajax-requests-that-redirect</link>
		<comments>http://blog.devlpr.net/2013/02/20/how-to-set-the-asp-net-form-action-with-jquery-mobile-ajax-requests-that-redirect/#comments</comments>
		<pubDate>Wed, 20 Feb 2013 21:17:55 +0000</pubDate>
		<dc:creator>rick schott</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[jQuery Mobile]]></category>

		<guid isPermaLink="false">http://blog.devlpr.net/?p=726</guid>
		<description><![CDATA[A major problem I have had with using ASP.NET and jQuery Mobile is that jQuery Mobile turns most requests into an AJAX call. It&#8217;s very cool, and it is the crux of the framework, also is what makes it feel like a native app instead of a web page. If you are familiar with ASP.NET [...]]]></description>
				<content:encoded><![CDATA[<p>A major problem I have had with using ASP.NET and jQuery Mobile is that jQuery Mobile turns most requests into an AJAX call.  It&#8217;s very cool, and it is the crux of the framework, also is what makes it feel like a native app instead of a web page.  If you are familiar with ASP.NET and it&#8217;s single form tag, you know it&#8217;s wants to control everything including the &#8220;action&#8221; of the form.  </p>
<p>I know I know ASP.NET MVC&#8230;etc is better for jQuery Mobile, but in this specific case, I am tied to a big giant ASP.NET custom CMS engine.</p>
<p>So, what&#8217;s happens when we take ASP.NET out of the loop(ajax request/hijacks)?  It&#8217;s not pretty and you will get all kinds of Event/ViewState errors, postbacks to the root, no events firing&#8230;etc.  I played with lots of solutions and this is the one that works for me:</p>
<p>1.  Disable ViewState and Event Validation<br />
[sourcecode language="csharp"]<br />
protected override void OnInit(EventArgs e)<br />
{<br />
    Page.EnableEventValidation = false;<br />
    Page.EnableViewState = false;<br />
    base.OnInit(e);<br />
}<br />
[/sourcecode]</p>
<p>2.  Always set the data-url of the jQuery Mobile page being viewed(this updates the browser url during a redirect)<br />
[sourcecode language="html"]<br />
&lt;div id=&quot;Home&quot; data-role=&quot;page&quot; data-url=&quot;&lt;%= Request.RawUrl %&gt;&quot;&gt;<br />
&#8230;&#8230;<br />
&lt;/div&gt;<br />
[/sourcecode]</p>
<p>3.  When the page inits set the form action with a little jQuery<br />
[sourcecode language="javascript"]<br />
$(document).bind(&#8216;pageinit&#8217;, function (event) {<br />
    var activePage = $(event.target); //&lt;&#8212;needed because $mobile.activePage isn&#8217;t available yet<br />
    $(&#8216;form&#8217;).attr(&quot;action&quot;, activePage.attr(&quot;data-url&quot;));<br />
});<br />
[/sourcecode]</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.devlpr.net/2013/02/20/how-to-set-the-asp-net-form-action-with-jquery-mobile-ajax-requests-that-redirect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to get script tags with jQuery .find from ajax result</title>
		<link>http://blog.devlpr.net/2012/04/29/how-to-get-script-tags-with-jquery-find-from-ajax-result/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-get-script-tags-with-jquery-find-from-ajax-result</link>
		<comments>http://blog.devlpr.net/2012/04/29/how-to-get-script-tags-with-jquery-find-from-ajax-result/#comments</comments>
		<pubDate>Sun, 29 Apr 2012 04:18:00 +0000</pubDate>
		<dc:creator>rick schott</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://blog.devlpr.net/?p=721</guid>
		<description><![CDATA[[sourcecode language="javascript"] $.ajax({ type: &#34;GET&#34;, dataType: &#8216;html&#8217;, contentType: &#8216;application/x-www-form-urlencoded&#8217;, url: &#8216;/url&#8217;, success: function (data) { //have to replace script or else jQuery will remove them var parsedHTML = data.replace(/script/gi, &#8216;rickscript&#8217;); $(parsedHTML).find(&#8216;rickscript&#8217;).each(function (index, domEle) { if (!$(this).attr(&#8216;src&#8217;)) { eval($(this).text()); //feeling lucky execute it } }); } }); [/sourcecode]]]></description>
				<content:encoded><![CDATA[<p>[sourcecode language="javascript"]<br />
$.ajax({<br />
    type: &quot;GET&quot;,<br />
    dataType: &#8216;html&#8217;,<br />
    contentType: &#8216;application/x-www-form-urlencoded&#8217;,<br />
    url: &#8216;/url&#8217;,<br />
    success: function (data) {<br />
        //have to replace script or else jQuery will remove them<br />
        var parsedHTML = data.replace(/script/gi, &#8216;rickscript&#8217;);<br />
        $(parsedHTML).find(&#8216;rickscript&#8217;).each(function (index, domEle) {<br />
            if (!$(this).attr(&#8216;src&#8217;)) {<br />
                eval($(this).text()); //feeling lucky execute it<br />
            }<br />
        });<br />
    }<br />
});<br />
[/sourcecode]</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.devlpr.net/2012/04/29/how-to-get-script-tags-with-jquery-find-from-ajax-result/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using ucajax to render UserControls via WCF</title>
		<link>http://blog.devlpr.net/2012/01/24/using-ucajax-to-render-usercontrol-via-wcf/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-ucajax-to-render-usercontrol-via-wcf</link>
		<comments>http://blog.devlpr.net/2012/01/24/using-ucajax-to-render-usercontrol-via-wcf/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 15:09:44 +0000</pubDate>
		<dc:creator>rick schott</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[SignalR]]></category>
		<category><![CDATA[signalR]]></category>
		<category><![CDATA[WCF]]></category>

		<guid isPermaLink="false">http://blog.devlpr.net/?p=699</guid>
		<description><![CDATA[I recently released an open source project called ucajaxÂ hosted onÂ GitHubÂ and also available viaÂ NuGet. The project&#8217;s main purpose is to render ASP.NET UserControls via web services, currently supporting WCF and WebMethods. Â  It also comes will a fullyÂ functionalÂ demo that consumes the NuGet package and can be viewed live here. There are fewÂ limitationsÂ such as postbacks, it doesn&#8217;t [...]]]></description>
				<content:encoded><![CDATA[<p>I recently released an open source project called <a href="http://www.devlpr.net/ucajax/" target="_blank">ucajax</a>Â hosted onÂ <a href="https://github.com/rickschott/uc-ajax" target="_blank">GitHub</a>Â and also available viaÂ <a href="http://nuget.org/packages/ucajax" target="_blank">NuGet</a>. The project&#8217;s main purpose is to render ASP.NET UserControls via web services, currently supporting WCF and WebMethods. Â  It also comes will a fullyÂ functionalÂ demo that consumes the <a href="http://nuget.org/packages/ucajax" target="_blank">NuGet package</a> and can be viewed live <a href="http://devlpr.net/ucajaxdemo" target="_blank">here</a>.</p>
<p>There are fewÂ limitationsÂ such as postbacks, it doesn&#8217;t support them. Â  Ucajax will also strip out resources/form tags&#8230;etc and only sends you the content of the UserControl. Â  This is done for a few reasons. Â ASP.NET will get upset if new ViewState or forms get injected into the DOM that it doesn&#8217;t know about.</p>
<p>The simplest example is the <a href="http://devlpr.net/ucajaxdemo/LoadViaClient.aspx?anotherparam=test" target="_blank">Load Via Client WCF</a> example.</p>
<p>1. Add ucajax to your project via NuGet:</p>
<p><a href="http://nuget.org/packages/ucajax"><img class="aligncenter size-full wp-image-705" title="ucajax NuGet package" src="http://www.devlpr.net/blog/wp-content/uploads/2012/01/nuget_ucajax.png" alt="" width="600" height="197" /></a></p>
<p>2. Create a UserControl:</p>
<p><em><strong>Markup:</strong></em></p>
<p>[sourcecode language="html"]</p>
<p>&lt;%@ Control Language=&quot;C#&quot; AutoEventWireup=&quot;true&quot; CodeBehind=&quot;UserControlSimple.ascx.cs&quot; Inherits=&quot;ucajax.web.Controls.UserControlSimple&quot; %&gt;</p>
<p>&lt;asp:label ID=&quot;lblTitle&quot; Text=&quot;I am a simple UserControl using asp:label&quot; runat=&quot;server&quot;/&gt;&lt;br&gt;<br />
&lt;asp:label ID=&quot;lblTextProperty1Title&quot; Text=&quot;TextProperty1 = &quot; runat=&quot;server&quot;/&gt;&lt;asp:label ID=&quot;lblTextProperty1&quot; Text=&quot;&quot; runat=&quot;server&quot;/&gt;<br />
&lt;!&#8211;and some html&#8211;&gt;&lt;br&gt;<br />
&lt;asp:hyperlink ID=&quot;hlLinkToMe&quot; Text=&quot;I am also using asp:hyperlink&quot; NavigateUrl=&quot;https://github.com/rickschott/uc-ajax&quot; runat=&quot;server&quot;/&gt;&lt;br&gt;<br />
&lt;asp:label ID=&quot;lblReload&quot; runat=&quot;server&quot; Text=&quot;Wait 30 seconds and I will reload myself using all the sever-side parameters originally used.&quot; /&gt;&lt;br&gt;<br />
&lt;asp:label ID=&quot;lblDateTime&quot; Text=&quot;&quot; runat=&quot;server&quot;/&gt;&lt;br&gt;<br />
&lt;asp:label ID=&quot;lblTextProperty2Title&quot; Text=&quot;TextProperty2 = &quot; runat=&quot;server&quot;/&gt;&lt;asp:label ID=&quot;lblTextProperty2&quot; Text=&quot;&quot; runat=&quot;server&quot;/&gt;</p>
<p>[/sourcecode]</p>
<p><em><strong>Code-behind:</strong></em></p>
<p>[sourcecode language="csharp"]<br />
namespace ucajax.web.Controls<br />
{<br />
    public partial class UserControlSimple : System.Web.UI.UserControl<br />
    {<br />
        public string TextProperty1 { get; set; }<br />
        public bool TextProperty2 { get; set; }<br />
        public bool AjaxAutoRefresh { get; set; }</p>
<p>        protected void Page_Load(object sender, EventArgs e)<br />
        {<br />
            lblTextProperty1.Text = TextProperty1;<br />
            lblTextProperty2.Text = TextProperty2.ToString();<br />
            lblDateTime.Text = &quot;Oh, look at the time: &quot; + DateTime.Now.ToString();<br />
            lblReload.Visible = AjaxAutoRefresh;<br />
        }<br />
    }<br />
}<br />
[/sourcecode]</p>
<p>3. Add some markup to a .aspx:</p>
<p>[sourcecode language="html"]<br />
&lt;div id=&quot;ajaxifyspinner&quot; class=&quot;ajaxifyspinner&quot;&gt;<br />
    &lt;asp:Image ID=&quot;imgResultsProgress&quot; ImageAlign=&quot;Middle&quot; runat=&quot;server&quot; ImageUrl=&quot;~/Images/ajax-loader.gif&quot; /&gt;<br />
&lt;/div&gt;<br />
&lt;div id=&quot;AJAXContent&quot;&gt;<br />
&lt;/div<br />
[/sourcecode]</p>
<p>4. Add some script that will render the UserControl:</p>
<p>[sourcecode language="javascript"]<br />
var baseUrl = &quot;&quot;;<br />
    $(document).ready(function () {<br />
        var model = new $.ucajax.viewModel($.ucajax.DICTIONARY_TYPE.WCF);<br />
        model.ajaxControlViewModel.ControlPath = baseUrl + &quot;Controls/UserControlSimple.ascx&quot;;<br />
        model.ajaxControlViewModel.ControlParams.push(new model.keyValuePair(&quot;TextProperty1&quot;, &quot;Set via JavaScript, rendered via WCF!&quot;));<br />
        model.ajaxControlViewModel.ControlParams.push(new model.keyValuePair(&quot;TextProperty2&quot;, &quot;True&quot;));<br />
        model.ajaxControlViewModel.ControlParams.push(new model.keyValuePair(&quot;AjaxAutoRefresh&quot;, &quot;True&quot;));</p>
<p>        $().ucajax({ contentId: &#8216;AJAXContent&#8217;,<br />
            postData: model,<br />
            RESTUrl:  baseUrl + &#8216;Service/AjaxContent.svc/GetAJAXControl&#8217;,<br />
            ajaxSpinnerId: &#8216;ajaxifyspinner&#8217;,<br />
            autoRefresh: true<br />
        });<br />
    });<br />
[/sourcecode]</p>
<p>5. You now have a UserControl rendered via a WCF web service:</p>
<p style="text-align: center;"><a href="http://devlpr.net/ucajaxdemo/LoadViaClient.aspx?anotherparam=test"><img src="http://www.devlpr.net/blog/wp-content/uploads/2012/01/jsonpost-24-2012-10-16-17-AM.png" alt="" title="JSON post" width="600" height="218" class="aligncenter size-full wp-image-718" /></a></p>
<p style="text-align: center;"><a href="http://devlpr.net/ucajaxdemo/LoadViaClient.aspx?anotherparam=test"><img class="aligncenter size-full wp-image-708" style="border-image: initial; border-width: 1px; border-color: black; border-style: solid;" title="Rendered content" src="http://www.devlpr.net/blog/wp-content/uploads/2012/01/render_1-24-2012-10-06-43-AM.png" alt="" width="596" height="256" /></a></p>
<p>Now, go create something and tell me about, would love to hear your feedback!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.devlpr.net/2012/01/24/using-ucajax-to-render-usercontrol-via-wcf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building a demo chat app in MVC3, backbone.js and a little SignalR for fun&#8230;</title>
		<link>http://blog.devlpr.net/2012/01/23/building-a-demo-chat-app-in-mvc3-backbone-js-and-a-little-signalr-for-fun/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=building-a-demo-chat-app-in-mvc3-backbone-js-and-a-little-signalr-for-fun</link>
		<comments>http://blog.devlpr.net/2012/01/23/building-a-demo-chat-app-in-mvc3-backbone-js-and-a-little-signalr-for-fun/#comments</comments>
		<pubDate>Mon, 23 Jan 2012 14:34:25 +0000</pubDate>
		<dc:creator>rick schott</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[backbone]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[backbone.js]]></category>
		<category><![CDATA[MVC3]]></category>
		<category><![CDATA[signalR]]></category>

		<guid isPermaLink="false">http://blog.devlpr.net/?p=675</guid>
		<description><![CDATA[I have been doing a lot of reading lately on backbone.js. One of the key features I wanted to explore was it&#8217;s concept of Models and how it keeps the server side in sync with RESTful JSON endpoints. What is backbone.js? BackboneÂ supplies structure to JavaScript-heavy applications by providingÂ modelsÂ with key-value binding and custom events,Â collectionsÂ with a rich [...]]]></description>
				<content:encoded><![CDATA[<p>I have been doing a lot of reading lately on <a href="http://documentcloud.github.com/backbone/" target="_blank"> backbone.js</a>. One of the key features I wanted to explore was it&#8217;s concept of <a href="http://documentcloud.github.com/backbone/#Introduction" target="_blank">Models</a> and how it keeps the server side in sync with RESTful JSON endpoints.</p>
<p><a href="https://github.com/rickschott/fire-camp"><img class="aligncenter size-full wp-image-683" title="backbone_demo" src="http://www.devlpr.net/blog/wp-content/uploads/2012/01/backbone_demo1.png" alt="" width="600" height="387" /></a></p>
<p><strong>What is backbone.js?</strong></p>
<blockquote><p><a href="http://github.com/documentcloud/backbone/">Backbone</a>Â supplies structure to JavaScript-heavy applications by providingÂ <strong>models</strong>Â with key-value binding and custom events,Â <strong>collections</strong>Â with a rich API of enumerable functions,Â <strong>views</strong>Â with declarative event handling, and connects it all to your existing application over a RESTful JSON interface.</p></blockquote>
<p>I started searching the internet to find an example in the .NET world, surely someone has an example already? Â I did run across a few posts that got me in the right direction:</p>
<p><a href="http://wekeroad.com/2011/08/11/the-backbonejs-todo-list-sample-refactored-part-1/" target="_blank">The Backbone.js Todo List Sample, Refactored â€“ Part 1</a>Â via <a href="http://twitter.com/robconery" target="_blank">@robconery</a><br />
<a href="http://www.bitcandies.com/blog/2011/asp-net-mvc3-restful-application-tutorial-with-backbone-js-part-i/"> ASP.NET MVC3 RESTful application tutorial with Backbone.js â€“ Part I</a><br />
<a href="http://www.bitcandies.com/blog/2011/asp-net-mvc3-restful-application-tutorial-with-backbone-js-%E2%80%93-part-ii//"> ASP.NET MVC3 RESTful application tutorial with Backbone.js â€“ Part II</a><br />
<a href="http://www.bitcandies.com/blog/2011/asp-net-mvc3-restful-application-tutorial-with-backbone-js-%E2%80%93-part-iii/"> ASP.NET MVC3 RESTful application tutorial with Backbone.js â€“ Part III</a><br />
<a href="https://gist.github.com/1655019" target="_blank"> A Backbone.js demo app (Sinatra Backend)</a>Â via <a href="https://github.com/ryandotsmith" target="_blank">ryandotsmith</a></p>
<p>The <a href="http://www.bitcandies.com" target="_blank">BitCandies</a> series was more than I needed, the last article with <a href="http://www.sinatrarb.com/intro.html" target="_blank">Sinatra </a>is what I was looking for. Â All I wanted to see was how backbone.js posts to the RESTful endpoints. Â  If I could see that in action I knew I could do the same with MVC3 <a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.jsonresult.aspx" target="_blank">JsonResults</a> in a Controller.</p>
<p><strong>The chat demo:</strong><br />
This demo uses MVC3 Controllers as the RESTful JSON endpoints utilizing the Json ActionResult. I also made a MVC3 Model called Message to keep the client and server-side parity. I cheated with persistence using a static class, no database needed to run the demo. The original demo I forked from used setInterval to poll the server for new messages. This worked but for only one client. I wanted this to work like a real chat app would, so I replaced that with <a href="https://github.com/SignalR/SignalR" target="_blank">SignalR</a> to let the clients know new messages have arrived and to update their data. <em>I know I could replace the Controllers with <a href="https://github.com/SignalR/SignalR" target="_blank">SignalR</a> all together but this is a demo to show how to use all the pieces, not a best practices.</em></p>
<p><strong>/Views/Shared/_Layout.cshtml</strong>(script references needed) </p>
<p>[sourcecode language="html"]<br />
    &#8230;&#8230;&#8230;<br />
    &lt;script src=&quot;@Url.Content(&quot;~/Scripts/jquery-1.6.4.min.js&quot;)&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;<br />
    &lt;script src=&quot;@Url.Content(&quot;~/Scripts/modernizr-1.7.min.js&quot;)&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;<br />
    &lt;script src=&quot;@Url.Content(&quot;~/Scripts/underscore.js&quot;)&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;<br />
    &lt;script src=&quot;@Url.Content(&quot;~/Scripts/backbone.js&quot;)&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;<br />
    &lt;script src=&quot;@Url.Content(&quot;~/Scripts/jquery.signalR.min.js&quot;)&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;<br />
    &lt;script src=&quot;@Url.Content(&quot;~/signalr/hubs&quot;)&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;<br />
    &#8230;&#8230;&#8230;<br />
    &lt;/body&gt;<br />
    &lt;script src=&quot;@Url.Content(&quot;~/Scripts/application.js&quot;)&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;<br />
    &#8230;&#8230;&#8230;<br />
[/sourcecode]</p>
<p><strong>/Scripts/application .js</strong> (this is basically the single page appÂ initializerÂ for this example)</p>
<p>[sourcecode language="javascript"]<br />
// SignalR Proxy created on the fly<br />
var chat = $.connection.chat;</p>
<p>var Message = Backbone.Model.extend({});</p>
<p>var MessageStore = Backbone.Collection.extend({<br />
 model: Message,<br />
   url: &#8216;/messages&#8217;<br />
});<br />
var messages = new MessageStore;</p>
<p>var MessageView = Backbone.View.extend({</p>
<p>   events: { &quot;submit #chatForm&quot; : &quot;handleNewMessage&quot; }</p>
<p>  , handleNewMessage: function(data) {<br />
    var inputField = $(&#8216;input[name=newMessageString]&#8216;);<br />
    messages.create({ content: inputField.val() });</p>
<p>    //signalr call to server<br />
    chat.send(&quot;dummy message, just signaling&quot;)<br />
            .done(function () {<br />
                console.log(&#8216;Success!&#8217;)<br />
            })<br />
            .fail(function (e) {<br />
                console.warn(e);<br />
            })<br />
    inputField.val(&#8221;);<br />
  }</p>
<p>  , render: function() {<br />
    var data = messages.map(function(message) { return message.get(&#8216;content&#8217;) + &#8216;\n&#8217;});<br />
    var result = data.reduce(function(memo,str) { return memo + str }, &#8221;);<br />
    $(&quot;#chatHistory&quot;).text(result);<br />
    return this;<br />
  }</p>
<p>});</p>
<p>messages.bind(&#8216;add&#8217;, function(message) {<br />
  messages.fetch({success: function(){view.render();}});<br />
});</p>
<p>var view = new MessageView({el: $(&#8216;#chatArea&#8217;)});</p>
<p>//replaced with SignalR<br />
//setInterval(function(){<br />
//  messages.fetch({success: function(){view.render();}});<br />
//},10000)</p>
<p>// Declare a function on the chat hub so the server can invoke it<br />
chat.reloadMessages = function (message) {<br />
    //server callback, reload messages from server via backbone!<br />
    messages.fetch({ success: function () { view.render(); } });<br />
};</p>
<p>// Start the connection<br />
$.connection.hub.start();</p>
<p>//get any messages on load, .fetch is backbone.js working here<br />
messages.fetch({ success: function () { view.render(); } });<br />
[/sourcecode]</p>
<p><strong>/Models/MessageModels.cs</strong></p>
<p>[sourcecode language="csharp"]<br />
namespace BackboneMVC3SignalR.Models<br />
{<br />
    public class Message<br />
    {<br />
        public string content { get; set; }<br />
    }</p>
<p>}<br />
[/sourcecode]</p>
<p><strong>/Controllers/MessagesController.cs</strong></p>
<p>[sourcecode language="csharp"]<br />
namespace BackboneMVC3SignalR.Controllers<br />
{<br />
    public class MessagesController : Controller<br />
    {<br />
        //<br />
        // GET: /Messages/</p>
<p>        public ActionResult Index()<br />
        {<br />
            List&lt;Message&gt; s = new List&lt;Message&gt;();<br />
            if (GlobalVariables.Messages != null)<br />
            {<br />
                s = GlobalVariables.Messages;</p>
<p>            }</p>
<p>            return Json(s, JsonRequestBehavior.AllowGet);<br />
        }</p>
<p>        [HttpPost]<br />
        public ActionResult Index(string content)<br />
        {<br />
            List&lt;Message&gt; s = new List&lt;Message&gt;();<br />
            if (GlobalVariables.Messages != null)<br />
            {<br />
                s = GlobalVariables.Messages;</p>
<p>            }<br />
            s.Add(new Message{ content = content});<br />
            GlobalVariables.Messages = s;</p>
<p>            return Json(s, JsonRequestBehavior.AllowGet);</p>
<p>        }</p>
<p>    }<br />
}<br />
[/sourcecode]</p>
<p><strong>/Hubs/Chat.cs</strong></p>
<p>[sourcecode language="csharp"]<br />
namespace BackboneMVC3SignalR.Hubs<br />
{<br />
    public class Chat : Hub<br />
    {<br />
        public void Send(string message)<br />
        {<br />
            // Call the reloadMessages method on all clients<br />
            Clients.reloadMessages(message);<br />
        }<br />
    }<br />
}<br />
[/sourcecode]</p>
<p>Full working demo can be found on <a href="https://github.com/rickschott/fire-camp">GitHub</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.devlpr.net/2012/01/23/building-a-demo-chat-app-in-mvc3-backbone-js-and-a-little-signalr-for-fun/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Postback UpatePanel on close of jQuery dialog</title>
		<link>http://blog.devlpr.net/2011/11/15/postback-upatepanel-on-close-of-jquery-dialog/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=postback-upatepanel-on-close-of-jquery-dialog</link>
		<comments>http://blog.devlpr.net/2011/11/15/postback-upatepanel-on-close-of-jquery-dialog/#comments</comments>
		<pubDate>Tue, 15 Nov 2011 18:43:41 +0000</pubDate>
		<dc:creator>rick schott</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://blog.devlpr.net/?p=646</guid>
		<description><![CDATA[Put a hidden asp:button within the UpdatePanel or outside and set it as an AsyncPostBackTrigger. Call the js function from ItemDataBound if needed, passing in the ClientID of the hidden asp:button. The js function will call the click event on the button passed in once the &#8220;OK&#8221; or whatever you set buttonTxt to, button is [...]]]></description>
				<content:encoded><![CDATA[<ul>
<li>Put a hidden <code>asp:button</code> within the <code>UpdatePanel </code> or outside and set it as an <code>AsyncPostBackTrigger</code>.</li>
<li>Call the js function from <code>ItemDataBound </code>if needed, passing in the <code>ClientID </code>of the hidden<code> asp:button</code>.</li>
<li>The js function will call the click event on the button passed in once the &#8220;OK&#8221; or whatever you set <code>buttonTxt </code>to, button is clicked.</li>
<li>You can then handle the <code>UpdatePanel.Update</code> automatically if the button is inside the <code>UpdatePanel </code>or call <code>Update </code>within the <code>butHidden_Click</code>.</li>
</ul>
<p><strong>Markup:</strong></p>
<p>[sourcecode language="xml"]<br />
    &lt;asp:UpdatePanel runat=&quot;server&quot; ID=&quot;UpdatePanel1&quot;&gt;<br />
         &lt;asp:button id=&quot;btnHidden&quot; style=&quot;display:none&quot; runat=&quot;server&quot; onclick=&quot;btnHidden_Click&quot;/&gt;<br />
     &lt;/asp:UpdatePanel&gt;<br />
[/sourcecode]</p>
<p><strong>Script:</strong><br />
[sourcecode language="javascript"]<br />
       function showjQueryUIDialogOkBtnCallback(buttonToClick, dialogSelector, buttonTxt, isModal, width, height)<br />
       {<br />
           var buttonOpts = {};<br />
           buttonOpts[buttonTxt] = function () {<br />
    	       $(&quot;#&quot; + buttonToClick).trigger(&#8216;click&#8217;);<br />
           };</p>
<p>           buttonOpts['Cancel'] = function () {<br />
    	       $(this).dialog(&quot;close&quot;);<br />
    	       $(this).dialog(&#8216;destroy&#8217;);<br />
           }</p>
<p>           $(dialogSelector).dialog({<br />
    	       resizable: false,<br />
    	       height: height,<br />
    	       width: width,<br />
    	       modal: isModal,<br />
    	       open: function (type, data) {<br />
    	           $(this).parent().appendTo(&quot;form&quot;); //won&#8217;t postback unless within the form tag<br />
    	       },<br />
    	       buttons: buttonOpts</p>
<p>           });</p>
<p>           $(dialogSelector).dialog(&#8216;open&#8217;);</p>
<p>        }<br />
[/sourcecode]</p>
<p><a href="http://stackoverflow.com/questions/8059802/asp-net-with-jquery-popup-dialog-how-to-post-back-on-dialog-closing/8059850#8059850" target="_blank">ASP.NET with jQuery popup dialog: how to post back on dialog closing</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.devlpr.net/2011/11/15/postback-upatepanel-on-close-of-jquery-dialog/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Cross browser keypress event handling</title>
		<link>http://blog.devlpr.net/2011/11/09/cross-browser-keypress-event-handling/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=cross-browser-keypress-event-handling</link>
		<comments>http://blog.devlpr.net/2011/11/09/cross-browser-keypress-event-handling/#comments</comments>
		<pubDate>Wed, 09 Nov 2011 18:46:20 +0000</pubDate>
		<dc:creator>rick schott</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://blog.devlpr.net/?p=639</guid>
		<description><![CDATA[Running example on JSFiddle: [sourcecode language="javascript"] $(document).ready(function () { $(&#34;#TextBox1&#34;).live(&#8216;keypress&#8217;, function (e) { var kCode = e.keyCode &#124;&#124; e.charCode; //cross browser check //Mozilla and Safari define e.charCode, while IE defines e.keyCode which returns the ASCII value if (kCode == 9) { $(&#34;#TextBox2&#34;).focus(); } }); }); [/sourcecode] JavaScript Madness: Keyboard Events]]></description>
				<content:encoded><![CDATA[<p>Running example on <a href="http://jsfiddle.net/xsqrd">JSFiddle</a>:</p>
<p>[sourcecode language="javascript"]<br />
$(document).ready(function () {<br />
    $(&quot;#TextBox1&quot;).live(&#8216;keypress&#8217;, function (e) {<br />
        var kCode = e.keyCode || e.charCode; //cross browser check<br />
        //Mozilla and Safari define e.charCode, while IE defines e.keyCode which returns the ASCII value<br />
        if (kCode == 9) {<br />
           $(&quot;#TextBox2&quot;).focus();<br />
        }<br />
    });<br />
});</p>
<p>[/sourcecode]</p>
<p><a href="http://unixpapa.com/js/key.html" target="_blank">JavaScript Madness: Keyboard Events</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.devlpr.net/2011/11/09/cross-browser-keypress-event-handling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Load dynamic controls without dll or project references and assign properties</title>
		<link>http://blog.devlpr.net/2011/11/04/load-dynamic-controls-without-dll-or-project-references-and-assign-properties/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=load-dynamic-controls-without-dll-or-project-references-and-assign-properties</link>
		<comments>http://blog.devlpr.net/2011/11/04/load-dynamic-controls-without-dll-or-project-references-and-assign-properties/#comments</comments>
		<pubDate>Fri, 04 Nov 2011 21:59:30 +0000</pubDate>
		<dc:creator>rick schott</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[ASP.NET 4.0]]></category>

		<guid isPermaLink="false">http://blog.devlpr.net/?p=630</guid>
		<description><![CDATA[I recently had to load an instance of a specific control within a masterpage base class that had no direct references but would be available at run-time.Â Â  Here is how I approached it. I first used LoadControl via a fully qualified assembly name.Â  I then used dynamic to set properties to bypass compile time checks: [...]]]></description>
				<content:encoded><![CDATA[<p>I recently had to load an instance of a specific control within a masterpage base class that had no direct references but would be available at run-time.Â Â  Here is how I approached it.</p>
<p>I first used <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.page.loadcontrol.aspx" target="_blank">LoadControl </a>via a fully qualified assembly name.Â  I then used <a href="http://msdn.microsoft.com/en-us/library/dd264741.aspx" target="_blank">dynamic </a>to set properties to bypass compile time checks:</p>
<p>[sourcecode language="csharp"]<br />
Control knownControl = FindControl(&quot;KnownControl&quot;);<br />
if (knownControl != null)<br />
{<br />
    string assemblyName = &quot;Com.YourNameSpace.UI&quot;;<br />
    string controlAssemblyName = string.Format(&quot;{0}.{1},{0}&quot;, assemblyName, &quot;AwesomeControl&quot;);</p>
<p>    Type type = Type.GetType(controlAssemblyName);<br />
    if (type != null)<br />
    {<br />
	dynamic control = LoadControl(type, null);<br />
	control.YourAwesomeName = &quot;Awesome Name&quot;;<br />
	control.ShowAwesomeName = true;</p>
<p>	knownControl.Controls.Add(control);<br />
    }<br />
}<br />
[/sourcecode]</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.devlpr.net/2011/11/04/load-dynamic-controls-without-dll-or-project-references-and-assign-properties/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Glimpse into the future of MVC debugging</title>
		<link>http://blog.devlpr.net/2011/04/22/a-glimpse-into-the-future-of-mvc-debugging/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-glimpse-into-the-future-of-mvc-debugging</link>
		<comments>http://blog.devlpr.net/2011/04/22/a-glimpse-into-the-future-of-mvc-debugging/#comments</comments>
		<pubDate>Fri, 22 Apr 2011 12:36:24 +0000</pubDate>
		<dc:creator>rick schott</dc:creator>
				<category><![CDATA[MVC]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://blog.devlpr.net/?p=626</guid>
		<description><![CDATA[What Firebug is for the client, Glimpse does for the server&#8230; in other words, a client side Glimpse into whats going on in your server.]]></description>
				<content:encoded><![CDATA[<blockquote><p><a href="http://getglimpse.com/" target="_blank">What Firebug is for the client, Glimpse does for the server&#8230; in other  words, a client side Glimpse into whats going on in your server.</a></p></blockquote>
<p style="text-align: center;">
<iframe title="YouTube video player" width="640" height="390" src="http://www.youtube.com/embed/ke8Rw2BGPG0" frameborder="0" allowfullscreen></iframe></p>
<p style="text-align: center;"><a href="http://nuget.org/List/Packages/Glimpse"><img class="size-full wp-image-627 aligncenter" title="Glimpse" src="http://devlpr.net.dotnet-host.com/blog/wp-content/uploads/2011/04/nugetlogo.png" alt="" width="26" height="27" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.devlpr.net/2011/04/22/a-glimpse-into-the-future-of-mvc-debugging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Infinite Scroll with MVC 2</title>
		<link>http://blog.devlpr.net/2011/04/12/jquery-infinite-scroll-with-mvc-2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jquery-infinite-scroll-with-mvc-2</link>
		<comments>http://blog.devlpr.net/2011/04/12/jquery-infinite-scroll-with-mvc-2/#comments</comments>
		<pubDate>Tue, 12 Apr 2011 17:55:36 +0000</pubDate>
		<dc:creator>rick schott</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://blog.devlpr.net/?p=611</guid>
		<description><![CDATA[The inspiration for this post came from answering a question on Stack Overflow: jQuery Infinite Scroll and Gridview Controller: [sourcecode language="csharp"] /// &#60;summary&#62; /// GET: /Widget/Search/ /// Displays search results. /// &#60;/summary&#62; /// &#60;param name=&#34;s&#34;&#62;&#60;/param&#62; /// &#60;returns&#62;&#60;/returns&#62; public ActionResult Search(SearchType searchType, string s, [DefaultValue(1)]int page) { try { int batch = 20; int fromRecord = [...]]]></description>
				<content:encoded><![CDATA[<p>The inspiration for this post came from answering a question on <a href="http://stackoverflow.com/" target="_blank">Stack Overflow</a>:<br />
<a href="http://stackoverflow.com/questions/5117934/jquery-infinite-scroll-and-gridview/5118008#5118008" target="_blank">jQuery Infinite Scroll and Gridview</a></p>
<p><strong>Controller:</strong><br />
[sourcecode language="csharp"]</p>
<p>/// &lt;summary&gt;<br />
/// GET: /Widget/Search/<br />
/// Displays search results.<br />
/// &lt;/summary&gt;<br />
/// &lt;param name=&quot;s&quot;&gt;&lt;/param&gt;<br />
/// &lt;returns&gt;&lt;/returns&gt;<br />
public ActionResult Search(SearchType searchType, string s, [DefaultValue(1)]int page)<br />
{<br />
    try<br />
    {<br />
        int batch = 20;<br />
        int fromRecord = 1;<br />
        int toRecord = batch;</p>
<p>        if(page != 1)<br />
        {<br />
            toRecord = (batch * page);<br />
            fromRecord = (toRecord &#8211; (batch-1));</p>
<p>        }</p>
<p>        var widgets= _repos.Search(searchType, s, fromRecord, toRecord );</p>
<p>        if (widgets.Count == 0)<br />
        {<br />
            InfoMsg(&quot;No widgets were found.&quot;);<br />
        }</p>
<p>        if (Request.IsAjaxRequest())<br />
        {<br />
            if(widgets.Count &gt; 0)<br />
            {<br />
                return View(&quot;SearchResultsLineItems&quot;, widgets);<br />
            }<br />
            else<br />
            {<br />
                return new ContentResult<br />
                {<br />
                    ContentType = &quot;text/html&quot;,<br />
                    Content = &quot;noresults&quot;,<br />
                    ContentEncoding = System.Text.Encoding.UTF8<br />
                };<br />
            }</p>
<p>        }</p>
<p>        return View(&quot;SearchResults&quot;, widgets);<br />
    }<br />
    catch (Exception ex)<br />
    {<br />
        return HandleError(ex);<br />
    }<br />
}</p>
<p>[/sourcecode]</p>
<p><strong>View:</strong><br />
[sourcecode language="csharp"]<br />
&lt;% if (Model.Count &gt; 0) { %&gt;<br />
    &lt;table id=&quot;tblSearchResults&quot;&gt;<br />
        &lt;tr&gt;<br />
            &lt;th&gt;&lt;/th&gt;<br />
            &lt;th&gt;Col1&lt;/th&gt;<br />
            &lt;th&gt;Col2&lt;/th&gt;<br />
            &lt;th&gt;Col3&lt;/th&gt;<br />
            &lt;th&gt;Col4&lt;/th&gt;<br />
            &lt;th&gt;Col5&lt;/th&gt;<br />
            &lt;th&gt;Col6&lt;/th&gt;<br />
        &lt;/tr&gt;<br />
        &lt;% Html.RenderPartial(&quot;SearchResultsLineItems&quot;, Model); %&gt;<br />
    &lt;/table&gt;<br />
    &lt;div id=&quot;loadingSearchResults&quot; style=&quot;text-align:center;height:24px;&quot;&gt;&lt;/div&gt;<br />
    &lt;div id=&quot;actionModal&quot; class=&quot;modal&quot;&gt;&lt;/div&gt;<br />
    &lt;% } %&gt;<br />
[/sourcecode]</p>
<p><strong>Script:</strong><br />
[sourcecode language="csharp"]</p>
<p>$(document).ready(function() {<br />
    initAutoPaging();<br />
});</p>
<p>function initAutoPaging() {<br />
    $(window).scroll(function () {<br />
        if ($(window).scrollTop() == $(document).height() &#8211; $(window).height()) {<br />
            loadMore()<br />
        }<br />
    });<br />
}</p>
<p>var current = 1;<br />
function loadMore() {<br />
    if (current &gt; -1) {<br />
        if (!_isShowingDetails)<br />
        {<br />
            if (!$(&#8216;#loadingSearchResults&#8217;).html()) {<br />
                current++;<br />
                $(&#8216;#loadingSearchResults&#8217;).show();<br />
                $(&#8216;#loadingSearchResults&#8217;).html(&quot;&lt;img src=&#8217;/content/images/loading.gif&#8217; /&gt;&quot;);<br />
                $.ajax({<br />
                    async: true,<br />
                    url: document.URL + &quot;?&amp;page=&quot; + current,<br />
                    contentType: &quot;application/x-www-form-urlencoded&quot;,<br />
                    dataType: &quot;text&quot;,<br />
                    success: function(data) {<br />
                    if (data != &#8216;noresults&#8217;) {<br />
                            $(&#8216;#tblSearchResults tr:last&#8217;).after(data);<br />
                            $(&#8216;#loadingSearchResults&#8217;).hide();<br />
                            $(&#8216;#loadingSearchResults&#8217;).html(&#8221;);<br />
                            highlightSearch();<br />
                        } else {<br />
                            current = -1;<br />
                            $(&#8216;#loadingSearchResults&#8217;).show();<br />
                            $(&#8216;#loadingSearchResults&#8217;).html(&quot;&lt;h3&gt;&lt;i&gt;&#8211; No more results &#8212; &lt;/i&gt;&lt;/h3&gt;&quot;);<br />
                        }<br />
                    }<br />
                });<br />
            }<br />
        }</p>
<p>    }<br />
}</p>
<p>[/sourcecode] </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.devlpr.net/2011/04/12/jquery-infinite-scroll-with-mvc-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
