×

Loading...
Ad by
  • 予人玫瑰,手有余香:加拿大新天地工作移民诚聘求职顾问&行业导师!
Ad by
  • 予人玫瑰,手有余香:加拿大新天地工作移民诚聘求职顾问&行业导师!

方法2

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Label1.Text = "Key Issue"
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

</div>
</form>
</body>
</html>
Report

Replies, comments and Discussions:

  • 工作学习 / 学科技术讨论 / 一个ASP的入门问题
    我想在html中插入一段C#返回的html code。html如下:
    <td>
    <% Response.Write("<asp:Label ID=\"lKeyIssue\" runat=\"server\" Text=\"Key Issue\"></asp:Label>");
    <td>
    但上面的Label不能显示出来。如果是一个Response.Write("Hello World");则可以正常显示。不知道到底是用反斜线escape双引号错了还是别的什么。请指点。谢先。
    • 你插的是asp.net的代码,这是server端的代码,换成响应html的代码就行了。
      • 请稍讲详细一点。谢。
        • 天下所有的浏览器(IE,Netscape,FireFox等)只认html+javascript,服务器(server)的asp.net/Java/PHP等只不过提供快速生成html+javascript的手段。
          简言之,浏览器不认识
          <% Response.Write("<asp:Label ID='lKeyIssue' runat='server' Text='Key Issue'></asp:Label>")%>

          只认识<% Response.Write("<span id='lKeyIssue'>Key Issue</span>")%>
        • 方法一:<asp:Label ID='lKeyIssue' runat='server' > <% Response.Write("Key Issue")%></asp:Label>
          • 方法2
            <%@ Page Language="VB" %>

            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

            <script runat="server">

            Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
            Label1.Text = "Key Issue"
            End Sub
            </script>

            <html xmlns="http://www.w3.org/1999/xhtml">
            <head runat="server">
            <title></title>
            </head>
            <body>
            <form id="form1" runat="server">
            <div>
            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

            </div>
            </form>
            </body>
            </html>
            • 我需要的是在一个静态的html里插入一段asp.net动态产生的html code。比如说一个dropdown list,是在server上产生然后render的。是不是不应该用Response.Write。
              • 绝大部分时候是不需要你操劳Response.Write的。比如DropDownList,有两个方法,一个是用DropDownList.Items Property,另一个是用数据绑定(DropDownList.DataSource Property;DropDownList.DataMember Property;DropDownList.DataBind Method等)。慢慢练吧。
                • 搞好了。挺简单的。用了数据绑定。多谢指点!