<?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: Why do ASP.NET AJAX page methods have to be static?</title>
	<atom:link href="http://encosia.com/why-do-aspnet-ajax-page-methods-have-to-be-static/feed/" rel="self" type="application/rss+xml" />
	<link>http://encosia.com/why-do-aspnet-ajax-page-methods-have-to-be-static/</link>
	<description>ASP.NET and AJAX code, ideas, and examples.</description>
	<lastBuildDate>Thu, 02 Feb 2012 19:50:46 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: pinkPanther</title>
		<link>http://encosia.com/why-do-aspnet-ajax-page-methods-have-to-be-static/#comment-62800</link>
		<dc:creator>pinkPanther</dc:creator>
		<pubDate>Thu, 02 Feb 2012 03:06:07 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=72#comment-62800</guid>
		<description>interesting!!  THanks Dave, for this blog and the replies!!</description>
		<content:encoded><![CDATA[<p>interesting!!  THanks Dave, for this blog and the replies!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Ward</title>
		<link>http://encosia.com/why-do-aspnet-ajax-page-methods-have-to-be-static/#comment-62799</link>
		<dc:creator>Dave Ward</dc:creator>
		<pubDate>Thu, 02 Feb 2012 02:24:57 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=72#comment-62799</guid>
		<description>Yes, &lt;a href=&quot;http://encosia.com/asp-net-page-methods-are-only-as-secure-as-you-make-them/&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;you can call a page method from anywhere&lt;/a&gt;. For all intents and purposes, they&#039;re the same as ASMX ScriptServices with EnableSession defaulted to true.</description>
		<content:encoded><![CDATA[<p>Yes, <a href="http://encosia.com/asp-net-page-methods-are-only-as-secure-as-you-make-them/" target="_blank" rel="nofollow">you can call a page method from anywhere</a>. For all intents and purposes, they&#8217;re the same as ASMX ScriptServices with EnableSession defaulted to true.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pinkPanther</title>
		<link>http://encosia.com/why-do-aspnet-ajax-page-methods-have-to-be-static/#comment-62796</link>
		<dc:creator>pinkPanther</dc:creator>
		<pubDate>Wed, 01 Feb 2012 20:19:24 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=72#comment-62796</guid>
		<description>so i understand page method within a user control doesnt work.... so will it work if the page method is declared on a page hosting the user control?  i know thats silly, but just curious.  

oh wait, must the page method the javascript in the user control calls reside on a page that is hosting the user control?   so say i have test1.ascx hosted in test1.aspx.  can i in test1.ascx call test2.aspx.pageMethodName?</description>
		<content:encoded><![CDATA[<p>so i understand page method within a user control doesnt work&#8230;. so will it work if the page method is declared on a page hosting the user control?  i know thats silly, but just curious.  </p>
<p>oh wait, must the page method the javascript in the user control calls reside on a page that is hosting the user control?   so say i have test1.ascx hosted in test1.aspx.  can i in test1.ascx call test2.aspx.pageMethodName?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Ward</title>
		<link>http://encosia.com/why-do-aspnet-ajax-page-methods-have-to-be-static/#comment-61996</link>
		<dc:creator>Dave Ward</dc:creator>
		<pubDate>Wed, 18 Jan 2012 15:43:35 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=72#comment-61996</guid>
		<description>That will work.

What wouldn&#039;t work, that you may have run into before, is something like this:

&lt;pre lang=&quot;csharp&quot;&gt;public partial class _Default : Page {
  // Instance variable to use in various methods on the Page,
  //  like Page_Load or Click handlers.
  Orders orders = new Orders(customerId);

  // Will not work. The static method doesn&#039;t have access
  //  to the instance variable since the static method is
  //  shared across any number of instances of the class.
  public static float BrokenGetOrderTotal() {
    return orders.Total;
  }

  // Will work.
  public static float GetOrderTotal() {
    Orders orders = new Orders(customerId);
    return orders.Total;
  }
}&lt;/pre&gt;

Also, don&#039;t forget the &lt;code&gt;public&lt;/code&gt; on the methods. They won&#039;t work as &quot;page methods&quot; without that.</description>
		<content:encoded><![CDATA[<p>That will work.</p>
<p>What wouldn&#8217;t work, that you may have run into before, is something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #0600FF;">partial</span> <span style="color: #FF0000;">class</span> _Default <span style="color: #008000;">:</span> Page <span style="color: #000000;">&#123;</span>
  <span style="color: #008080; font-style: italic;">// Instance variable to use in various methods on the Page,</span>
  <span style="color: #008080; font-style: italic;">//  like Page_Load or Click handlers.</span>
  Orders orders <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Orders<span style="color: #000000;">&#40;</span>customerId<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
  <span style="color: #008080; font-style: italic;">// Will not work. The static method doesn't have access</span>
  <span style="color: #008080; font-style: italic;">//  to the instance variable since the static method is</span>
  <span style="color: #008080; font-style: italic;">//  shared across any number of instances of the class.</span>
  <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> <span style="color: #FF0000;">float</span> BrokenGetOrderTotal<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">return</span> orders.<span style="color: #0000FF;">Total</span><span style="color: #008000;">;</span>
  <span style="color: #000000;">&#125;</span>
&nbsp;
  <span style="color: #008080; font-style: italic;">// Will work.</span>
  <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> <span style="color: #FF0000;">float</span> GetOrderTotal<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
    Orders orders <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Orders<span style="color: #000000;">&#40;</span>customerId<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF;">return</span> orders.<span style="color: #0000FF;">Total</span><span style="color: #008000;">;</span>
  <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Also, don&#8217;t forget the <code>public</code> on the methods. They won&#8217;t work as &#8220;page methods&#8221; without that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Brown</title>
		<link>http://encosia.com/why-do-aspnet-ajax-page-methods-have-to-be-static/#comment-61991</link>
		<dc:creator>Mark Brown</dc:creator>
		<pubDate>Wed, 18 Jan 2012 13:12:51 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=72#comment-61991</guid>
		<description>Hi Dave

Great article.  I was just wondering how I can get my static method to then call other business logic in my project.  This entails me to create an instance of my business class, however, from what I remember I cannot create an instance of an object (class) from within a static method.

For example, just for simplicity.  Say I have a class that loads an object that contains orders, then within that object I have a method that returns the total value of all order and I want to use ajax to display this...

&lt;pre lang=&quot;csharp&quot;&gt;[WebMethod]
static float GetOrderTotal()
{
   Orders orders = new Orders(customerId);
   return orders.Total;
}&lt;/pre&gt;

This is the method that my jQuery ajax code will call.  But from experience this will not work as far as I remember.  

I suppose it comes down to me updating my existing applications to use Ajax, Object, Methods, Layers are already defined. 

Hopefully this makes sense and you understand what I am asking.

Thanks

Mark</description>
		<content:encoded><![CDATA[<p>Hi Dave</p>
<p>Great article.  I was just wondering how I can get my static method to then call other business logic in my project.  This entails me to create an instance of my business class, however, from what I remember I cannot create an instance of an object (class) from within a static method.</p>
<p>For example, just for simplicity.  Say I have a class that loads an object that contains orders, then within that object I have a method that returns the total value of all order and I want to use ajax to display this&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #000000;">&#91;</span>WebMethod<span style="color: #000000;">&#93;</span>
<span style="color: #0600FF;">static</span> <span style="color: #FF0000;">float</span> GetOrderTotal<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
   Orders orders <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Orders<span style="color: #000000;">&#40;</span>customerId<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
   <span style="color: #0600FF;">return</span> orders.<span style="color: #0000FF;">Total</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>This is the method that my jQuery ajax code will call.  But from experience this will not work as far as I remember.  </p>
<p>I suppose it comes down to me updating my existing applications to use Ajax, Object, Methods, Layers are already defined. </p>
<p>Hopefully this makes sense and you understand what I am asking.</p>
<p>Thanks</p>
<p>Mark</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Ward</title>
		<link>http://encosia.com/why-do-aspnet-ajax-page-methods-have-to-be-static/#comment-58279</link>
		<dc:creator>Dave Ward</dc:creator>
		<pubDate>Fri, 30 Dec 2011 19:14:50 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=72#comment-58279</guid>
		<description>I mean that you can&#039;t define a page method in an ASCX control&#039;s code behind. It will compile, but you won&#039;t be able to make requests to the .ascx/method URL.</description>
		<content:encoded><![CDATA[<p>I mean that you can&#8217;t define a page method in an ASCX control&#8217;s code behind. It will compile, but you won&#8217;t be able to make requests to the .ascx/method URL.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gireesh</title>
		<link>http://encosia.com/why-do-aspnet-ajax-page-methods-have-to-be-static/#comment-58196</link>
		<dc:creator>Gireesh</dc:creator>
		<pubDate>Fri, 30 Dec 2011 13:22:21 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=72#comment-58196</guid>
		<description>I am new to ASP.NET and page methods as well

I did&#039;t understand what do you mean by &quot;Page methods don&#039;t work with User Controls&quot;?</description>
		<content:encoded><![CDATA[<p>I am new to ASP.NET and page methods as well</p>
<p>I did&#8217;t understand what do you mean by &#8220;Page methods don&#8217;t work with User Controls&#8221;?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mahesh Parvekar</title>
		<link>http://encosia.com/why-do-aspnet-ajax-page-methods-have-to-be-static/#comment-57257</link>
		<dc:creator>Mahesh Parvekar</dc:creator>
		<pubDate>Tue, 27 Dec 2011 06:25:12 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=72#comment-57257</guid>
		<description>Hi 
gr8 article 
keep it up</description>
		<content:encoded><![CDATA[<p>Hi<br />
gr8 article<br />
keep it up</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ashraf Sabry</title>
		<link>http://encosia.com/why-do-aspnet-ajax-page-methods-have-to-be-static/#comment-54731</link>
		<dc:creator>Ashraf Sabry</dc:creator>
		<pubDate>Sat, 17 Dec 2011 19:35:22 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=72#comment-54731</guid>
		<description>Asad, you cannot do this. Page methods are not intended to manipulate a page controls, for this reason they&#039;re made static, to emphasize that they don&#039;t manipulate certain page instance. Page methods (and web service methods) are meant to accept some input and do certain processing then return output that can be consumed by client side JavaScript (or any other compatible client).

I think that your problem is candidate for UpdatePanels. Place the CheckBoxList in an UpdatePanel then place your code in a handler for an asynchronous request event.</description>
		<content:encoded><![CDATA[<p>Asad, you cannot do this. Page methods are not intended to manipulate a page controls, for this reason they&#8217;re made static, to emphasize that they don&#8217;t manipulate certain page instance. Page methods (and web service methods) are meant to accept some input and do certain processing then return output that can be consumed by client side JavaScript (or any other compatible client).</p>
<p>I think that your problem is candidate for UpdatePanels. Place the CheckBoxList in an UpdatePanel then place your code in a handler for an asynchronous request event.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Asad Malik</title>
		<link>http://encosia.com/why-do-aspnet-ajax-page-methods-have-to-be-static/#comment-54476</link>
		<dc:creator>Asad Malik</dc:creator>
		<pubDate>Fri, 16 Dec 2011 19:29:48 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=72#comment-54476</guid>
		<description>Only a guru like you can write such a great article...
and +1 for giving me confidence by telling that there are people like me who find it easier to use page methods instead of going in to webservices business.

Now, if you can help me out here:
Is there any way I can access my checkbox list (asp.net server control), in my static pageMethod. For example, i used a static variable to access my querystirng(s) etc. but I can&#039;t seem to find a way to use my checkbox list control, which needs to be populated and then updated using same Add/Update method.
Also is there a workaround for using Response.Redirect();

any suggestions/comments/thoughts are appreciated.


here is the code for reference:
&lt;pre lang=&quot;csharp&quot;&gt;
        UsersBuyersFactory objUsersBuyersFactory = new UsersBuyersFactory(conn);
        UsersBuyers objUsersBuyers = new UsersBuyers();
        objUsersBuyers.UserId = GeneralBL.CheckInteger(queryString_uid, 0);

        UsersBuyersCollection objUsersBuyersCollection;
        objUsersBuyersCollection = objUsersBuyersFactory.FindByUserId(GeneralBL.CheckInteger(queryString_uid, 0));

        for (int i = 0; i &lt; m_cblAllowedBuyers.Items.Count; i++)
        {
            if (m_cblAllowedBuyers.Items[i].Selected)
            {
                if (objUsersBuyersCollection.Items.Count == 0)
                    IsBuyerAvalaible = false;

                for (int j = 0; j &lt; objUsersBuyersCollection.Items.Count; j++)
                {
                    int? Comparer = null;
                    if (m_cblAllowedBuyers.Items[i].Value != string.Empty)
                        Comparer = int.Parse(m_cblAllowedBuyers.Items[i].Value);

                    if (objUsersBuyersCollection[j].BuyerId == Comparer)
                        IsBuyerAvalaible = true;
                    else
                        IsBuyerAvalaible = false;
                    if (IsBuyerAvalaible)
                        break;
                }
                if (!IsBuyerAvalaible)
                {
                    int? Comparer = null;
                    if (m_cblAllowedBuyers.Items[i].Value != string.Empty)
                        Comparer = int.Parse(m_cblAllowedBuyers.Items[i].Value);
                    objUsersBuyers.BuyerId = Comparer;
                    objUsersBuyersFactory.Insert(objUsersBuyers, 0);

                }
            }
        }
        for (int j = 0; j &lt; objUsersBuyersCollection.Items.Count; j++)
        {
            for (int i = 0; i &lt; m_cblAllowedBuyers.Items.Count; i++)
            {
                if (!m_cblAllowedBuyers.Items[i].Selected)
                {
                    int? Comparer = null;
                    if (m_cblAllowedBuyers.Items[i].Value != string.Empty)
                        Comparer = int.Parse(m_cblAllowedBuyers.Items[i].Value);
                    objUsersBuyers.BuyerId = Comparer;
                    objUsersBuyers.UsersBuyersId = objUsersBuyersCollection[j].UsersBuyersId;
                    objUsersBuyersFactory.Delete(objUsersBuyers, 0);
                }

            }
        }

        if (boolRedirect)
            Response.Redirect(m_bctTrail.PreviousBreadCrumb.NavigateUrl);

&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Only a guru like you can write such a great article&#8230;<br />
and +1 for giving me confidence by telling that there are people like me who find it easier to use page methods instead of going in to webservices business.</p>
<p>Now, if you can help me out here:<br />
Is there any way I can access my checkbox list (asp.net server control), in my static pageMethod. For example, i used a static variable to access my querystirng(s) etc. but I can&#8217;t seem to find a way to use my checkbox list control, which needs to be populated and then updated using same Add/Update method.<br />
Also is there a workaround for using Response.Redirect();</p>
<p>any suggestions/comments/thoughts are appreciated.</p>
<p>here is the code for reference:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">        UsersBuyersFactory objUsersBuyersFactory <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> UsersBuyersFactory<span style="color: #000000;">&#40;</span>conn<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        UsersBuyers objUsersBuyers <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> UsersBuyers<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        objUsersBuyers.<span style="color: #0000FF;">UserId</span> <span style="color: #008000;">=</span> GeneralBL.<span style="color: #0000FF;">CheckInteger</span><span style="color: #000000;">&#40;</span>queryString_uid, <span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        UsersBuyersCollection objUsersBuyersCollection<span style="color: #008000;">;</span>
        objUsersBuyersCollection <span style="color: #008000;">=</span> objUsersBuyersFactory.<span style="color: #0000FF;">FindByUserId</span><span style="color: #000000;">&#40;</span>GeneralBL.<span style="color: #0000FF;">CheckInteger</span><span style="color: #000000;">&#40;</span>queryString_uid, <span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> i <span style="color: #008000;">&lt;</span> m_cblAllowedBuyers.<span style="color: #0000FF;">Items</span>.<span style="color: #0000FF;">Count</span><span style="color: #008000;">;</span> i<span style="color: #008000;">++</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>m_cblAllowedBuyers.<span style="color: #0000FF;">Items</span><span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">Selected</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>objUsersBuyersCollection.<span style="color: #0000FF;">Items</span>.<span style="color: #0000FF;">Count</span> <span style="color: #008000;">==</span> <span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span>
                    IsBuyerAvalaible <span style="color: #008000;">=</span> false<span style="color: #008000;">;</span>
&nbsp;
                <span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> j <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> j <span style="color: #008000;">&lt;</span> objUsersBuyersCollection.<span style="color: #0000FF;">Items</span>.<span style="color: #0000FF;">Count</span><span style="color: #008000;">;</span> j<span style="color: #008000;">++</span><span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#123;</span>
                    <span style="color: #FF0000;">int</span><span style="color: #008000;">?</span> Comparer <span style="color: #008000;">=</span> null<span style="color: #008000;">;</span>
                    <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>m_cblAllowedBuyers.<span style="color: #0000FF;">Items</span><span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">Value</span> <span style="color: #008000;">!=</span> <span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">Empty</span><span style="color: #000000;">&#41;</span>
                        Comparer <span style="color: #008000;">=</span> <span style="color: #FF0000;">int</span>.<span style="color: #0000FF;">Parse</span><span style="color: #000000;">&#40;</span>m_cblAllowedBuyers.<span style="color: #0000FF;">Items</span><span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">Value</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
                    <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>objUsersBuyersCollection<span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">BuyerId</span> <span style="color: #008000;">==</span> Comparer<span style="color: #000000;">&#41;</span>
                        IsBuyerAvalaible <span style="color: #008000;">=</span> true<span style="color: #008000;">;</span>
                    <span style="color: #0600FF;">else</span>
                        IsBuyerAvalaible <span style="color: #008000;">=</span> false<span style="color: #008000;">;</span>
                    <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>IsBuyerAvalaible<span style="color: #000000;">&#41;</span>
                        break<span style="color: #008000;">;</span>
                <span style="color: #000000;">&#125;</span>
                <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #008000;">!</span>IsBuyerAvalaible<span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#123;</span>
                    <span style="color: #FF0000;">int</span><span style="color: #008000;">?</span> Comparer <span style="color: #008000;">=</span> null<span style="color: #008000;">;</span>
                    <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>m_cblAllowedBuyers.<span style="color: #0000FF;">Items</span><span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">Value</span> <span style="color: #008000;">!=</span> <span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">Empty</span><span style="color: #000000;">&#41;</span>
                        Comparer <span style="color: #008000;">=</span> <span style="color: #FF0000;">int</span>.<span style="color: #0000FF;">Parse</span><span style="color: #000000;">&#40;</span>m_cblAllowedBuyers.<span style="color: #0000FF;">Items</span><span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">Value</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                    objUsersBuyers.<span style="color: #0000FF;">BuyerId</span> <span style="color: #008000;">=</span> Comparer<span style="color: #008000;">;</span>
                    objUsersBuyersFactory.<span style="color: #0000FF;">Insert</span><span style="color: #000000;">&#40;</span>objUsersBuyers, <span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
                <span style="color: #000000;">&#125;</span>
            <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
        <span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> j <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> j <span style="color: #008000;">&lt;</span> objUsersBuyersCollection.<span style="color: #0000FF;">Items</span>.<span style="color: #0000FF;">Count</span><span style="color: #008000;">;</span> j<span style="color: #008000;">++</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> i <span style="color: #008000;">&lt;</span> m_cblAllowedBuyers.<span style="color: #0000FF;">Items</span>.<span style="color: #0000FF;">Count</span><span style="color: #008000;">;</span> i<span style="color: #008000;">++</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #008000;">!</span>m_cblAllowedBuyers.<span style="color: #0000FF;">Items</span><span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">Selected</span><span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#123;</span>
                    <span style="color: #FF0000;">int</span><span style="color: #008000;">?</span> Comparer <span style="color: #008000;">=</span> null<span style="color: #008000;">;</span>
                    <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>m_cblAllowedBuyers.<span style="color: #0000FF;">Items</span><span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">Value</span> <span style="color: #008000;">!=</span> <span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">Empty</span><span style="color: #000000;">&#41;</span>
                        Comparer <span style="color: #008000;">=</span> <span style="color: #FF0000;">int</span>.<span style="color: #0000FF;">Parse</span><span style="color: #000000;">&#40;</span>m_cblAllowedBuyers.<span style="color: #0000FF;">Items</span><span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">Value</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                    objUsersBuyers.<span style="color: #0000FF;">BuyerId</span> <span style="color: #008000;">=</span> Comparer<span style="color: #008000;">;</span>
                    objUsersBuyers.<span style="color: #0000FF;">UsersBuyersId</span> <span style="color: #008000;">=</span> objUsersBuyersCollection<span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">UsersBuyersId</span><span style="color: #008000;">;</span>
                    objUsersBuyersFactory.<span style="color: #0000FF;">Delete</span><span style="color: #000000;">&#40;</span>objUsersBuyers, <span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                <span style="color: #000000;">&#125;</span>
&nbsp;
            <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>boolRedirect<span style="color: #000000;">&#41;</span>
            Response.<span style="color: #0000FF;">Redirect</span><span style="color: #000000;">&#40;</span>m_bctTrail.<span style="color: #0000FF;">PreviousBreadCrumb</span>.<span style="color: #0000FF;">NavigateUrl</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Ward</title>
		<link>http://encosia.com/why-do-aspnet-ajax-page-methods-have-to-be-static/#comment-50868</link>
		<dc:creator>Dave Ward</dc:creator>
		<pubDate>Fri, 02 Dec 2011 16:58:43 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=72#comment-50868</guid>
		<description>You&#039;re right about that. I&#039;m not sure what I was thinking when I wrote that comment.</description>
		<content:encoded><![CDATA[<p>You&#8217;re right about that. I&#8217;m not sure what I was thinking when I wrote that comment.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thaabiet</title>
		<link>http://encosia.com/why-do-aspnet-ajax-page-methods-have-to-be-static/#comment-50788</link>
		<dc:creator>Thaabiet</dc:creator>
		<pubDate>Fri, 02 Dec 2011 09:02:35 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=72#comment-50788</guid>
		<description>By the way, thank you for all your excellent posts!</description>
		<content:encoded><![CDATA[<p>By the way, thank you for all your excellent posts!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thaabiet</title>
		<link>http://encosia.com/why-do-aspnet-ajax-page-methods-have-to-be-static/#comment-50785</link>
		<dc:creator>Thaabiet</dc:creator>
		<pubDate>Fri, 02 Dec 2011 09:00:49 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=72#comment-50785</guid>
		<description>Hi. Actually, I&#039;m sure it&#039;s the other way round, i.e. enabled by default in page methods, but needs to be set ASMX methods.</description>
		<content:encoded><![CDATA[<p>Hi. Actually, I&#8217;m sure it&#8217;s the other way round, i.e. enabled by default in page methods, but needs to be set ASMX methods.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BrunoF</title>
		<link>http://encosia.com/why-do-aspnet-ajax-page-methods-have-to-be-static/#comment-48176</link>
		<dc:creator>BrunoF</dc:creator>
		<pubDate>Mon, 21 Nov 2011 23:18:55 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=72#comment-48176</guid>
		<description>You&#039;re a master!

Thank u so much!!!!</description>
		<content:encoded><![CDATA[<p>You&#8217;re a master!</p>
<p>Thank u so much!!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Ward</title>
		<link>http://encosia.com/why-do-aspnet-ajax-page-methods-have-to-be-static/#comment-48167</link>
		<dc:creator>Dave Ward</dc:creator>
		<pubDate>Mon, 21 Nov 2011 22:26:55 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=72#comment-48167</guid>
		<description>You can use &lt;code&gt;HttpContext.Current.Application&lt;/code&gt; to access that object from within a static/shared method.</description>
		<content:encoded><![CDATA[<p>You can use <code>HttpContext.Current.Application</code> to access that object from within a static/shared method.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

