How to Play youtube video in Asp net application using youtube video url

If you want to Embed any YouTube url into ASP.NET page, please got thought the below article. Here I have explained how to play youtube video in Asp net application using youtube video url.

Please create a sample Web Page with a Literal control (ID="youtubeVideo") as shown below :

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="PlayYouTubeVideo.aspx.cs" Inherits="PlayYouTubeVideo" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
   <head runat="server">
      <title>Play YouTube Video : Hima Sagar Kutikuppala</title>
   </head>
   <body>
      <form id="myform" runat="server">
         <div>
            <h3>Play YouTube Video</h3>
            <br />
            <asp:literal ID="youtubeVideo" runat="server"></asp:literal>
         </div>
      </form>
   </body>
</html>

Please find below the code behind code:

using System;

/// <summary>
/// Play YouTube Video
/// Author : Himasagar Kutikuppala  ( www.himasagar.com )
/// </summary>
public partial class PlayYouTubeVideo : System.Web.UI.Page
{
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
    protected void Page_Load(object sender, EventArgs e)
    {
        string source = @"<object width='500' height='300'> ";
        source = source + @"<param name='movie' value='http://www.youtube.com/v/gWtL24IEpy0'></param> ";
        source = source + @"<param name='allowFullScreen' value='true'></param> ";
        source = source + @"<param name='allowscriptaccess' value='always'></param> ";
        source = source + @"<embed src='http://www.youtube.com/v/gWtL24IEpy0'";
        source = source + @"type='application/x-shockwave-flash' allowscriptaccess='always' ";
        source = source + @"allowfullscreen='true' width='500' height='300'> ";
        source = source + @"</embed></object>";

        youtubeVideo.Text = source;
    }
}

Demo:

Play YouTube Video



What is GST

GST (Goods and Service Tax) is a comprehensive tax on the supply of goods and services at each stage of any transaction. Read More

Income Tax Information

An income tax is a tax imposed by government on income earned by you. Income tax is a key source of funds that the government uses to fund its activities and serve the public. Read More

General Insurance Companies in India

General insurance is insurance for valuables other than our life and health. General insurance covers the insurer against damage, loss and theft of your valuables. Read More



Types of Bank Loans In India

Loan means lending money from one individual or entity to another. A loan has three components – principal or the borrowed amount, rate of interest and tenure or duration for which the loan is availed. Read More

List of Banks in India

The Reserve Bank of India is the central Bank that is fully owned by the Government of India. It is governed by a central board (headed by a Governor) appointed by the Central Government. Read More

List of Educational Institutions in India

The following list of comprehensive websites on higher education in India. These websites will provide detailed information on education system in India. Read More