How to call a Function in ASP.NET

I have the following 1.aspx page


<%@ Page Language="VB" %>
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY>
<%=stl%>
</BODY>
</HTML>
<%
public function stl() As String
	return "Hello Word"
end function
%>

When I run this page, I get the following error:


Compiler Error Message: BC30289: This statement cannot appear within a method body. The compiler will assume an intent to terminate the method body.

Source Error:



Line 9:  </HTML>
Line 10: <%
Line 11: public function stl() As String
Line 12: 	return "Hello Word"
Line 13: end function

Source File: C:\\WebServers\\Gazeta\\1.aspx    Line: 11

Where am I wrong?
Thank you

Try this:


<%@ Page Language="VB" %>
<script language="VB" runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
   printStr = "Hello world"
   showStr.text = printStr
end sub
</script>
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY>
<asp:label id="showStr" runat=server/>
</BODY>
</HTML>

:slight_smile:

Thank you, dhtmlgod !!!

No problem

:slight_smile: