SamYan
SamYan

Reputation: 1571

Functions fail in asp page

i have a little problem with asp.net. I'm trying to program functions directly into the ASP page but it fails.

<%@ 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>

And this is a error:

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:        

Any one can help me please? Thanks in advance!

Upvotes: 0

Views: 839

Answers (1)

Claudio Redi
Claudio Redi

Reputation: 68400

Try with this

<%@ 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>  

You missed to wrap your code with a script tag

Take also into account that you're not calling print anywhere so it won't do anything.

Upvotes: 4

Related Questions