[thelist] vb.net: using subroutines within user controls - .ascx
Casey Crookston
casey at thecrookstons.com
Mon Oct 11 16:56:51 CDT 2004
> -----Original Message-----
> Is it possible to use subroutines from within a user control? If so, what
> is the syntax for declaring the sub?
------- David Said-----------
> In the code-behind file (the XXX.ascx.vb file) you can declare any sub you
> wish using the following syntax:
>
> Public Sub SubName()
> 'sub logic
> End Sub
Thanks David. Okay, so:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<% Public sub header()
response.write("a bunch of html")
end sub %>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Like that?
When I do that, I an error on this line: <% Public sub header()
Compiler Error Message: BC30289: Statement cannot appear within a method
body. End of method assumed.
Or is it like this:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<script runat="server">
Public sub header()
response.write("a bunch of html")
end sub
</script>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When I try that, then the page which calls the user control bombs out.
Line 26: <aspfd:header runat="server"/>
BC30188: Declaration expected.
?????
More information about the thelist
mailing list