Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何通过查询字符串更改youtube嵌入代码中URL的一部分_C#_Asp.net - Fatal编程技术网

C# 如何通过查询字符串更改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 如果有人能帮助我,我将非常感激。

我正在用C#在ASP.NET上编程。 我想知道如何通过查询字符串更改youtube嵌入代码中URL的一部分。 比如说

<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>