Project Description
Embed YouTube object into ASP.NET AJAX-extended web page; build simple dynamic playlist control
1. Default Web page "Default.aspx" with corresponding code behind: both to be placed in Application root directory (ASP.NET 2.0+)
2. Ajax Library file (AjaxControlToolkit.dll) to be placed in Bin directory
(NOTE: ALL CONTENT IS SHOWN FOR DEMO PURPOSE ONLY)
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>DEMO | Embebbed YouTube object</title> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <asp:UpdatePanel ID="UpdatePanel1" runat="server" updatemode="Conditional" > <ContentTemplate> <div> <!-- ALL CONTENT IS SHOWN FOR DEMO PURPOSE ONLY--> <asp:DropDownList ID="cmbPlaylist" runat="server" AutoPostBack="True"> <asp:ListItem Value="raRaxt_KM9Q">Sound Of Silence (Masters of Chant)</asp:ListItem> <asp:ListItem Value="WALIARHHLII">Miss Teen USA South Carolina 2007</asp:ListItem> </asp:DropDownList> <br /><br /> <asp:Literal ID="Literal1" runat="server"></asp:Literal> </div> </ContentTemplate> </asp:UpdatePanel> </form> </body> </html>
//**************************************************************************** // Module : Default.aspx.cs // Type : ASP.NET web page code behind // Developer : Alexander Bell (Infosoft International Inc) // DateCreated : 06/29/2009 // LastModified : 09/30/2009 //**************************************************************************** // DISCLAIMER: This Application is provide on AS IS basis without any warranty //**************************************************************************** //**************************************************************************** // TERMS OF USE : ALL YouTube CONTENT IS SHOWN AS DEMO SAMPLE ONLY // : You can use it at your sole risk //**************************************************************************** using System; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Literal1.Text = GetYouTubeScript(cmbPlaylist.SelectedValue);} protected string GetYouTubeScript(string id) { string scr = @"<object width='320' height='240'> "; scr = scr + @"<param name='movie' value='http://www.youtube.com/v/" + id + "'></param> "; scr = scr + @"<param name='allowFullScreen' value='true'></param> "; scr = scr + @"<param name='allowscriptaccess' value='always'></param> "; scr = scr + @"<embed src='http://www.youtube.com/v/" + id + "' "; scr = scr + @"type='application/x-shockwave-flash' allowscriptaccess='always' "; scr = scr + @"allowfullscreen='true' width='320' height='240'> "; scr = scr + @"</embed></object>"; return scr; } }
YouTube | ASP.NET | Media Player | Video Player | HTML5 | CSS 3 | Javascript | RIA | Silverlight | Web TV |