<?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: Using jQuery to directly call ASP.NET AJAX page methods</title>
	<atom:link href="http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/feed/" rel="self" type="application/rss+xml" />
	<link>http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/</link>
	<description>ASP.NET and AJAX code, ideas, and examples.</description>
	<lastBuildDate>Fri, 12 Mar 2010 17:47:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Dave Ward</title>
		<link>http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/#comment-38164</link>
		<dc:creator>Dave Ward</dc:creator>
		<pubDate>Mon, 01 Mar 2010 03:10:23 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=77#comment-38164</guid>
		<description>Yes, the content-type is necessary.  If you call a page method without the correct content-type (or with a method other than POST), ASP.NET will treat the request as a normal GET request to the ASPX page itself.</description>
		<content:encoded><![CDATA[<p>Yes, the content-type is necessary.  If you call a page method without the correct content-type (or with a method other than POST), ASP.NET will treat the request as a normal GET request to the ASPX page itself.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ron</title>
		<link>http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/#comment-38163</link>
		<dc:creator>Ron</dc:creator>
		<pubDate>Mon, 01 Mar 2010 00:54:42 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=77#comment-38163</guid>
		<description>First of all, many thanks to Dave Ward. It&#039;s just fantastic work. 
However, Dave, I have one question. Is it neccessary to include contentType: &quot;application/json; charset=utf-8&quot; in our ajax call ? My call was returning error without this, if I enter any other dataType option like html,text,xml etc. Also, if I don&#039;t write anything at all, it returns the entire page html, though I&#039;m calling a page method.</description>
		<content:encoded><![CDATA[<p>First of all, many thanks to Dave Ward. It&#8217;s just fantastic work.<br />
However, Dave, I have one question. Is it neccessary to include contentType: &#8220;application/json; charset=utf-8&#8243; in our ajax call ? My call was returning error without this, if I enter any other dataType option like html,text,xml etc. Also, if I don&#8217;t write anything at all, it returns the entire page html, though I&#8217;m calling a page method.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BinzBlog &#187; Unit Testing Javascript</title>
		<link>http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/#comment-38159</link>
		<dc:creator>BinzBlog &#187; Unit Testing Javascript</dc:creator>
		<pubDate>Sat, 27 Feb 2010 16:27:03 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=77#comment-38159</guid>
		<description>[...] calls have to be static and must be decorated with the [Webmethod] attribute.   Here is a great blog post going into great detail about exactly how to call an ASP.net pagemethod from jQuery.  We [...]</description>
		<content:encoded><![CDATA[<p>[...] calls have to be static and must be decorated with the [Webmethod] attribute.   Here is a great blog post going into great detail about exactly how to call an ASP.net pagemethod from jQuery.  We [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: billigflug</title>
		<link>http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/#comment-38151</link>
		<dc:creator>billigflug</dc:creator>
		<pubDate>Fri, 26 Feb 2010 15:04:49 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=77#comment-38151</guid>
		<description>This blog is my favorite, congratulates.</description>
		<content:encoded><![CDATA[<p>This blog is my favorite, congratulates.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JK</title>
		<link>http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/#comment-38139</link>
		<dc:creator>JK</dc:creator>
		<pubDate>Thu, 25 Feb 2010 01:58:11 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=77#comment-38139</guid>
		<description>Thanks, it was pretty easy to get /GetDate working by following your example.

The next thing I did was to add /HelloWorld to the same .aspx page.  The result:  &quot;Unknown web method&quot; Say what?

I&#039;ve googled this high and low and found some stuff about VS caching the autogenerated code.  But I cleared everything I can find and still had this error.

Then I found the reason - I forgot to make it static.

I just want to say thanks a lot .NET for allowing a webmethod to compile when it wasnt static.  Thanks a lot .NET for the *really* helpful error message that I spent hours trying to resolve.</description>
		<content:encoded><![CDATA[<p>Thanks, it was pretty easy to get /GetDate working by following your example.</p>
<p>The next thing I did was to add /HelloWorld to the same .aspx page.  The result:  &#8220;Unknown web method&#8221; Say what?</p>
<p>I&#8217;ve googled this high and low and found some stuff about VS caching the autogenerated code.  But I cleared everything I can find and still had this error.</p>
<p>Then I found the reason &#8211; I forgot to make it static.</p>
<p>I just want to say thanks a lot .NET for allowing a webmethod to compile when it wasnt static.  Thanks a lot .NET for the *really* helpful error message that I spent hours trying to resolve.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Umzug München</title>
		<link>http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/#comment-38126</link>
		<dc:creator>Umzug München</dc:creator>
		<pubDate>Tue, 23 Feb 2010 21:15:29 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=77#comment-38126</guid>
		<description>Hello, Very good article. I will continue to pursue this article, as it is written is very interesting. Since we are interpreted very much on good information. Best regards :-)</description>
		<content:encoded><![CDATA[<p>Hello, Very good article. I will continue to pursue this article, as it is written is very interesting. Since we are interpreted very much on good information. Best regards :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bogdan</title>
		<link>http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/#comment-38008</link>
		<dc:creator>bogdan</dc:creator>
		<pubDate>Wed, 10 Feb 2010 07:24:48 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=77#comment-38008</guid>
		<description>Thanks for the reply; i only asked because i currently am searching for ways to get rid of ScriptManager and all the axd files it produces(i had a update panel implementation). It&#039;s just to much and i find it to be quite a waist of resources.
So, my priority is to have ajax without all those files. 

We tried to find a way to keep PageMethods without ScriptManager, or somehow to call a server side function from Javascript in front end, but that did not work till now. 
What we could do, is to use a aspx file as a source for XmlHTTPRequest. It is ok, meaning that it does the job. However, i would like to implement your idea, so i will try it as you suggested.

Thank you,</description>
		<content:encoded><![CDATA[<p>Thanks for the reply; i only asked because i currently am searching for ways to get rid of ScriptManager and all the axd files it produces(i had a update panel implementation). It&#8217;s just to much and i find it to be quite a waist of resources.<br />
So, my priority is to have ajax without all those files. </p>
<p>We tried to find a way to keep PageMethods without ScriptManager, or somehow to call a server side function from Javascript in front end, but that did not work till now.<br />
What we could do, is to use a aspx file as a source for XmlHTTPRequest. It is ok, meaning that it does the job. However, i would like to implement your idea, so i will try it as you suggested.</p>
<p>Thank you,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Ward</title>
		<link>http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/#comment-37999</link>
		<dc:creator>Dave Ward</dc:creator>
		<pubDate>Tue, 09 Feb 2010 18:21:58 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=77#comment-37999</guid>
		<description>If I understand, what&#039;s getting you is that changes to a &quot;global&quot; variable in that Page instance isn&#039;t necessarily visible to the webmethod call in a separate HttpContext.  Consider using a Session variable instead, which is shared as you would expect.</description>
		<content:encoded><![CDATA[<p>If I understand, what&#8217;s getting you is that changes to a &#8220;global&#8221; variable in that Page instance isn&#8217;t necessarily visible to the webmethod call in a separate HttpContext.  Consider using a Session variable instead, which is shared as you would expect.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Ward</title>
		<link>http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/#comment-37998</link>
		<dc:creator>Dave Ward</dc:creator>
		<pubDate>Tue, 09 Feb 2010 18:17:50 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=77#comment-37998</guid>
		<description>Yes.  You need the ASP.NET AJAX Extensions v1.0 installed and your project&#039;s web.config updated accordingly to expose the &quot;page method&quot; functionality.

You&#039;ll also need to be aware that &lt;a href=&quot;http://encosia.com/2009/02/10/a-breaking-change-between-versions-of-aspnet-ajax/&quot; rel=&quot;nofollow&quot;&gt;the &quot;.d&quot; isn&#039;t present&lt;/a&gt; in the response from 2.0 JSON services.</description>
		<content:encoded><![CDATA[<p>Yes.  You need the ASP.NET AJAX Extensions v1.0 installed and your project&#8217;s web.config updated accordingly to expose the &#8220;page method&#8221; functionality.</p>
<p>You&#8217;ll also need to be aware that <a href="http://encosia.com/2009/02/10/a-breaking-change-between-versions-of-aspnet-ajax/" rel="nofollow">the &#8220;.d&#8221; isn&#8217;t present</a> in the response from 2.0 JSON services.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bogdan</title>
		<link>http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/#comment-37992</link>
		<dc:creator>bogdan</dc:creator>
		<pubDate>Tue, 09 Feb 2010 08:41:31 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=77#comment-37992</guid>
		<description>Hello,

Can this be done in .net 2.0 Framework?

thank you,</description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>Can this be done in .net 2.0 Framework?</p>
<p>thank you,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/#comment-37945</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Tue, 02 Feb 2010 07:49:53 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=77#comment-37945</guid>
		<description>And that is what I was doing - I would use a webmethod call to a function that would return to me the value of a global variable in the code-behind.  I did this for 2 variables, one function each.  That global variable would get updated as the server code ran - as it was polling records in a database in a &quot;foreach&quot; loop and updating this global counter variable as it went.  Another global variable was assigned dt.Rows.Count - the total rows in the DataTable, and had a webmethod function call for it.  Problem was, even though I had a JavaScript function to ask for the value in a loop until it equaled the total rows, it never showed progress, it was just instantaneous - the postback didn&#039;t happen until the database loop had run.  By then, you get a bar that is all the way done, instead of one that got generated on the fly as the database was being looped.  If you have a way to do this with jQuery, please share, but I couldn&#039;t get it to run until the server-side code completed, by which time it was too late to show its progress in a progress bar.  Appreciate the help.

Thanks, Tom</description>
		<content:encoded><![CDATA[<p>And that is what I was doing &#8211; I would use a webmethod call to a function that would return to me the value of a global variable in the code-behind.  I did this for 2 variables, one function each.  That global variable would get updated as the server code ran &#8211; as it was polling records in a database in a &#8220;foreach&#8221; loop and updating this global counter variable as it went.  Another global variable was assigned dt.Rows.Count &#8211; the total rows in the DataTable, and had a webmethod function call for it.  Problem was, even though I had a JavaScript function to ask for the value in a loop until it equaled the total rows, it never showed progress, it was just instantaneous &#8211; the postback didn&#8217;t happen until the database loop had run.  By then, you get a bar that is all the way done, instead of one that got generated on the fly as the database was being looped.  If you have a way to do this with jQuery, please share, but I couldn&#8217;t get it to run until the server-side code completed, by which time it was too late to show its progress in a progress bar.  Appreciate the help.</p>
<p>Thanks, Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Ward</title>
		<link>http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/#comment-37943</link>
		<dc:creator>Dave Ward</dc:creator>
		<pubDate>Tue, 02 Feb 2010 02:12:58 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=77#comment-37943</guid>
		<description>The idea is that you&#039;d poll your server-side process for its progress and adjust the jQuery progress bar after each callback.  That&#039;s what you described in your previous comment, isn&#039;t it?</description>
		<content:encoded><![CDATA[<p>The idea is that you&#8217;d poll your server-side process for its progress and adjust the jQuery progress bar after each callback.  That&#8217;s what you described in your previous comment, isn&#8217;t it?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/#comment-37942</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Tue, 02 Feb 2010 02:03:02 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=77#comment-37942</guid>
		<description>The only problem with the jQuery issue, at least in my case, it was that the server-side code with all finish before the jQuery (client-side) code with go through and build a bar.  This had to happen while a server-side event was going on, not after it was already done.</description>
		<content:encoded><![CDATA[<p>The only problem with the jQuery issue, at least in my case, it was that the server-side code with all finish before the jQuery (client-side) code with go through and build a bar.  This had to happen while a server-side event was going on, not after it was already done.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Ward</title>
		<link>http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/#comment-37909</link>
		<dc:creator>Dave Ward</dc:creator>
		<pubDate>Sat, 30 Jan 2010 01:06:44 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=77#comment-37909</guid>
		<description>You could use the &lt;a href=&quot;http://jqueryui.com/demos/progressbar/&quot; rel=&quot;nofollow&quot;&gt;jQuery UI Progressbar widget&lt;/a&gt; to handle that more cleanly than with a table.  Assuming the service always returns an integer, something like:

&lt;pre lang=&quot;javascript&quot;&gt;function QueryService() {
  $.ajax({
    type: &quot;POST&quot;,
    url: &quot;PageName.aspx/MethodName&quot;,
    data: &quot;{}&quot;,
    contentType: &quot;application/json; charset=utf-8&quot;,
    dataType: &quot;json&quot;,
    success: function(msg) {
      // Update the progress bar completion amount.
      $(&#039;#progressbar&#039;).progressbar({ value: msg });

      // If not finished, do it all again.
      if (msg &lt; 100) {
        QueryService();
      }
    }
  });
}&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>You could use the <a href="http://jqueryui.com/demos/progressbar/" rel="nofollow">jQuery UI Progressbar widget</a> to handle that more cleanly than with a table.  Assuming the service always returns an integer, something like:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> QueryService<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  $.<span style="color: #660066;">ajax</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
    type<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;POST&quot;</span><span style="color: #339933;">,</span>
    url<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;PageName.aspx/MethodName&quot;</span><span style="color: #339933;">,</span>
    data<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;{}&quot;</span><span style="color: #339933;">,</span>
    contentType<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;application/json; charset=utf-8&quot;</span><span style="color: #339933;">,</span>
    dataType<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;json&quot;</span><span style="color: #339933;">,</span>
    success<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>msg<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #006600; font-style: italic;">// Update the progress bar completion amount.</span>
      $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#progressbar'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">progressbar</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> value<span style="color: #339933;">:</span> msg <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #006600; font-style: italic;">// If not finished, do it all again.</span>
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>msg <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        QueryService<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/#comment-37865</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Mon, 25 Jan 2010 22:48:34 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=77#comment-37865</guid>
		<description>Was finally able to get it working to retrieve my value from the server-side.  Was using the wrong version of jQuery before and forgot to update the webmethod name in the Default.js.

Is there a way to query the same webmethod over and over again until it reaches a certain value (i.e. 100), but report that value in the form of a table cell width, instead of as Div text?  Basically trying to create a progress bar...  table has 2 cells - first would grow as the other shrinks.</description>
		<content:encoded><![CDATA[<p>Was finally able to get it working to retrieve my value from the server-side.  Was using the wrong version of jQuery before and forgot to update the webmethod name in the Default.js.</p>
<p>Is there a way to query the same webmethod over and over again until it reaches a certain value (i.e. 100), but report that value in the form of a table cell width, instead of as Div text?  Basically trying to create a progress bar&#8230;  table has 2 cells &#8211; first would grow as the other shrinks.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
