Click here to Skip to main content
15,899,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm programming on ASP.NET with C#. I want to know how to change a part of URL in embed code from youtube by Query String. for example
HTML
<iframe width="560" height="315" src="http://www.youtube.com/embed/**5CZobYTEwaY**" frameborder="0" allowfullscreen></iframe>


I want to receive the variable of video by query string and insert instead of 5CZobYTEwaY.

I will be very thankful if anybody help me.
Posted

As you're doing this in ASP.NET, this is trivial. Put a Literal control on your form, form this HTML using the query string values, and assign it to the literal.
 
Share this answer
 
Comments
asasi_kamal 4-Aug-12 1:33am    
Can u please explain more or introduce a link to study more, my dear friend?
Christian Graus 4-Aug-12 2:21am    
If you buy any basic ASP.NET book, it will explain to you what a literal control is, and how to work with the query string. If you don't know these things, you're too much of a beginner to learn from forum replies, you should google and read detailed articles
asasi_kamal 4-Aug-12 2:39am    
i think this kind of answer is not good for a professional programmer such as u.
It's better to be more Modest my brother. tq any away. i solved it and i shared it for others.
Christian Graus 4-Aug-12 2:50am    
I am sorry, but, I gave you the names of the controls and what to do. I couldn't give you more info unless I took the time to type 'asp.net literal control' in to google for you, or I wrote all the code for you. I was also being serious - too many people are posting questions here when they can't follow the answers. If you need in depth explanations, a forum reply won't do, you need to read articles. I don't think the code you have above actually compiles, it's missing information, but, he's done what I told you to do. If you needed him to do that, and could not understand what I told you, that just proves you have no clue what you're doing and should take the time to learn instead of always having to hope that someone will give you a copy and paste solution, as you don't know enough about programming to follow simple instructions. It's precisely because I want to help real programmers ( which does not mean GREAT ones, only ones trying to learn ), that I don't ever give a copy and paste solution in this forum. If you don't care enough to write your own code, then I don't see why I should write it for you.
asasi_kamal 15-Aug-12 4:38am    
leave it dear Christian. I was under pressure of my project's schedule time.
You can use <asp:Literal to output a clean string on your page.
Do this:

ASP.NET
<iframe width="560" height="315" src="http://www.youtube.com/embed/<asp:Literal ID="keyOfVideo" runat="server"></asp:Literal>" frameborder="0" allowfullscreen></iframe>


CodeBehind in C#'s Page_load():

C#
keyOfVideo.Text = "SomeKey";
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900