0

我对asp.net 有一点问题。我正在尝试将功能直接编程到 ASP 页面中,但它失败了。

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="WebApplication2.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%
    // My function 
    Sub print()
        Response.Write("example")
    End Sub%>

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

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

这是一个错误:

Línea 242:            
Línea 243:            #End ExternalSource
Línea 244:            Me.__PageInspector_EndRenderTracing(New Object() {__w})
Línea 245:        End Sub
Línea 246:        

任何人都可以帮助我吗?提前致谢!

4

1 回答 1

4

试试这个

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="WebApplication2.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">  
    // My function 
    Sub print()
        Response.Write("example")
    End Sub
</script>  

你错过了用标签包装你的script代码

还要考虑到你没有print在任何地方打电话,所以它不会做任何事情。

于 2013-05-08T20:59:22.017 回答