2012-02-11 69 views
1

我想在我的頁面中顯示youtube視頻。如何在網站中顯示youtube視頻

http://www.youtube.com/v/u1zgFlCw8Aw?fs=1 

以上是它的網址。

我寫了嵌入標籤,但無法正確完成。

我可以使用嵌入標籤或其他方式在我的網站上使用其網址顯示您的管狀視頻嗎?如下所示

回答

0

Embedding a Youtube video

的.aspx頁面

<asp:Label ID="LabelShowYouTubeVideo" runat="server"></asp:Label> 

.aspx.cs代碼隱藏文件:

// this is the YouTube Video ID, here you replace by 
// the code of the one you want to show 
string VideoID = "nQJACVmankY"; 

// Here this code you show in the label the YouTube Video that you put the code 
LabelShowYouTubeVideo.Text = "<object width='425' height='355'><param name='movie' value='http://www.youtube.com/v/" + VideoID + "'></param><param name='wmode' value='transparent'></param><embed src='http://www.youtube.com/v/" + VideoID + "' type='application/x-shockwave-flash' wmode='transparent' width='425' height='355'></embed></object>"; 

編輯:添加部分:看?根據需要添加到網址。我複製了我在ASP.NET論壇中發現的內容,但並未自行運行,但人們回答說它完美無缺!

+0

我有網址like..http://www.youtube.com/watch?v = YR12Z8f1Dh8所以不能做我喜歡直接傳遞網址到對象 – 2012-02-11 14:23:22

+1

爲什麼標籤?更好Literal和EnableViewState = false – Aristos 2012-02-11 14:29:06

+0

此網址在以上示例中不起作用.. http://www.youtube.com/watch?v=YR12Z8f1Dh8 – 2012-02-11 14:30:39