Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ASP.NET c#打印出html内容_C#_Php_Html_Asp.net - Fatal编程技术网

ASP.NET c#打印出html内容

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>"; } ?>

我正在为一个大学项目学习.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>"; 

    }
?>

这是我试图实现和理解的一个简单例子。如何在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)); 
  }
  %>

是否将此代码放入面板中?或者它去哪里?