Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:

C#
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 21:05pm

1 solution

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
C#
lt.Add(videoframe.Text);
to
C#
lt.Add(videoframe);
 
Share this answer
 
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900