ASP.NET c#打印出html内容
我正在为一个大学项目学习.NET,对PHP已经有了扎实的知识。我想了解如何像在PHP中一样在.NET中打印html内容 PHP示例:ASP.NET c#打印出html内容,c#,php,html,asp.net,C#,Php,Html,Asp.net,我正在为一个大学项目学习.NET,对PHP已经有了扎实的知识。我想了解如何像在PHP中一样在.NET中打印html内容 PHP示例: <?php $array = array("foo", "bar", "hello", "world"); for($i=0; $i<count($array); $i++) { echo "<p id=\"$i\">This is paragraph $i.</p>"; } ?>
<?php
$array = array("foo", "bar", "hello", "world");
for($i=0; $i<count($array); $i++) {
echo "<p id=\"$i\">This is paragraph $i.</p>";
}
?>
这是我试图实现和理解的一个简单例子。如何在ASP.NET中执行上述操作
感谢您的帮助。请执行以下操作:
<%
var array = new string[]{"foo", "bar", "hello", "world"};
Response.ContentType = "text/html";
for(int i = 0; i < array.Length; i++) {
Response.Write(string.Format("<p id=\"{0}\">This is paragraph {0}.</p>",i));
}
%>
将此内容写在您的页面上
<%
var array = new string[]{"foo", "bar", "hello", "world"};
Response.ContentType = "text/html";
for(int i = 0; i < array.Length; i++)
{
Response.Write(string.Format("<p id=\"{0}\">This is paragraph {0}.</p>",i));
}
%>
是否将此代码放入面板中?或者它去哪里?