<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>With Great Power comes Great Response.write("Ability") : YouTube</title><link>http://blogs.msdn.com/phaniraj/archive/tags/YouTube/default.aspx</link><description>Tags: YouTube</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Building a Simple Client Callback to YouTube with Atlas</title><link>http://blogs.msdn.com/phaniraj/archive/2006/12/02/building-a-simple-client-script-binding-control-with-atlas.aspx</link><pubDate>Sat, 02 Dec 2006 03:25:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1188038</guid><dc:creator>PhaniRajuYN</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/phaniraj/comments/1188038.aspx</comments><wfw:commentRss>http://blogs.msdn.com/phaniraj/commentrss.aspx?PostID=1188038</wfw:commentRss><description>&lt;PRE&gt;   &lt;P&gt;We will talk about how we can use Atlas to talk to YouTube using the REST protocol .&lt;/P&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) Download Visual Web Developer , Go &lt;A href="http://msdn.microsoft.com/vstudio/express/vwd/download/" target=_blank mce_href="http://msdn.microsoft.com/vstudio/express/vwd/download/"&gt;&lt;FONT color=#669966&gt;Here&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;2) Download Atlas , Go &lt;A href="http://ajax.asp.net/default.aspx?tabid=47&amp;amp;subtabid=471" target=_blank mce_href="http://ajax.asp.net/default.aspx?tabid=47&amp;amp;subtabid=471"&gt;&lt;FONT color=#669966&gt;Here&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;3) Get an Application Developer ID at Youtube . Go &lt;A href="http://www.youtube.com/dev" target=_blank mce_href="http://www.youtube.com/dev"&gt;&lt;FONT color=#669966&gt;Here&lt;/FONT&gt;&lt;/A&gt; &lt;/P&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After you are done  running around the world collecting tools , you should be all set to take on YouTube .&lt;/P&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have a WebService that talks to YouTube's REST Interface and downloads Data .&lt;/P&gt;&lt;P&gt;Without Getting into Discussions of using Service Bridges , we will have a wrapper over the YouTube REST-API using a &lt;/P&gt;&lt;P&gt;webservice on the Server-Side.&lt;/P&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;The YouTube Wrapper Class&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;&lt;/U&gt;&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have a class that wraps the Fucntionality Provided by YouTube REST APIs , lets Call it "YouTubeSearch".&lt;/P&gt;&lt;P&gt;It will  have a method called "SearchTags" which takes a Tagname as an input and will return results of the type "VideoRow"&lt;/P&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt; Schema of VideoRow  Class&lt;/P&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&amp;nbsp;&lt;PRE class=csharpcode&gt;  ClassName  : VideoRow  
  Methods    : None   
  Attributes :

  Name          Description
   Url           The Url to View the Video on 
   ThumbNailUrl  The Url to View the thumbnail of the video
   Description   A Short Description of the video&lt;/PRE&gt;&lt;PRE class=csharpcode&gt;&amp;nbsp;&lt;/PRE&gt;&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;&lt;P&gt;Signature of the SearchTags method of YouTubeSearch &lt;/P&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;static&lt;/SPAN&gt; List&amp;lt;VideoRow&amp;gt; SearchVideoTags(&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; tagName)&lt;/PRE&gt;&lt;PRE class=csharpcode&gt;&amp;nbsp;&lt;/PRE&gt;&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;&lt;P&gt;Make a WebClient Request to the RESTBased Webservice and gather the downloaded info onto a string&lt;/P&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; requestURL = &lt;SPAN class=str&gt;"http://www.youtube.com/api2_rest?method=youtube.videos.list_by_tag&amp;amp;dev_id="&lt;/SPAN&gt; +
    youTubeAppId + &lt;SPAN class=str&gt;"&amp;amp;tag="&lt;/SPAN&gt; + tagName + &lt;SPAN class=str&gt;"&amp;amp;per_page=6"&lt;/SPAN&gt; 
WebClient restRequest = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; WebClient();
&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; dataDownloaded = restRequest.DownloadString(requestURL);&lt;/PRE&gt;&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt; Read the Downloaded String onto a DataSet&lt;/P&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=csharpcode&gt;DataSet dsResultSet = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; DataSet(); 
StringReader dataWriter = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; StringReader(dataDownloaded);
dsResultSet.ReadXml(dataWriter);&lt;/PRE&gt;&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt; Convert the DataRows onto VideoRows&lt;P&gt;&amp;nbsp;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;PRE class=csharpcode&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;foreach&lt;/SPAN&gt; (DataRow drVideoRow &lt;SPAN class=kwrd&gt;in&lt;/SPAN&gt; dsResultSet.Tables[&lt;SPAN class=str&gt;"video"&lt;/SPAN&gt;].Rows)
{     
searchResults.Add(&lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; VideoRow( drVideoRow[&lt;SPAN class=str&gt;"url"&lt;/SPAN&gt;].ToString(), 
drVideoRow[&lt;SPAN class=str&gt;"thumbnail_url"&lt;/SPAN&gt;].ToString(), 
drVideoRow[&lt;SPAN class=str&gt;"description"&lt;/SPAN&gt;].ToString()));
}&lt;/PRE&gt;&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt; return searchResults back to Caller&lt;/P&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;The ServerSide WebService&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;&lt;/U&gt;&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) Create a WebService &lt;/P&gt;&lt;P&gt;2) Include the Following Directive to make the Web-Service "Client Proxiable"&lt;/P&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; Microsoft.Web.Script.Services;&lt;/PRE&gt;&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;&lt;BLOCKQUOTE&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;3) Decorate the Webservice with the "ScriptService" attribute.&lt;/P&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=csharpcode&gt;[ScriptService]
&lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;class&lt;/SPAN&gt; AjaxService : System.Web.Services.WebService &lt;/PRE&gt;&lt;PRE class=csharpcode&gt;&amp;nbsp;&lt;/PRE&gt;&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;&lt;P&gt;4) The methods of the webservice that need to be proxied onto the client are marked as "&lt;STRONG&gt;WebMethod"&lt;/STRONG&gt;&lt;/P&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=csharpcode&gt;[WebMethod]
&lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; SearchYouTube(&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; tagName)&lt;/PRE&gt;&lt;PRE class=csharpcode&gt;&amp;nbsp;&lt;/PRE&gt;&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;&lt;P&gt;5) Call the &lt;STRONG&gt;SearchVideoTags &lt;/STRONG&gt;method of the YouTube Wrapper class with the Parameter passed from the Client Proxy.&lt;/P&gt;&lt;P&gt;Have the Content Formatted in the form of a Usercontrol's rendered output  .&lt;/P&gt;&lt;P&gt;  I use a ViewManager to implement the MVC pattern here.&lt;/P&gt;&lt;P&gt;For an explanation of the same , refer to ScottGu's blog post &lt;A href="http://weblogs.asp.net/scottgu/archive/2006/10/22/Tip_2F00_Trick_3A00_-Cool-UI-Templating-Technique-to-use-with-ASP.NET-AJAX-for-non_2D00_UpdatePanel-scenarios.aspx" mce_href="http://weblogs.asp.net/scottgu/archive/2006/10/22/Tip_2F00_Trick_3A00_-Cool-UI-Templating-Technique-to-use-with-ASP.NET-AJAX-for-non_2D00_UpdatePanel-scenarios.aspx"&gt;&lt;FONT color=#669966&gt;Here&lt;/FONT&gt;&lt;/A&gt; .&lt;/P&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Markup of the View&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;&lt;/U&gt;&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&amp;lt;asp:DataList runat=&lt;SPAN class=str&gt;"server"&lt;/SPAN&gt; ID=&lt;SPAN class=str&gt;"grdvSearchResults"&lt;/SPAN&gt; 
         RepeatColumns=&lt;SPAN class=str&gt;"6"&lt;/SPAN&gt; RepeatDirection=&lt;SPAN class=str&gt;"Horizontal"&lt;/SPAN&gt;         
        BorderStyle=&lt;SPAN class=str&gt;"None"&lt;/SPAN&gt; BorderWidth=&lt;SPAN class=str&gt;"0px"&lt;/SPAN&gt; 
         GridLines=&lt;SPAN class=str&gt;"none"&lt;/SPAN&gt; Width=&lt;SPAN class=str&gt;"100%"&lt;/SPAN&gt;&amp;gt;  
&amp;lt;ItemTemplate&amp;gt;         
&amp;lt;a href=&lt;SPAN class=str&gt;"&amp;lt;%#DataBinder.Eval(Container.DataItem, "&lt;/SPAN&gt;Url&lt;SPAN class=str&gt;")%&amp;gt;"&lt;/SPAN&gt;&amp;gt;           
   &amp;lt;img  src=&lt;SPAN class=str&gt;"&amp;lt;%#DataBinder.Eval(Container.DataItem, "&lt;/SPAN&gt;ThumbNailUrl&lt;SPAN class=str&gt;")%&amp;gt;"&lt;/SPAN&gt;                  
     title=&lt;SPAN class=str&gt;"&amp;lt;%#DataBinder.Eval(Container.DataItem, "&lt;/SPAN&gt;Description&lt;SPAN class=str&gt;")%&amp;gt;"&lt;/SPAN&gt;/&amp;gt; 
  &amp;lt;/a&amp;gt;   
&amp;lt;/ItemTemplate&amp;gt;   
&amp;lt;SeparatorTemplate&amp;gt;   &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;   &amp;lt;/SeparatorTemplate&amp;gt;
&amp;lt;/asp:DataList&amp;gt;&lt;/PRE&gt;&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;&lt;P&gt; 
6) Return the Rendered View in the form of a String back to the Client Method calling this Webmethod .&lt;/P&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt; The Client Web Page &lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Following Controls will be put in ..&lt;/P&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;HTML Controls &lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt; 1) A textbox which provides the Tag to search for. &lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;input&lt;/SPAN&gt; &lt;SPAN class=attr&gt;type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="text"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;id&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="searchKey"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/PRE&gt;&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt; 2) A button to call the  Search Function in the Webservice .&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;input&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="button"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;id&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="btnSearchServer"&lt;/SPAN&gt; 
    &lt;SPAN class=attr&gt;onclick&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;="SearchYouTube(searchKey.value)"&lt;/SPAN&gt; 
    &lt;SPAN class=attr&gt;value&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;="Search You Tube"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt; 3) A Div to show the Server Returned Markup .&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;div&lt;/SPAN&gt; &lt;SPAN class=attr&gt;id&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="serverMarkupRecipient"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
     Search Results Go Here
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;div&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;AJAX Controls&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;A Script Manager to Generate the proxy of the webservice and handle all Ajax Scripts &lt;/P&gt;&lt;P&gt;We will add a Service Reference to the WebService that we want a Client proxy for ..&lt;/P&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;asp:ScriptManager&lt;/SPAN&gt; &lt;SPAN class=attr&gt;runat&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="server"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;ID&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="scrpManager"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt; 
     &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;Services&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;   
       &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;asp:ServiceReference&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Path&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="~/Services/AjaxService.asmx"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;      
     &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;Services&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;asp:ScriptManager&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Javascript Code to Call the Webservice&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;function&lt;/SPAN&gt; SearchYouTube( searchTag ) 
{   
&lt;SPAN class=rem&gt;// The Proxy generated enables you to do something as simple as calling a method on an object .   &lt;/SPAN&gt;
&lt;SPAN class=rem&gt;// the Two parameters are &amp;lt;inputparam&amp;gt;,&amp;lt;OnCompleteCallback&amp;gt;   &lt;/SPAN&gt;
    AjaxService.SearchYouTube(searchTag,VideSearchCallback ); 
} &lt;/PRE&gt;&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;&lt;PRE class=csharpcode&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;function&lt;/SPAN&gt; VideSearchCallback(returnValue)
{
  &lt;SPAN class=rem&gt;// Microsft Ajax  enables Browser - Independent ways to wrappers To Document.getElementById as $get    //Show the Div Element   &lt;/SPAN&gt;
 $get(&lt;SPAN class=str&gt;"serverMarkupRecipient"&lt;/SPAN&gt;).style.display= &lt;SPAN class=str&gt;"block"&lt;/SPAN&gt;  
  &lt;SPAN class=rem&gt;//Inject Server Returned Markup into the DIV element    &lt;/SPAN&gt;
 $get(&lt;SPAN class=str&gt;"serverMarkupRecipient"&lt;/SPAN&gt;).innerHTML = returnValue;
}&lt;/PRE&gt;&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;&lt;P&gt;Thats it , You can download the Source of the application Here &lt;/P&gt;&lt;/PRE&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1188038" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/phaniraj/attachment/1188038.ashx" length="180152" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/phaniraj/archive/tags/YouTube/default.aspx">YouTube</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/AJAX/default.aspx">AJAX</category></item></channel></rss>