Dynamically addign a youtube video by video id in the serverside c# code


I would like to dynamically embed videos to my page.

I am using below code, vidies.FirstOrDefault(); has my first video id to show but unfortunately i can not get this to work. Video player displays in my page but video would not load. When i manually write the video id to the url http://www.youtube.com/embed/xxxxxx then i see the video is loading so how can i achieve what i am trying to do? i would like to show the videos that i calculate in the server side

Note i tried adding + after embed/ but this also did not work

      <% string n = vidies.FirstOrDefault(); %>
     <iframe id="ytplayer" type="text/html" width="640" height="390"
  src="http://www.youtube.com/embed/"<% vidies.FirstOrDefault(); %>

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Duy PhamFreelance IT ConsultantCommented:
Could it be that your code put video id outside of " (double quote)?
David Johnson, CD, MVPOwnerCommented:
videosource = "http://www.youtube.com/embed/"
myvideo = videosource + vidies.FirstOrDefault()
 <iframe id="ytplayer" type="text/html" width="640" height="390" src=myvideo>  frameborder="0"/>

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nicedoneAuthor Commented:
Yeap this has done it , thank you
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.