C# 如何通过查询字符串更改youtube嵌入代码中URL的一部分
我正在用C#在ASP.NET上编程。 我想知道如何通过查询字符串更改youtube嵌入代码中URL的一部分。 比如说C# 如何通过查询字符串更改youtube嵌入代码中URL的一部分,c#,asp.net,C#,Asp.net,我正在用C#在ASP.NET上编程。 我想知道如何通过查询字符串更改youtube嵌入代码中URL的一部分。 比如说 <iframe width="560" height="315" src="http://www.youtube.com/embed/**5CZobYTEwaY**" frameborder="0" allowfullscreen></iframe> 我想通过查询字符串接收视频变量并插入,而不是5CZobYTEwaY 如果有人能帮助我,我将非常感激。
<iframe width="560" height="315" src="http://www.youtube.com/embed/**5CZobYTEwaY**" frameborder="0" allowfullscreen></iframe>
我想通过查询字符串接收视频变量并插入,而不是5CZobYTEwaY
如果有人能帮助我,我将非常感激。您可以使用
您可以为iframe添加属性,同时将其设置为在服务器上运行
example = "5CZobYTEwaY";
ex_iframe.Attributes.Add("src", "http://www.youtube.com/embed/" + example);
请将查询字符串变量“id”替换为您的以下代码
下面的示例使用test.asp?id=5CZobYTEwaY
<iframe width="560" height="315" src='http://www.youtube.com/embed/<%=Request.QueryString["id"]%>' frameborder="0" allowfullscreen></iframe>
example = "5CZobYTEwaY";
ex_iframe.Attributes.Add("src", "http://www.youtube.com/embed/" + example);
<iframe width="560" height="315" src='http://www.youtube.com/embed/<%=Request.QueryString["id"]%>' frameborder="0" allowfullscreen></iframe>