Click here to Skip to main content
14,361,384 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hey,
i am trying to add literal string.format values to list, literal has youtube embed link. having no success while adding literal to list. some solution will be deeply appreciated.
Regards

What I have tried:

List<Literal> lt = new List<Literal>();
string url = "https://www.youtube.com/embed/9bi9eDZUJPQ";
var videoframe = new Literal();
videoframe.Text = string.Format(@"<iframe width=""628"" height=""374"" src=""{0}"" frameborder=""0"" allowfullscreen></iframe>", url);
lt.Add(videoframe.Text);
foreach (Literal l in lt)Panel1.Controls.Add(l); { }
Posted
Updated 4-Oct-19 22:05pm

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

lt variable is defined as a List<Literal>, but you are trying to add it a string value (the Text property of the videoframe variable).
You can try to change
lt.Add(videoframe.Text);
to
lt.Add(videoframe);
   
Comments
Aftab Iqbal Clips 5-Oct-19 4:58am
   
good explanation. i cant believe that solution was so simple
thanks, have a nice day
phil.o 5-Oct-19 5:27am
   
You're welcome!

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100