<?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>Wed, 16 May 2012 23:02:53 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: Dave Ward</title>
		<link>http://encosia.com/why-do-aspnet-ajax-page-methods-have-to-be-static/#comment-69705</link>
		<dc:creator>Dave Ward</dc:creator>
		<pubDate>Tue, 15 May 2012 19:11:03 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=72#comment-69705</guid>
		<description>You can&#039;t. That&#039;s basically the point of this post. The advantage of page methods is that they can be fast and light weight since they&#039;re not encumbered by ViewState and the page life cycle. But, that also means an instance of the Page and its child controls never exists during the page method&#039;s execution.

If you absolutely must have access to a WebControl during the AJAX request, you&#039;ll need to use something like an UpdatePanel instead. Just keep in mind that you&#039;ll be trading away significant performance for that convenience. If at all possible, figure out a way to work around that need by passing the dropdown&#039;s client-side value as a parameter to the page method and/or setting the dropdown&#039;s selected value on the client-side based on the result of the page method.</description>
		<content:encoded><![CDATA[<p>You can&#8217;t. That&#8217;s basically the point of this post. The advantage of page methods is that they can be fast and light weight since they&#8217;re not encumbered by ViewState and the page life cycle. But, that also means an instance of the Page and its child controls never exists during the page method&#8217;s execution.</p>
<p>If you absolutely must have access to a WebControl during the AJAX request, you&#8217;ll need to use something like an UpdatePanel instead. Just keep in mind that you&#8217;ll be trading away significant performance for that convenience. If at all possible, figure out a way to work around that need by passing the dropdown&#8217;s client-side value as a parameter to the page method and/or setting the dropdown&#8217;s selected value on the client-side based on the result of the page method.</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-68540</link>
		<dc:creator>Mark Brown</dc:creator>
		<pubDate>Thu, 10 May 2012 09:30:04 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=72#comment-68540</guid>
		<description>Hi Dave

Thanks for your reply!  

I have just quickly tried that out.  One other question, how can I reference a control on the page.  For example, a drop down list as it come up with an error as it&#039;s a static method?

Thanks

Mark</description>
		<content:encoded><![CDATA[<p>Hi Dave</p>
<p>Thanks for your reply!  </p>
<p>I have just quickly tried that out.  One other question, how can I reference a control on the page.  For example, a drop down list as it come up with an error as it&#8217;s a static method?</p>
<p>Thanks</p>
<p>Mark</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DJC</title>
		<link>http://encosia.com/why-do-aspnet-ajax-page-methods-have-to-be-static/#comment-68394</link>
		<dc:creator>DJC</dc:creator>
		<pubDate>Wed, 09 May 2012 17:55:29 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=72#comment-68394</guid>
		<description>Thanks Dave... Great article by the way... I&#039;m finding myself landing at encosia.com for answers more and more lately</description>
		<content:encoded><![CDATA[<p>Thanks Dave&#8230; Great article by the way&#8230; I&#8217;m finding myself landing at encosia.com for answers more and more lately</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-68223</link>
		<dc:creator>Dave Ward</dc:creator>
		<pubDate>Wed, 09 May 2012 01:00:17 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=72#comment-68223</guid>
		<description>HttpContext.Current.Handler doesn&#039;t contain anything useful inside a page method (or ever, really). HttpContext.Current is generally pretty handy in page methods, since it gives you access to the Application, Session, Cache, and other objects that you&#039;re used to using from regular WebForms code, but there&#039;s no Page instance there during a page method&#039;s execution.</description>
		<content:encoded><![CDATA[<p>HttpContext.Current.Handler doesn&#8217;t contain anything useful inside a page method (or ever, really). HttpContext.Current is generally pretty handy in page methods, since it gives you access to the Application, Session, Cache, and other objects that you&#8217;re used to using from regular WebForms code, but there&#8217;s no Page instance there during a page method&#8217;s execution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DJC</title>
		<link>http://encosia.com/why-do-aspnet-ajax-page-methods-have-to-be-static/#comment-68201</link>
		<dc:creator>DJC</dc:creator>
		<pubDate>Tue, 08 May 2012 22:25:29 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=72#comment-68201</guid>
		<description>Just when I was coming to terms with *not* being able to access controls on the page from within static page methods:

From Ashraf Sabry:
&quot;If you look at HttpContext.Current.Handler during a web method call, you’ll find it an instance of your page&quot;

does that not mean that you could access the page&#039;s controls then? I assume you cannot, but that fact makes me wonder again?</description>
		<content:encoded><![CDATA[<p>Just when I was coming to terms with *not* being able to access controls on the page from within static page methods:</p>
<p>From Ashraf Sabry:<br />
&#8220;If you look at HttpContext.Current.Handler during a web method call, you’ll find it an instance of your page&#8221;</p>
<p>does that not mean that you could access the page&#8217;s controls then? I assume you cannot, but that fact makes me wonder again?</p>
]]></content:encoded>
	</item>
	<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>
</channel>
</rss>

