Input string was not in a correct format. I dont know why, i've used this format before, i guess i'm missing something
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 3; i++)
{
sb.Append(string.Format(@"
<button onclick=""playPause{0}()"" type=""button"" >Play/Pause</button>
<br>
<video id=""video{0}"" width=""420"" controls>
<source src=""videos/arturo.mp4"" type=""video/mp4"">
<source src=""videos/arturo.ogg"" type=""video/ogg"">
Your browser does not support HTML5 video.
</video>
<script type=""text/javascript"" >
function playPause{0}()
{
var myvideo = document.getElementById('video{0}');
if (myvideo.paused)
myvideo.play();
else
myvideo.pause();
}
</script>
", i));
}
Literal1.Text = sb.ToString();
You need to double the curly braces
....
function playPause{0}()
{{
var myvideo = document.getElementById('video{0}');
if (myvideo.paused)
myvideo.play();
else
myvideo.pause();
}}
....
Otherwise the string format interpret them as placeholder for the next argument, that you don't supply in the argument list (It is like you do for the double quotes)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.