<?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"
	>

<channel>
	<title>Hassan Zaheer</title>
	<atom:link href="http://www.hassanzaheer.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hassanzaheer.com</link>
	<description>The Initiator</description>
	<pubDate>Sun, 22 Nov 2009 00:06:17 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
	<language>en</language>
			<item>
		<title>AJAX using JQuery and ASP.net</title>
		<link>http://www.hassanzaheer.com/ajax-using-jquery-and-aspnet/</link>
		<comments>http://www.hassanzaheer.com/ajax-using-jquery-and-aspnet/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 00:06:17 +0000</pubDate>
		<dc:creator>hzaheer</dc:creator>
		
		<category><![CDATA[AJAX]]></category>

		<category><![CDATA[ASP.net]]></category>

		<category><![CDATA[JQuery]]></category>

		<category><![CDATA[asp.net ajax]]></category>

		<category><![CDATA[asp.net Jquery]]></category>

		<guid isPermaLink="false">http://www.hassanzaheer.com/?p=129</guid>
		<description><![CDATA[This is my first article on JQuery. Although I am using JQuery for more than two years I was unable to write any article on that due to lack of time. In the following simple example I will try to explain how you can send AJAX request from you asp.net application using JQuery and web [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="font-family: Calibri; font-size: small;">This is my first article on JQuery. Although I am using JQuery for more than two years I was unable to write any article on that due to lack of time. In the following simple example I will try to explain how you can send AJAX request from you asp.net application using JQuery and web services. So let’s start our journey.</span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="font-family: Calibri; font-size: small;">For this example I have used the Customers table from Northwind database.</span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="font-family: Calibri; font-size: small;">Create a default.aspx page and add the following code in the body portion of the aspx page</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes;">&lt;</span><span style="font-family: &quot;Courier New&quot;; color: #a31515; font-size: 10pt; mso-no-proof: yes;">form</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"> <span style="color: red;">id</span><span style="color: blue;">=&#8221;form1&#8243;</span> <span style="color: red;">runat</span><span style="color: blue;">=&#8221;server&#8221;&gt;</span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">    </span>// asp.net dropdown list</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">    </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">asp</span><span style="color: blue;">:</span><span style="color: #a31515;">DropDownList</span> <span style="color: red;">ID</span><span style="color: blue;">=&#8221;Customers&#8221;</span> <span style="color: red;">runat</span><span style="color: blue;">=&#8221;server&#8221;</span> <span style="color: red;">AutoPostBack</span><span style="color: blue;">=&#8221;false&#8221;&gt;</span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">    </span><span style="color: blue;">&lt;/</span><span style="color: #a31515;">asp</span><span style="color: blue;">:</span><span style="color: #a31515;">DropDownList</span><span style="color: blue;">&gt;</span> </span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">    </span>// div to hold the details regarding customers</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">    </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">div</span> <span style="color: red;">id</span><span style="color: blue;">=&#8221;CustomerDetails&#8221;</span> <span style="color: blue;">&gt;</span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">    </span><span style="color: blue;">&lt;/</span><span style="color: #a31515;">div</span><span style="color: blue;">&gt;</span><span style="mso-spacerun: yes;">        </span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes;">&lt;/</span><span style="font-family: &quot;Courier New&quot;; color: #a31515; font-size: 10pt; mso-no-proof: yes;">form</span><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes;">&gt;</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes;"> </span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;">Just make sure that the AutoPostBack property of your DropdownList is set to false<span style="color: blue;"> </span><span style="color: red;">AutoPostBack</span><span style="color: blue;">=&#8221;false&#8221;.</span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes;"> </span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes;"> </span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;">Then go to the cs page i.e. defaul.aspx.cs and add the following code in the page Load method.</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes;"> </span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes;">if</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;">(!IsPostBack)</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;">{</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">   </span><span style="color: green;">// usually we define the connection string in web.config but for making it simple defined here</span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;">  </span><span style="color: blue;">string</span> connect = <span style="color: #a31515;">@&#8221;Data Source=.\SQLEXPRESS;Initial Catalog=NorthWind;User ID=sa;Password=password&#8221;</span>;</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">   </span><span style="color: green;">//query to select customer data </span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">   </span><span style="color: blue;">string</span> query = <span style="color: #a31515;">&#8220;SELECT CustomerID, CompanyName FROM Customers&#8221;</span>;</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">   </span><span style="color: blue;">using</span> (<span style="color: #2b91af;">SqlConnection</span> conn = <span style="color: blue;">new</span> <span style="color: #2b91af;">SqlConnection</span>(connect))</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">   </span>{</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">   </span><span style="mso-tab-count: 1;">   </span><span style="color: blue;">using</span> (<span style="color: #2b91af;">SqlCommand</span> cmd = <span style="color: blue;">new</span> <span style="color: #2b91af;">SqlCommand</span>(query, conn))</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">      </span>{</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">      </span><span style="mso-tab-count: 1;">      </span>conn.Open();</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">            </span>Customers.DataSource = cmd.ExecuteReader();</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">            </span>Customers.DataValueField = <span style="color: #a31515;">&#8220;CustomerID&#8221;</span>;</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">            </span>Customers.DataTextField = <span style="color: #a31515;">&#8220;CompanyName&#8221;</span>;</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">            </span>Customers.DataBind();</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">   </span><span style="mso-spacerun: yes;">   </span>}</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">   </span>}<span style="mso-spacerun: yes;">  </span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">  </span>}</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"> </span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;">Now add an entity class customer.cs and add the following code in it.</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"> </span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes;">public</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"> <span style="color: blue;">string</span> CustomerID { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes;">public</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"> <span style="color: blue;">string</span> CompanyName { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes;">public</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"> <span style="color: blue;">string</span> Address { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes;">public</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"> <span style="color: blue;">string</span> City { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes;">public</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"> <span style="color: blue;">string</span> Region { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes;">public</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"> <span style="color: blue;">string</span> PostalCode { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes;">public</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"> <span style="color: blue;">string</span> Country { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes;">public</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"> <span style="color: blue;">string</span> Phone { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes;">public</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"> <span style="color: blue;">string</span> Fax { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"> </span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;">Now a webservice WebService.asmx in the project and add the following method in it.</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"> </span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;">[<span style="color: #2b91af;">WebMethod</span>]</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes;">public</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"> <span style="color: #2b91af;">ClsCustomer</span> GetCustomerDetailByID(<span style="color: blue;">string</span> CustomerID)</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;">{</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">   </span><span style="color: blue;">try</span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">   </span>{<span style="mso-spacerun: yes;">       </span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">   </span><span style="mso-tab-count: 1;">   </span><span style="color: #2b91af;">Customer</span> c = <span style="color: blue;">new</span> <span style="color: #2b91af;">Customer</span>();</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">       </span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">      </span><span style="color: blue;">string</span> connect = <span style="color: #a31515;">@&#8221;Data Source=.\SQLEXPRESS;Initial Catalog=NorthWind;User ID=sa;Password=password&#8221;</span>;</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">      </span><span style="color: blue;">string</span> query = <span style="color: #a31515;">&#8220;SELECT CustomerID,CompanyName, Address, City, Region, PostalCode,&#8221;</span> +</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">    </span><span style="mso-spacerun: yes;"> </span><span style="color: #a31515;">&#8220;Country, Phone, Fax FROM Customers WHERE CustomerID = @CustomerID&#8221;</span>;</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"> </span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">        </span><span style="color: blue;">if</span> (CustomerID != <span style="color: blue;">null</span> )</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">        </span>{</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">            </span><span style="color: blue;">using</span> (<span style="color: #2b91af;">SqlConnection</span> conn = <span style="color: blue;">new</span> <span style="color: #2b91af;">SqlConnection</span>(connect))</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">            </span>{</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">                </span><span style="color: blue;">using</span> (<span style="color: #2b91af;">SqlCommand</span> cmd = <span style="color: blue;">new</span> <span style="color: #2b91af;">SqlCommand</span>(query, conn))</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">                </span>{</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">                    </span>cmd.Parameters.AddWithValue(<span style="color: #a31515;">&#8220;CustomerID&#8221;</span>, CustomerID);</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">                    </span>conn.Open();</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">                   </span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">                    </span><span style="color: #2b91af;">SqlDataReader</span> rdr = cmd.ExecuteReader();</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">                    </span><span style="color: blue;">if</span> (rdr.HasRows)</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">                    </span>{</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">                        </span><span style="color: blue;">while</span> (rdr.Read())</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">                   </span><span style="mso-spacerun: yes;">     </span>{</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-tab-count: 3;">                  </span><span style="mso-tab-count: 1;">      </span><span style="mso-spacerun: yes;">    </span><span style="color: green;">// Load the data in the customer object</span><span style="mso-tab-count: 1;">     </span><span style="mso-tab-count: 1;">      </span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">                            </span>c.CustomerID = rdr[<span style="color: #a31515;">"CustomerID"</span>].ToString();</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">                            </span>c.CompanyName = rdr[<span style="color: #a31515;">"CompanyName"</span>].ToString();</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">                            </span>c.Address = rdr[<span style="color: #a31515;">"Address"</span>].ToString();</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">                            </span>c.City = rdr[<span style="color: #a31515;">"City"</span>].ToString();</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">                            </span>c.Region = rdr[<span style="color: #a31515;">"Region"</span>].ToString();</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">                            </span>c.PostalCode = rdr[<span style="color: #a31515;">"PostalCode"</span>].ToString();</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">                            </span>c.Country = rdr[<span style="color: #a31515;">"Country"</span>].ToString();</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">                            </span>c.Phone = rdr[<span style="color: #a31515;">"Phone"</span>].ToString();</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">                            </span>c.Fax = rdr[<span style="color: #a31515;">"Fax"</span>].ToString();</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">                        </span>}</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">                    </span>}</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">                </span>}</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">            </span>}</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">        </span>}</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-tab-count: 1;">      </span><span style="mso-spacerun: yes;">  </span><span style="color: green;">// return customer object</span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">        </span><span style="color: blue;">return</span> c;</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">        </span>}</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">      </span><span style="mso-spacerun: yes;">  </span><span style="color: blue;">catch</span> (System.<span style="color: #2b91af;">Exception</span> ex)</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">        </span>{</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">            </span><span style="color: blue;">return</span> <span style="color: blue;">null</span>;</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">        </span>}</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">    </span>}</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"> </span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;">Now again go back to the default.aspx page and prepare AJAX request using jquery. First include the jQuery library in the head section of the default.aspx page. (you can easily download the jquery file from internet)</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"> </span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes;">&lt;</span><span style="font-family: &quot;Courier New&quot;; color: #a31515; font-size: 10pt; mso-no-proof: yes;">script</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"> <span style="color: red;">type</span><span style="color: blue;">=&#8221;text/javascript&#8221;</span> <span style="color: red;">src</span><span style="color: blue;">=&#8221;Script/jquery-1.3.2.min.js&#8221;&gt;&lt;/</span><span style="color: #a31515;">script</span><span style="color: blue;">&gt;</span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes;"> </span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;">Now add the following javascript code</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes;"> </span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes;">&lt;</span><span style="font-family: &quot;Courier New&quot;; color: #a31515; font-size: 10pt; mso-no-proof: yes;">script</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"> <span style="color: red;">type</span><span style="color: blue;">=&#8221;text/javascript&#8221;&gt;</span> </span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">    </span><span style="color: green;">// this method will be called when the page is loaded in the browser</span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">     </span>$(document).ready(<span style="color: blue;">function</span>() </span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">     </span>{</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">        </span><span style="color: green;">//attach change event on asp dropdown list with id Customers. </span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">        </span>$(<span style="color: #a31515;">&#8216;#Customers&#8217;</span>).change(<span style="color: blue;">function</span>() {</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">        </span><span style="color: green;">// send ajax request.</span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">        </span>$.ajax({</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">        </span>type: <span style="color: #a31515;">&#8220;POST&#8221;</span>,</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">        </span>contentType: <span style="color: #a31515;">&#8220;application/json; charset=utf-8&#8243;</span>,</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">        </span><span style="color: green;">//pass parameter with the ajax request </span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">        </span>data: <span style="color: #a31515;">&#8220;{ CustomerID: &#8216;&#8221;</span> + $(<span style="color: #a31515;">&#8216;#Customers&#8217;</span>).val() + <span style="color: #a31515;">&#8220;&#8216;}&#8221;</span>,</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">        </span><span style="color: green;">//calling webservice</span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">        </span>url: <span style="color: #a31515;">&#8220;FatchCustomers.asmx/GetCustomerDetailByID&#8221;</span>,</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">        </span><span style="color: green;">//return type will be JSON</span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">        </span>dataType: <span style="color: #a31515;">&#8220;json&#8221;</span>,</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">        </span><span style="color: green;">//on success call this method.</span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">        </span>success: BuildTable,</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">        </span>error:TransacionFailed</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">       </span>});</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">    </span>});</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">  </span>});</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"> </span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">   </span><span style="color: blue;">function</span> TransacionFailed() {</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">   </span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">          </span>$(<span style="color: #a31515;">&#8216;#CustomerDetails&#8217;</span>).empty();</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">          </span>$(<span style="color: #a31515;">&#8216;#CustomerDetails&#8217;</span>).append </span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">            </span>(result.status + <span style="color: #a31515;">&#8216; &#8216;</span> + result.statusText);</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">            </span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">   </span>}</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes;">function</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"> BuildTable(msg) {</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">      </span><span style="color: blue;">var</span> table = <span style="color: #a31515;">&#8216;&lt;table cellpadding=&#8221;5px&#8221; cellspacing=&#8221;5px&#8221; border=&#8221;1px&#8221;&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Customer Id&lt;/th&gt;<span style="mso-spacerun: yes;">  </span>&lt;th&gt;Customer Name&lt;/th&gt; &lt;th&gt;Address&lt;/th&gt;&lt;th&gt;City&lt;/th&gt; &lt;th&gt;Region&lt;/th&gt;&lt;th&gt;PostalCode&lt;/th&gt;&lt;th&gt;Country&lt;/th&gt;&lt;th&gt;Phone&lt;/th&gt;&lt;th&gt;Fax&lt;/th&gt;&lt;/thead&gt;&lt;tbody&gt;&#8217;</span>;</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">      </span><span style="color: green;">//brows the returned JSON DATA</span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">      </span><span style="color: blue;">for</span> (<span style="color: blue;">var</span> cd <span style="color: blue;">in</span> msg) {</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">          </span><span style="color: blue;">var</span> row = <span style="color: #a31515;">&#8216;&lt;tr&gt;&#8217;</span>;</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">          </span>row += <span style="color: #a31515;">&#8216;&lt;td&gt;&#8217;</span> + msg[cd].CustomerID + <span style="color: #a31515;">&#8216;&lt;/td&gt;&#8217;</span>;</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">          </span>row += <span style="color: #a31515;">&#8216;&lt;td&gt;&#8217;</span> + msg[cd].CompanyName + <span style="color: #a31515;">&#8216;&lt;/td&gt;&#8217;</span>;</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">          </span>row += <span style="color: #a31515;">&#8216;&lt;td&gt;&#8217;</span> + msg[cd].Address + <span style="color: #a31515;">&#8216;&lt;/td&gt;&#8217;</span>;</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">          </span>row += <span style="color: #a31515;">&#8216;&lt;td&gt;&#8217;</span> + msg[cd].City + <span style="color: #a31515;">&#8216;&lt;/td&gt;&#8217;</span>;</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">          </span>row += <span style="color: #a31515;">&#8216;&lt;td&gt;&#8217;</span> + msg[cd].Region + <span style="color: #a31515;">&#8216;&lt;/td&gt;&#8217;</span>;</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">          </span>row += <span style="color: #a31515;">&#8216;&lt;td&gt;&#8217;</span> + msg[cd].PostalCode + <span style="color: #a31515;">&#8216;&lt;/td&gt;&#8217;</span>;</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">          </span>row += <span style="color: #a31515;">&#8216;&lt;td&gt;&#8217;</span> + msg[cd].Country + <span style="color: #a31515;">&#8216;&lt;/td&gt;&#8217;</span>;</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">          </span>row += <span style="color: #a31515;">&#8216;&lt;td&gt;&#8217;</span> + msg[cd].Phone + <span style="color: #a31515;">&#8216;&lt;/td&gt;&#8217;</span>;</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">          </span>row += <span style="color: #a31515;">&#8216;&lt;td&gt;&#8217;</span> + msg[cd].Fax + <span style="color: #a31515;">&#8216;&lt;/td&gt;&#8217;</span>;</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">          </span>row += <span style="color: #a31515;">&#8216;&lt;/tr&gt;&#8217;</span>;</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">          </span>table += row;</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">      </span>}</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">      </span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">      </span>table += <span style="color: #a31515;">&#8216;&lt;/tbody&gt;&lt;/table&gt;&#8217;</span>;</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">      </span>$(<span style="color: #a31515;">&#8216;#CustomerDetails&#8217;</span>).html(table);</span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">      </span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">      </span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">  </span>}<span style="mso-spacerun: yes;">    </span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">    </span><span style="color: blue;">&lt;/</span><span style="color: #a31515;">script</span><span style="color: blue;">&gt;</span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;"> </span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes;">We are done. I always prefer jquery over asp.net ajax as it is far more easier and lite weight.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hassanzaheer.com/ajax-using-jquery-and-aspnet/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Get the day from date value in SQL Server</title>
		<link>http://www.hassanzaheer.com/day-from-dated-in-sqlserver/</link>
		<comments>http://www.hassanzaheer.com/day-from-dated-in-sqlserver/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 05:49:06 +0000</pubDate>
		<dc:creator>hzaheer</dc:creator>
		
		<category><![CDATA[SQL SERVER]]></category>

		<category><![CDATA[day for date]]></category>

		<category><![CDATA[find day in sql server]]></category>

		<guid isPermaLink="false">http://www.hassanzaheer.com/?p=126</guid>
		<description><![CDATA[There is a nice function available in SQL server to find out the day name for any given date you can use it in your query.
select datename (dw, &#8216;10/10/2009&#8242;) as [day]
]]></description>
			<content:encoded><![CDATA[<p>There is a nice function available in SQL server to find out the day name for any given date you can use it in your query.</p>
<p><span style="font-size: x-small;"><strong>select </strong><em><strong>datename</strong> </em>(dw, &#8216;10/10/2009&#8242;) as [day]</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hassanzaheer.com/day-from-dated-in-sqlserver/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Installing Cache on Red Hat Linux</title>
		<link>http://www.hassanzaheer.com/installing-cache-on-red-hat-linux/</link>
		<comments>http://www.hassanzaheer.com/installing-cache-on-red-hat-linux/#comments</comments>
		<pubDate>Fri, 15 May 2009 12:28:59 +0000</pubDate>
		<dc:creator>hzaheer</dc:creator>
		
		<category><![CDATA[Cache]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Cache on Linux]]></category>

		<category><![CDATA[installating Cache on Linux]]></category>

		<category><![CDATA[Installing Cache on Linux]]></category>

		<guid isPermaLink="false">http://www.hassanzaheer.com/?p=118</guid>
		<description><![CDATA[Cache installation steps on Red Hat Linux
 
Download the cache setup files for your Linux version. and then Uzip the files.
Start the Terminal window in Linux.
Go to the cache setup foldcer. eg. cd  /root/cache-2007/
Run  ./cinstall  command
The cache installation script will be start and ask you some question regarding installation .
 


1 )      It will display the Linux [...]]]></description>
			<content:encoded><![CDATA[<h1 style="margin: 12pt 0in 3pt;"><span style="font-family: Cambria; font-size: large;">Cache installation steps on Red Hat Linux</span></h1>
<p style="margin: 12pt 0in 3pt;"> </p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-family: Times New Roman; font-size: small;">Download the cache setup files for your Linux version. and then Uzip the files.<br />
Start the Terminal window in Linux.<br />
Go to the cache setup foldcer. eg. cd<span style="mso-spacerun: yes;">  </span>/root/cache-2007/<br />
Run<span style="mso-spacerun: yes;">  </span>./cinstall<span style="mso-spacerun: yes;">  </span>command<br />
The cache installation script will be start and ask you some question regarding installation .</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"> </p>
<div></div>
<p><span style="font-family: Times New Roman; font-size: small;"></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; tab-stops: list .5in;"><span style="mso-list: Ignore;">1 )<span style="font-family: &quot;Times New Roman&quot;;">      </span></span>It will display the Linux version which is supported with this version of cache and ask you to choose by asking<span style="mso-spacerun: yes;">  </span>“Is this the correct type of your system”. Select accordingly.</p>
<p class="MsoNormal" style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; tab-stops: list .5in;"><span style="mso-list: Ignore;">2 )<span style="font-family: &quot;Times New Roman&quot;;">      </span></span>Next it will ask “Enter instance name”. Type the name of the instance for example cache07.</p>
<p class="MsoNormal" style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; tab-stops: list .5in;"><span style="mso-list: Ignore;">3 )<span style="font-family: &quot;Times New Roman&quot;;">      </span></span>Then it will ask “Enter directory name for this installation ”. Type the path for your installation e.g /xyz/abc/.</p>
<p class="MsoNormal" style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; tab-stops: list .5in;"><span style="mso-list: Ignore;">4 )<span style="font-family: &quot;Times New Roman&quot;;">      </span></span>If the directory you provide does not exist<span style="mso-spacerun: yes;">  </span>it will ask “Do you want to create it”. Type Yes.</p>
<p class="MsoNormal" style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; tab-stops: list .5in;"><span style="mso-list: Ignore;">5 )<span style="font-family: &quot;Times New Roman&quot;;">      </span></span>Next it will ask u about the setup type “Standard or Custom”. Type 1 for standard.</p>
<p class="MsoNormal" style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; tab-stops: list .5in;"><span style="mso-list: Ignore;">6 )<span style="font-family: &quot;Times New Roman&quot;;">      </span></span>Next it will ask u about Unicode support. Reply accordingly.</p>
<p class="MsoNormal" style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; tab-stops: list .5in;"><span style="mso-list: Ignore;">7 )<span style="font-family: &quot;Times New Roman&quot;;">      </span></span>Then it will ask u about Security Settings. Select accordingly.</p>
<p class="MsoNormal" style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; tab-stops: list .5in;"><span style="mso-list: Ignore;">8 )<span style="font-family: &quot;Times New Roman&quot;;">      </span></span>Then it will ask u about the Group which is allowed to start and stop the cache instance.</p>
<p class="MsoNormal" style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; tab-stops: list .5in;"><span style="mso-list: Ignore;">9 )<span style="font-family: &quot;Times New Roman&quot;;">      </span></span>Then it will ask u about licence key. “Are u want to enter the licence Key”. Type yes if you want to provide a licence key.</p>
<p class="MsoNormal" style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; tab-stops: list .5in;"><span style="mso-list: Ignore;">10)<span style="font-family: &quot;Times New Roman&quot;;">  </span></span>It will then show u the provide option as installation summary and will ask u to proced. Type yes … and the installation will start.</p>
<p class="MsoNormal" style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; tab-stops: list .5in;"><span style="mso-list: Ignore;">11)<span style="font-family: &quot;Times New Roman&quot;;">  </span></span>After the installation if every thing goes fine it will show u the URL of System Management Portal.</p>
<p class="MsoNormal" style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; tab-stops: list .5in;"><span style="mso-list: Ignore;">12)<span style="font-family: &quot;Times New Roman&quot;;">  </span></span>Done</p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"> </p>
<p> </p>
<p> </p>
<p></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hassanzaheer.com/installing-cache-on-red-hat-linux/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Restore Cache Backup From Cache Terminal</title>
		<link>http://www.hassanzaheer.com/cache-from-terminal/</link>
		<comments>http://www.hassanzaheer.com/cache-from-terminal/#comments</comments>
		<pubDate>Fri, 15 May 2009 11:41:54 +0000</pubDate>
		<dc:creator>hzaheer</dc:creator>
		
		<category><![CDATA[Cache]]></category>

		<category><![CDATA[cache backup restore]]></category>

		<category><![CDATA[cache linux]]></category>

		<category><![CDATA[cache linux backup]]></category>

		<category><![CDATA[cache linux restore]]></category>

		<category><![CDATA[cache restore]]></category>

		<guid isPermaLink="false">http://www.hassanzaheer.com/?p=111</guid>
		<description><![CDATA[It is quite easy to restore the cache classes backup using cache studio but some times we have a scenario where we have to restore the cache classes backup from the cache terminal. Usually we need this in Linux. We can achive this goal by using a simple command.
$system.OBJ.Load(&#8221;path to the xml File&#8221;,&#8221;ck&#8221;) 
Just start cache terminal [...]]]></description>
			<content:encoded><![CDATA[<p>It is quite easy to restore the cache classes backup using cache studio but some times we have a scenario where we have to restore the cache classes backup from the cache terminal. Usually we need this in Linux. We can achive this goal by using a simple command.</p>
<p>$system.OBJ.Load(&#8221;path to the xml File&#8221;,&#8221;ck&#8221;) </p>
<p>Just start cache terminal go to the specific namespace by typeing</p>
<p><strong>zn &#8220;Namespace Name&#8221;</strong></p>
<p>and then run the command </p>
<p><strong>w $system.OBJ.Load(&#8221;path to the xml File&#8221;,&#8221;ck&#8221;) </strong></p>
<p>and the xml file will be restored in the current namespace.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hassanzaheer.com/cache-from-terminal/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Calling WSDL WebService From PHP.</title>
		<link>http://www.hassanzaheer.com/calling-wsdl-webservice-from-php/</link>
		<comments>http://www.hassanzaheer.com/calling-wsdl-webservice-from-php/#comments</comments>
		<pubDate>Fri, 15 May 2009 08:20:43 +0000</pubDate>
		<dc:creator>hzaheer</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[calling webservice from PHP]]></category>

		<category><![CDATA[PHP &amp; webservice]]></category>

		<category><![CDATA[PHP web service]]></category>

		<guid isPermaLink="false">http://www.hassanzaheer.com/?p=107</guid>
		<description><![CDATA[Web service is a way of comunication over the internet. It is  Language independent. We can call Web service from PHP by using Curl Library. For that we have to enable the Php_curl library from the php.ini file.
&#60;?php
             // URL of the Web Service
              $url=&#8221;http://localhost/Test/Service1.asmx/Test?name=&#8221;.$_POST["fcurrency"];
             // initiate the Curl library.
              $ch = curl_init();     
             // initiate the Curl library.
             // [...]]]></description>
			<content:encoded><![CDATA[<p>Web service is a way of comunication over the internet. It is  Language independent. We can call Web service from PHP by using Curl Library. For that we have to enable the Php_curl library from the php.ini file.</p>
<p>&lt;?php</p>
<p>             // URL of the Web Service<br />
              $url=&#8221;<a href="http://192.168.0.25/SetupFedEx/Service1.asmx/Test?name=&quot;.$_POST[&quot;fcurrency">http://localhost/Test/Service1.asmx/Test?name=&#8221;.$_POST["fcurrency</a>"];<br />
             // initiate the Curl library.<br />
              $ch = curl_init();     <br />
             // initiate the Curl library.<br />
             // for reference see:- (<a href="http://www.php.net/curl_setopt">http://www.php.net/curl_setopt</a>)<br />
              curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);<br />
              curl_setopt($ch, CURLOPT_URL, $url);<br />
              // get the Response from the WebService<br />
              //for reference see:- (<a href="http://www.php.net/curl_exec">http://www.php.net/curl_exec</a>)<br />
              $x=curl_exec($ch);</p>
<p>?&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hassanzaheer.com/calling-wsdl-webservice-from-php/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Calling Cache Store Procedure through SQL</title>
		<link>http://www.hassanzaheer.com/calling-cache-store-procedure-in-sql/</link>
		<comments>http://www.hassanzaheer.com/calling-cache-store-procedure-in-sql/#comments</comments>
		<pubDate>Fri, 15 May 2009 07:57:24 +0000</pubDate>
		<dc:creator>hzaheer</dc:creator>
		
		<category><![CDATA[Cache]]></category>

		<category><![CDATA[cache sp]]></category>

		<category><![CDATA[cache store procedure]]></category>

		<category><![CDATA[calling store procedures in cache]]></category>

		<category><![CDATA[SP in cache]]></category>

		<category><![CDATA[sql proc in cache]]></category>

		<guid isPermaLink="false">http://www.hassanzaheer.com/?p=99</guid>
		<description><![CDATA[We can call a cache SP from SQL in the following way.
Define SP in Cache:-
Class User.test Extends %Persistent
{ 
   ClassMethod t1(p as %String) As %String [ SqlProc ]
  {
     s ^Asad($H)=p
     q 1
  }
}
Query to Call this SP:-
select Test_t1(&#8217;Test1&#8242;) from SQLUser.Test

Example to calling SP if the class is in package:-

Class TestPkg.test Extends %Persistent
{

ClassMethod t1(p As %String) As [...]]]></description>
			<content:encoded><![CDATA[<p style="line-height: 14.25pt;"><span style="font-family: &quot;Lucida Sans Unicode&quot;,&quot;sans-serif&quot;; color: black; font-size: 10pt;">We can call a cache SP from SQL in the following way.</span></p>
<p style="line-height: 14.25pt;"><strong style="mso-bidi-font-weight: normal;"><span style="font-family: &quot;Lucida Sans Unicode&quot;,&quot;sans-serif&quot;; color: black; font-size: 10pt;">Define SP in Cache:-</span></strong></p>
<div style="line-height: 14.25pt;"><span style="font-family: &quot;Lucida Sans Unicode&quot;,&quot;sans-serif&quot;; color: black; font-size: 10pt;"><span style="font-family: &quot;Lucida Sans Unicode&quot;,&quot;sans-serif&quot;; color: black; font-size: 10pt;">Class User.test Extends %Persistent<br />
{</span></span> <br />
   <span style="font-family: &quot;Lucida Sans Unicode&quot;,&quot;sans-serif&quot;; color: black; font-size: 10pt;">ClassMethod t1(p as %String) As %String [ SqlProc ]<br />
  {<br />
 <span style="mso-spacerun: yes;">    </span>s ^Asad($H)=p<br />
<span style="mso-spacerun: yes;">    </span> q 1<br />
  }<br />
</span><span style="font-family: &quot;Lucida Sans Unicode&quot;,&quot;sans-serif&quot;; color: black; font-size: 10pt;">}</span></div>
<p style="line-height: 14.25pt;"><strong style="mso-bidi-font-weight: normal;"><span style="font-family: &quot;Lucida Sans Unicode&quot;,&quot;sans-serif&quot;; color: black; font-size: 10pt;">Query to Call this SP:-<br />
</span></strong><span style="font-family: &quot;Lucida Sans Unicode&quot;,&quot;sans-serif&quot;; color: black; font-size: 10pt;">select Test_t1(&#8217;Test1&#8242;) from SQLUser.Test<br />
</span><span style="font-family: &quot;Lucida Sans Unicode&quot;,&quot;sans-serif&quot;; color: black; font-size: 10pt;"><br />
<strong style="mso-bidi-font-weight: normal;">Example to calling SP if the class is in package:-<br />
</strong><br />
Class TestPkg.test Extends %Persistent<br />
{</span></p>
<p style="line-height: 14.25pt;">
<div><span style="font-family: &quot;Lucida Sans Unicode&quot;,&quot;sans-serif&quot;; color: black; font-size: 10pt;"><span style="font-family: &quot;Lucida Sans Unicode&quot;,&quot;sans-serif&quot;; color: black; font-size: 10pt;">ClassMethod t1(p As %String) As %String [ SqlProc ]<br />
{<br />
 <span style="mso-spacerun: yes;">     </span>s ^Asad($zdt($H))=p<br />
 <span style="mso-spacerun: yes;">     </span>q 1<br />
}<br />
</span></span><span style="font-family: &quot;Lucida Sans Unicode&quot;,&quot;sans-serif&quot;; color: black; font-size: 10pt;">}</span></div>
<p style="line-height: 14.25pt;"><strong style="mso-bidi-font-weight: normal;">SQL Query :-</strong></p>
<p> </p>
<div><span style="font-family: &quot;Lucida Sans Unicode&quot;,&quot;sans-serif&quot;; color: black; font-size: 10pt;"><span style="font-family: &quot;Lucida Sans Unicode&quot;,&quot;sans-serif&quot;; color: black; font-size: 10pt;"><span style="font-family: &quot;Lucida Sans Unicode&quot;,&quot;sans-serif&quot;; color: black; font-size: 10pt;">select TestPkg.Test_t1(&#8217;Test1&#8242;) from TestPkg.Test</span> </span></span></div>
<p><span style="font-family: &quot;Lucida Sans Unicode&quot;,&quot;sans-serif&quot;; color: black; font-size: 10pt;"><span style="font-family: &quot;Lucida Sans Unicode&quot;,&quot;sans-serif&quot;; color: black; font-size: 10pt;"> </p>
<p></span></span></p>
<p style="line-height: 14.25pt;"><span style="font-family: &quot;Lucida Sans Unicode&quot;,&quot;sans-serif&quot;; color: black; font-size: 10pt;">This is the way how you can call cache store procedures from SQL. This is very helpful in the scenarios when using cache with other languages like java or .net.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hassanzaheer.com/calling-cache-store-procedure-in-sql/feed/</wfw:commentRss>
		</item>
		<item>
		<title>REACT^STU1 routine ALternative</title>
		<link>http://www.hassanzaheer.com/reactstu1-routine-alternative/</link>
		<comments>http://www.hassanzaheer.com/reactstu1-routine-alternative/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 13:25:42 +0000</pubDate>
		<dc:creator>hzaheer</dc:creator>
		
		<category><![CDATA[Cache]]></category>

		<category><![CDATA[cache Linux REACT]]></category>

		<category><![CDATA[cache REACT]]></category>

		<category><![CDATA[cache refresh]]></category>

		<category><![CDATA[cache.cpf changes]]></category>

		<category><![CDATA[REACT command]]></category>

		<category><![CDATA[REACT^STU1]]></category>

		<guid isPermaLink="false">http://www.hassanzaheer.com/?p=94</guid>
		<description><![CDATA[REACT^STU1 routine woks fine on cache version 5.21 (Linux). but surprisingly the command does not work in the cache 2007.x and cache 2008.x for Linux the command works fine for the windows version of cache but did not work accordingly in the Linux. This command is used to refresh the cache.cpf files changes in the [...]]]></description>
			<content:encoded><![CDATA[<p style="line-height: 14.25pt;"><span style="font-family: &quot;Lucida Sans Unicode&quot;,&quot;sans-serif&quot;; color: black; font-size: 10pt;">REACT^STU1 routine woks fine on cache version 5.21 (Linux). but surprisingly the command does not work in the cache 2007.x and cache 2008.x for Linux the command works fine for the windows version of cache but did not work accordingly in the Linux. This command is used to refresh the cache.cpf files changes in the cache without restarting the cache instance. for example if you change cache.cpf file programmatically and want cache to reflect those changes without restart you need to run the REACT^STU1 command on previous version of cache for Linux(5.21) but in cache 2007 and 2008 you need to add the following command before that command.</span></p>
<p style="line-height: 14.25pt;"><span style="font-family: &quot;Arial&quot;,&quot;sans-serif&quot;; color: blue; font-size: 10pt;">do ##class(Config.Configuration).CPFImport($p($zu(86),&#8221;*&#8221;,1))<br />
</span><span style="font-family: &quot;Arial&quot;,&quot;sans-serif&quot;; color: black; font-size: 10pt;">and then write the following command<br />
</span><span style="font-family: &quot;Arial&quot;,&quot;sans-serif&quot;; color: blue; font-size: 10pt;">REACT^STU1($p($zu(86),&#8221;*&#8221;,1),0,2,1)<br />
</span><span style="font-family: &quot;Arial&quot;,&quot;sans-serif&quot;; color: black; font-size: 10pt;">this will solve your problem .</span><span style="font-family: &quot;Lucida Sans Unicode&quot;,&quot;sans-serif&quot;; color: black; font-size: 10pt;"></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hassanzaheer.com/reactstu1-routine-alternative/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Using BackgroundWorker Class</title>
		<link>http://www.hassanzaheer.com/backgroundworker/</link>
		<comments>http://www.hassanzaheer.com/backgroundworker/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 12:52:57 +0000</pubDate>
		<dc:creator>hzaheer</dc:creator>
		
		<category><![CDATA[C#]]></category>

		<category><![CDATA[.net Threading]]></category>

		<category><![CDATA[Background Worker]]></category>

		<category><![CDATA[BackgroundWorker]]></category>

		<category><![CDATA[C# backgroundworker class]]></category>

		<category><![CDATA[C# Threading]]></category>

		<category><![CDATA[Threading]]></category>

		<category><![CDATA[Threading in C#]]></category>

		<guid isPermaLink="false">http://www.hassanzaheer.com/?p=73</guid>
		<description><![CDATA[When running a large task on windows from application the application may seems to be un-responsive and some time it looks that the application is in the state of non-responding.
 Start a new Windows Form Application. Drag a button and a Label on the form write the following lines of code in the click event of [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="margin: 0in 0in 10pt; line-height: 14.25pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span style="font-family: Calibri;"><span style="color: #000000; font-size: 12pt; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;;">When running a large task on windows from application the application may seems to be un-responsive and some time it looks that the application is in the state of non-responding.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt; line-height: 14.25pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span style="font-family: Calibri;"><span style="color: #000000; font-size: 12pt; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;;"><span style="mso-spacerun: yes;"> </span>Start a new Windows Form Application. Drag a button and a Label on the form write the following lines of code in the click event of the button.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt; line-height: 14.25pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span style="font-family: Calibri;"><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #0000ff; font-size: 10pt; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;">for</span><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #000000; font-size: 10pt; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;"> (</span><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #0000ff; font-size: 10pt; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;">int</span></span><span style="font-family: Calibri;"><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #000000; font-size: 10pt; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;"> i = 0; i &lt; 10; i++)<br />
{<br />
<span style="mso-spacerun: yes;">     </span>label1.Text = </span><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #a31515; font-size: 10pt; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;">&#8221; Itreation No &#8220;</span></span><span style="font-family: Calibri;"><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #000000; font-size: 10pt; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;"> + i.ToString();<br />
<span style="mso-spacerun: yes;">     </span>System.Threading.</span><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #2b91af; font-size: 10pt; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;">Thread</span></span><span style="font-family: Calibri;"><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #000000; font-size: 10pt; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;">.Sleep(1000);<br />
</span><span style="color: #000000; font-size: 12pt; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;;"><span style="mso-spacerun: yes;"> </span>}</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt; line-height: 14.25pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span style="font-family: Calibri;"><span style="color: #000000; font-size: 12pt; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;;">Now run the application and u will see that the text on the label is not updating and the application looks like non-responsive. </span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt; line-height: 14.25pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span style="font-family: Calibri;"><span style="color: #000000; font-size: 12pt; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;;">To overcome this problem the BackgroundWorker class allows you to run an operation on a separate, dedicated thread. Time-consuming operations like downloads and database transactions can cause your user interface (UI) to seem as though it has stopped responding while they are running. When you want a responsive UI and you are faced with long delays associated with such operations, the BackgroundWorker class provides a convenient solution.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt; line-height: 14.25pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: #000000; font-size: 12pt; mso-fareast-font-family: &quot;Times New Roman&quot;;">To execute a time-consuming operation in the background, create a BackgroundWorker and listen for events (<a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.dowork.aspx"><span style="color: #0000ff;">DoWork</span></a> , <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.progresschanged.aspx"><span style="color: #0000ff;">ProgressChanged</span></a> , <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.runworkercompleted.aspx"><span style="color: #0000ff;">RunWorkerCompleted</span></a> )<span style="mso-spacerun: yes;">  </span>that report the progress of your operation and signal when your operation is finished. You can create the BackgroundWorker programmatically or you can drag it onto your form from the Components tab of the Toolbox. </span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt; line-height: 14.25pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span style="color: #000000; font-size: 10pt; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: &quot;Lucida Sans Unicode&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;;"><span style="font-family: Calibri;"> </span></span><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: #000000; font-size: 12pt; mso-fareast-font-family: &quot;Times New Roman&quot;;">To set up for a background operation, add an event handler for the <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.dowork.aspx"><span style="color: #0000ff;">DoWork</span></a> event. Call your time-consuming operation in this event handler. To start the operation, call <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.runworkerasync.aspx"><span style="color: #0000ff;">RunWorkerAsync</span></a>. To receive notifications of progress updates, handle the <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.progresschanged.aspx"><span style="color: #0000ff;">ProgressChanged</span></a> event. To receive a notification when the operation is completed, handle the <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.runworkercompleted.aspx"><span style="color: #0000ff;">RunWorkerCompleted</span></a> event.</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: 14.25pt;"><span style="font-family: Calibri;"><span style="color: #000000; font-size: 10pt; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: &quot;Lucida Sans Unicode&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;;">  </span><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #008000; font-size: 10pt; mso-bidi-font-family: &quot;Lucida Sans Unicode&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;">//Create a background worker</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: 14.25pt;"><span style="font-family: Calibri;"><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #0000ff; font-size: 10pt; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;">private</span><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #000000; font-size: 10pt; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;"> System.ComponentModel.</span><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #2b91af; font-size: 10pt; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;">BackgroundWorker</span><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #000000; font-size: 10pt; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;"> backgroundWorker1;</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt; line-height: 14.25pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span style="font-family: Calibri;"><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #000000; font-size: 10pt; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;">Call this method from the constructor of the form to initialize the background worker object.</span></span></p>
<div><span style="font-family: Calibri;"></span></div>
<p><span style="font-family: Calibri;"><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #0000ff; font-size: 10pt; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;"></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none;"><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #0000ff; font-size: 10pt; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;">private</span><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #000000; font-size: 10pt; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;"> </span><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #0000ff; font-size: 10pt; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;">void</span><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #000000; font-size: 10pt; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;"> InitializeBackgoundWorker()</span><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: #000000; font-size: 12pt; mso-fareast-font-family: &quot;Times New Roman&quot;;"><br />
</span><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #000000; font-size: 10pt; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;">{<br />
</span><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: #000000; font-size: 12pt; mso-fareast-font-family: &quot;Times New Roman&quot;;"><span style="mso-spacerun: yes;">   </span><span style="mso-spacerun: yes;"> </span></span><span style="font-family: &quot;Courier New&quot;; color: #008000; font-size: 10pt; mso-no-proof: yes;">//create a new Background Worker</span><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: #000000; font-size: 12pt; mso-fareast-font-family: &quot;Times New Roman&quot;;"><br />
</span><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #0000ff; font-size: 10pt; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;"><span style="mso-spacerun: yes;">    </span><span style="mso-spacerun: yes;"> </span>this</span><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #000000; font-size: 10pt; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;">.backgroundWorker1 = </span><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #0000ff; font-size: 10pt; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;">new</span><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #000000; font-size: 10pt; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;"> System.ComponentModel.</span><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #2b91af; font-size: 10pt; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;">BackgroundWorker</span><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #000000; font-size: 10pt; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;">();<span style="mso-spacerun: yes;">  </span><span style="mso-spacerun: yes;">  </span><span style="mso-spacerun: yes;"> </span></span><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #000000; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;"><br />
</span><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #000000; font-size: 10pt; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;"><span style="mso-spacerun: yes;">       </span><br />
<span style="mso-spacerun: yes;">   </span><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span></span><span style="font-family: &quot;Courier New&quot;; color: #008000; font-size: 10pt; mso-no-proof: yes;">// backgroundworker can report progress updates.</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none;"><span style="font-family: &quot;Courier New&quot;; color: #008000; font-size: 10pt; mso-no-proof: yes;"> </span><span style="mso-no-proof: yes;"><span style="font-size: x-small;"><span style="mso-spacerun: yes;"><span style="color: #000000;">  </span></span><span style="color: #0000ff;">this</span><span style="color: #000000;">.backgroundWorker1.WorkerReportsProgress = </span><span style="color: #0000ff;">true</span></span><span style="color: #000000; font-size: x-small;">;<br />
</span></span><span style="font-size: x-small;"><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #000000; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;"><span style="mso-spacerun: yes;">       </span><br />
<span style="mso-spacerun: yes;">  </span><span style="mso-spacerun: yes;">  </span><span style="mso-spacerun: yes;"> </span></span><span style="color: #008000;">// Set up the BackgroundWorker object by attaching event handlers. </span></span><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: #000000; font-size: 12pt;"><br />
</span><span style="font-size: x-small;"><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #000000; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;"><span style="mso-spacerun: yes;">    </span><span style="mso-spacerun: yes;"> </span>backgroundWorker1.DoWork += </span><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #0000ff; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;">new</span><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #000000; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;"> </span><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #2b91af; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;">DoWorkEventHandler</span><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #000000; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;">(backgroundWorker1_DoWork);</span></span><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: #000000; font-size: 12pt;"><br />
</span><span style="font-size: x-small;"><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #000000; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;"><span style="mso-spacerun: yes;">     </span>backgroundWorker1.ProgressChanged += </span><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #0000ff; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;">new</span><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #000000; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;"> </span><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #2b91af; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;">ProgressChangedEventHandler</span></span><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #000000; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;"><span style="font-size: x-small;">(backgroundWorker1_ProgressChanged);<br />
}</span></span></p>
<div></div>
<div><span style="font-family: Calibri;"></span></div>
<p><span style="font-family: Calibri;"><span style="font-family: &quot;&quot;Courier New&quot;&quot;,&quot;serif&quot;; color: #0000ff; font-size: 10pt; mso-bidi-font-family: &quot;Times New Roman&quot;; mso-fareast-font-family: &quot;Times New Roman&quot;; mso-no-proof: yes;"> </p>
<p></span></span></span></span></p>
<div><span class="code"><br />
private int showMessage(BackgroundWorker worker, DoWorkEventArgs e)<br />
{<br />
for (int i = 0; i &lt; 10; i++)<br />
{<br />
label1.Text = ” Itreation No “ + i.ToString();<br />
System.Threading.Thread.Sleep(1000);<br />
<span class="comment" >// call the worker object to show the progress.<br />
	 //This will call the backgroundWorker1_ProgressChanged Method. </span><br />
	 worker.ReportProgress(i * 10);<br />
}<br />
return 1;<br />
}</span></div>
<p><span class="code"> </p>
<p></span></p>
<div><span class="code"><br />
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)<br />
{<br />
<span class="comment">// Get the BackgroundWorker that raised this event. </span><br />
BackgroundWorker worker = sender as BackgroundWorker;</span></div>
<p><span class="code"><span class="comment"><br />
// Assign the result to the Result property of the DoWorkEventArgs<br />
// object. This is will be available to the<br />
// RunWorkerCompleted eventhandler.<br />
</span><br />
e.Result = showMessage(worker, e);<br />
}<br />
<span class="code"><br />
private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)<br />
{<br />
<span class="comment">// You can show a progress bar or what ever you want to indicate progress<br />
// This event will fire when you call the ReportProgress method of the Background Worker Object </span><br />
}<br />
</span><br />
</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hassanzaheer.com/backgroundworker/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Advance Screen Scrapping</title>
		<link>http://www.hassanzaheer.com/advance-screen-scrapping/</link>
		<comments>http://www.hassanzaheer.com/advance-screen-scrapping/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 14:05:02 +0000</pubDate>
		<dc:creator>hzaheer</dc:creator>
		
		<category><![CDATA[C#]]></category>

		<category><![CDATA[C# Screen Scraping]]></category>

		<category><![CDATA[elance screen scrapping]]></category>

		<category><![CDATA[logged-in data]]></category>

		<category><![CDATA[private data]]></category>

		<category><![CDATA[web Scrapping]]></category>

		<category><![CDATA[Web site data]]></category>

		<guid isPermaLink="false">http://www.hassanzaheer.com/?p=43</guid>
		<description><![CDATA[In the Previous article we disscuss the Simple Screen Scraping task using C#. Now we are moving towards advance Screen Scrapping in this we will Scrap the data which required user to login first. This is a very interesting and challenging task. In the following code we will scrap data from the elance site.
// Create [...]]]></description>
			<content:encoded><![CDATA[<p>In the Previous article we disscuss the Simple Screen Scraping task using C#. Now we are moving towards advance Screen Scrapping in this we will Scrap the data which required user to login first. This is a very interesting and challenging task. In the following code we will scrap data from the elance site.</p>
<p><span class="comment">// Create the Web Request Object and pass it the URL of the Login page.</span><br />
<span class="code">HttpWebRequest req = (HttpWebRequest)WebRequest.Create(&#8221;https://secure.elance.com/php/reg/main/signInAHR.php&#8221;);</span><br />
<span class="comment"><br />
// Set that request is coming from some browser e.g. Fire Fox.</span><br />
<span class="code">req.UserAgent = &#8220;User-Agent=Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5&#8243;;</span><br />
<span class="comment"><br />
// assign a new cookie to the cookie container.</span><br />
<span class="code">req.CookieContainer = new CookieContainer();</span><br />
<span class="comment"><br />
// Set values for the request</span><br />
<span class="code">req.Method = &#8220;POST&#8221;;<br />
req.ContentType = &#8220;application/x-www-form-urlencoded&#8221;;<br />
req.KeepAlive = true;<br />
req.Accept = &#8220;text/javascript, text/html, application/xml, text/xml, */*&#8221;;<br />
req.Referer = &#8220;https://secure.elance.com/php/reg/main/signInIframe.php&#8221;;<br />
</span></p>
<p>Now the most trickey section we have to send the user name and password to the requested page.I almost every case the user name and password are sent as post data. so we have to create a post data accordingly.</p>
<p><span class="code">strNewValue = &#8220;referrer=http://www.elance.com/p/landing/provider.html&#8221;;</span><br />
<span class="code">strNewValue += &#8220;&amp;mode=signin&#8221;;<br />
strNewValue += &#8220;&amp;login_name=elance_User&#8221;;<br />
strNewValue += &#8220;&amp;password=elance_pwd&#8221;;<br />
strNewValue += &#8220;&amp;email1=&#8221;;<br />
strNewValue += &#8220;&amp;email2=&#8221;;</span><br />
<span class="code">byte[] byteArray = Encoding.UTF8.GetBytes(strNewValue);<br />
</span></p>
<p><span class="comment">// Set the ContentLength property of the WebRequest.<br />
</span><span class="code">req.ContentLength = byteArray.Length;</span></p>
<p><span class="comment">// Get the request stream.</span><br />
<span class="code">Stream dataStream = req.GetRequestStream();</span></p>
<p><span class="comment">// Write the data to the request stream.</span><br />
<span class="code">dataStream.Write(byteArray, 0, byteArray.Length);</span><br />
<span class="code">dataStream.Close();</span></p>
<p><span class="comment">// Do the request to get the response</span><br />
<span class="code">HttpWebResponse wr = (HttpWebResponse)req.GetResponse();</span></p>
<p><span class="comment">// get the Login Cookie</span><br />
<span class="code">CookieContainer ccTemp  = req.CookieContainer; </span></p>
<p>Now you can use this cookie Container with every further request you send to the site and in response you will get the logged-in data.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hassanzaheer.com/advance-screen-scrapping/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Simple Screen Scraping in C#</title>
		<link>http://www.hassanzaheer.com/screen-scraping-in-net/</link>
		<comments>http://www.hassanzaheer.com/screen-scraping-in-net/#comments</comments>
		<pubDate>Mon, 26 Jan 2009 12:46:57 +0000</pubDate>
		<dc:creator>hzaheer</dc:creator>
		
		<category><![CDATA[C#]]></category>

		<category><![CDATA[Screen Scraping]]></category>

		<category><![CDATA[Screen Scrapingin C#]]></category>

		<category><![CDATA[Simple screen scraping]]></category>

		<category><![CDATA[Simple screen scraping in C#]]></category>

		<category><![CDATA[WebRequest]]></category>

		<category><![CDATA[WebResponse]]></category>

		<guid isPermaLink="false">http://www.hassanzaheer.com/?p=30</guid>
		<description><![CDATA[In C# Microsoft has provided HttpWebRequest and HttpWebResponse classes for the screen Scraping task. you have to write only few lines to get the work done.
String URL = @&#8221;www.abcd.com&#8221;;
// Prepare the HttpWebRequest
System.Net.HttpWebRequest htpreq = (HttpWebRequest)System.Net.WebRequest.Create(URL); 
// Define Method Get
htpreq.Method =&#8220;GET&#8221;; 
// Get the Response
System.Net.WebResponse htpRes = htpreq.GetResponse(); 
// Read the Response Stream
System.IO.StreamReader sr = new System.IO.StreamReader(htpRes.GetResponseStream()); 
 //get the response [...]]]></description>
			<content:encoded><![CDATA[<p><strong>In C# Microsoft has provided HttpWebRequest and HttpWebResponse classes for the screen Scraping task. you have to write only few lines to get the work done.</strong></p>
<p>String URL = @&#8221;www.abcd.com&#8221;;<br />
// Prepare the HttpWebRequest<br />
<span style="font-size: x-small;"><span style="font-size: x-small;">System.Net.</span></span><span style="font-size: x-small; color: #2b91af;"><span style="font-size: x-small; color: #2b91af;">HttpWebRequest</span></span><span style="font-size: x-small;"> htpreq = (</span><span style="font-size: x-small; color: #2b91af;"><span style="font-size: x-small; color: #2b91af;">HttpWebRequest</span></span><span style="font-size: x-small;">)System.Net.</span><span style="font-size: x-small; color: #2b91af;"><span style="font-size: x-small; color: #2b91af;">WebRequest</span></span><span style="font-size: x-small;">.Create(URL);<span style="font-size: x-small;"> <br />
</span></span>// Define Method Get<br />
<span style="font-size: x-small;"><span style="font-size: x-small;">htpreq.Method =</span></span><span style="font-size: x-small; color: #a31515;"><span style="font-size: x-small; color: #a31515;">&#8220;GET&#8221;</span></span><span style="font-size: x-small;">;<span style="font-size: x-small;"> <br />
</span></span>// Get the Response</p>
<p><span style="font-size: x-small;"><span style="font-size: x-small;">System.Net.</span></span><span style="font-size: x-small; color: #2b91af;"><span style="font-size: x-small; color: #2b91af;">WebResponse </span></span><span style="font-size: x-small;">htpRes = htpreq.GetResponse();<span style="font-size: x-small;"> </span></span></p>
<div>// Read the Response Stream</div>
<div><span style="font-size: x-small;"><span style="font-size: x-small;">System.IO.</span></span><span style="font-size: x-small; color: #2b91af;"><span style="font-size: x-small; color: #2b91af;">StreamReader</span></span><span style="font-size: x-small;"> sr = </span><span style="font-size: x-small; color: #0000ff;"><span style="font-size: x-small; color: #0000ff;">new</span></span><span style="font-size: x-small;"> System.IO.</span><span style="font-size: x-small; color: #2b91af;"><span style="font-size: x-small; color: #2b91af;">StreamReader</span></span><span style="font-size: x-small;">(htpRes.GetResponseStream());<span style="font-size: x-small;"> </span></span></div>
<div><span style="font-size: x-small;"><span style="font-size: x-small;"> </span></span>//get the response in string format.<br />
String result = sr.ReadToEnd();<br />
// Create a text File name test.text</div>
<div><span style="font-size: x-small;"><span style="font-size: x-small;">System.IO.</span></span><span style="font-size: x-small; color: #2b91af;"><span style="font-size: x-small; color: #2b91af;">StreamWriter</span></span><span style="font-size: x-small;"> file = System.IO.</span><span style="font-size: x-small; color: #2b91af;"><span style="font-size: x-small; color: #2b91af;">File</span></span><span style="font-size: x-small;">.CreateText</span>(&#8221;test.text&#8221;);<br />
// write the results in the file<br />
file.Write(result);<br />
// Close the File<br />
file.Close();</div>
<p><strong><br />
Done. </strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hassanzaheer.com/screen-scraping-in-net/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
