For Programmers: Free Programming Magazines  


Home > Archive > ASP > August 2005 > TRICK: ASP.NET methods with code blocks









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author TRICK: ASP.NET methods with code blocks
TEN TOD PSA

2005-08-18, 5:55 pm

Xref: TK2MSFTNGP08.phx.gbl microsoft.public.inetserver.asp.general:297162

you can trick ASP.NET into letting you declare methods with code blocks
(how anybody can survive without this i have no idea - in classic asp i
haven't written any html outside of a sub/method in 8 years - ASP.NET seems
to be going backwards in some respects)
(seems to me using Classic ASP but accessing the juicy .NET framework
features via COM Interop is a better choice than actually using ASP.NET)

in your aspx page do this:

(start)
<%
}
void RenderHTML(System.Web.UI.HtmlTextWriter __output) {
%><%="what ever you want"%><%
(end)

explanation follows:

(inside a code block)
<%
(close the render method with a brace)
}
(declare a new method which takes the hidden output object)
void RenderHTML(System.Web.UI.HtmlTextWriter __output) {
(use a codeblock inside the method)
%><%="what ever you want"%><%
(omit the closing brace - asp will put it in for you thinking it is closing
the render method)
(end)

you can call your new method as follows:

RenderHTML(__output);






Bob Barrows [MVP]

2005-08-19, 4:12 pm

TEN TOD PSA wrote:
> you can trick ASP.NET


There was no way for you to know it, but this is a classic asp newsgroup.
While you may be lucky enough to find a dotnet-knowledgeable person here who
can answer your question, you can eliminate the luck factor by posting your
question to a group where those dotnet-knowledgeable people hang out. I
suggest microsoft.public.dotnet.framework.aspnet.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com