C#:
protected void Page_Load(object sender, EventArgs e)
{
string imgURL = GetYouTubeImage("https://www.youtube.com/watch?v=3Kk-yZ7VpeA");
imgYourTube.ImageUrl = imgURL;
}
public string GetYouTubeImage(string videoUrl)
{
int mInd = videoUrl.IndexOf("v=");
if (mInd != -1)
{
string strVideoCode = videoUrl.Substring(videoUrl.IndexOf("v=") + 2);
int ind = strVideoCode.IndexOf("?");
strVideoCode = strVideoCode.Substring(0, ind == -1 ? strVideoCode.Length : ind);
return "https://img.youtube.com/vi/" + strVideoCode + "/default.jpg";
}
else
return "";
}
HTML:
<form id="form1" runat="server">
<asp:image id="imgYourTube" runat="server" clientidmode="Static" xmlns:asp="#unknown" />
</form>