3

我想在 ASP.net 上使用 C# 脚本语言。而且我还想通过使用 document.write 来操作我的 html 页面,但我在 C# 中找不到该选项。我还将我的代码直接编辑为 html 代码,而不是 .aspx.cs 文件。那么在c#中是否有任何与document.write相同的功能?

4

2 回答 2

3

试试这个

<%@ Page Title="Sample" Language="C#"  %>
<%
    var str = "hi!";
    Response.Write(str);

    Response.Write("hi");
%>
于 2013-03-05T03:45:49.313 回答
3

看看这个: http: //msdn.microsoft.com/en-in/library/ms178135 (v=vs.100).aspx

它讨论了可以在页面渲染阶段执行的嵌入式代码块。

从上面的网址:

<%@ Page Language="C#" %>
<html>
<body>
    <form id="form1" runat="server">
    <% for(int i = 0; i < 6; i++) %>
       <% { Response.Write("<br>" + i.ToString()); }%>
    </form>
</body>
</html>
于 2013-03-05T03:54:30.083 回答