[英]I am getting Input string was not in a correct format although i used the same format over and over again
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) 否则,字符串格式会将它们解释为下一个参数的占位符,您不会在参数列表中提供它(就像您对双引号所做的那样)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.