I have fixed ASP.NET check it out

J

John Rivers

This shows you how to implement html rendering methods
and libraries in ASPX pages.

This also means super fast debugging as no re-initialising
of IIS is required after editting!

This gets around the ridiculous situation of ASPX pages
not being allowed to have methods.

I am working on a way to do this with classes as well!

Here is how to do it:

you will create two ASPX pages:

- FixASP.asp (the page that actually gets called)
- Library.asp (the page that provides library methods to FixASP.asp)

the key thing to note is that we are tricking the ASP.NET compiler
by closing the hidden render method with a brace, then we omit
the last closing brace of our code because ASP.NET will put it in for
us!

Contents of FixASP.asp:

(start)
<%
InitLib(__output, parameterContainer);
PageStart("ASP.NET is sane again!");
PageHeader();
PageMethod();
PageFooter();
PageEnd();
%><!--#Include File="Library.aspx"--><%
}
void PageMethod() {
%>this is the page method<%
%>
(end)

Contents of Library.asp:

(start)
<%}
//Don't change this bit
private System.Web.UI.HtmlTextWriter __output;
private System.Web.UI.Control parameterContainer;
void InitLib(System.Web.UI.HtmlTextWriter o, System.Web.UI.Control pc)
{
__output = o;
parameterContainer = pc;
}
//Convenience methods go here
string HTML(string data) {
return HttpUtility.HtmlEncode(data);
}
string URL(string data) {
return HttpUtility.UrlEncode(data);
}
string QPX(string name, string val) {
return URL(name) + "=" + URL(val) + "&";
}
//Add your rendering methods here!
void RenderLink(string Title, string URL) {
%><a href="<%=HTML(URL)%>"><%=HTML(Title)%></a><%
}
void PageStart(string Title) {
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title><%=HTML(Title)%></title>
</head>
<body><%
}
void PageHeader() {
%><h1>This is the page header</h1><hr/><%
}
void PageFooter() {
%><hr/><h1>This is the page footer</h1><%
}
void PageEnd() {
%></body>
</html><%
}
//Don't change anything after this
void ButtPlug() {
//this is the end
%>
(end)

now set FixASP.asp as your StartPage
and hit F5
 
T

tom pester

Hi John,
This shows you how to implement html rendering methods and libraries
in ASPX pages.

This also means super fast debugging as no re-initialising of IIS is
required after editting!

This gets around the ridiculous situation of ASPX pages not being
allowed to have methods.

I would apply for a job with the asp.net team. I think these guys realy could
use you :)

Of course aspx files can have methods :

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<script runat="server">

Sub Output()
Response.Write("Hi John. I'm a method, really")
End Sub

</script>

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



Cheers,
Tom Pester
 
J

Juan T. Llibre

You should fix the way you refer to ASP.NET as ASP,
and explain why you use the .asp extension, in ASP.NET,
instead of using .aspx.
 
J

John Rivers

i meant methods with codeblocks

as you well know

you guys are still too dumb to get it

somebody at microsoft sat down

and decided no methods with codeblocks

why?

it is possible - i just did it

and it has simplified my asp.net evaluation project
significantly

for example, how would you do this?

void RenderMenuItem(string Title, string Link) {
%><tr>
<td style="background-image:url(Images/MenuItem.gif)"
height="22">&nbsp;&nbsp;<img
src="Images/ArrowGrey.gif"/>&nbsp;&nbsp;<b><a
href="<%=HTML(Link)%>"><%=HTML(Title)%></a></b></td>
</td>
</tr><%
}

such a simple thing

yet how would you do this in .net?

response.write is ridiculous - this is a chunk of html, where is color
coding and completion, let alone copy and paste from html page etc.

user controls are ridiculous - what if i wanted 12 menu items generated
dynamically?

custom controls are also ridiculous

can you not see that the CORRECT approach is the one from Classic ASP?

and that this situation is extremely strange and suspect?
 
J

John Rivers

why would you reply about a typo

and not reply constructively to the point in hand?

what are you a human spell checker?

hit F7 and Juan will come and check your stuff ...

like a spell checker he won't understand the words and sentences ...

ha ha ha
 
K

Kevin Spencer

1. You cannot fix something you don't understand. How could you fix, for
example, a watch, if you didn't know how it works?
2. An ASP.Net Page is a class. All classes can have methods.
3. Making ASP.Net procedural is a step backwards not a step forwards.
4. ASP.Net was developed over more than 6 years by architects, designers,
and programmers who make most of us look like amateurs. What you have done
is the equivalent of what Mr. Bean did to the Mona Lisa.
5. If you don't want to learn, stick to ASP.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Paranoia is just a state of mind.
 
S

Sparky Arbuckle

What you have done is the equivalent of what Mr. Bean did to the Mona Lisa.

'Winslow's Mother' was the actual name of the painting. Still the
funniest reply I have yet to read on this newsgroup.
 
J

Juan T. Llibre

A typo is something that happens once.

Careless posting happens when you include
several typos in the same post, as it did in your post.

Or, maybe, you're so fixated on ASP, that you
-mindlessly- write asp when you mean to write aspx.

In any case, I won't waste any more time on your posts.

<plonk>






why would you reply about a typo
and not reply constructively to the point in hand?

what are you a human spell checker?
hit F7 and Juan will come and check your stuff ...

like a spell checker he won't understand the words and sentences ...
ha ha ha
 
T

tom pester

coding horror :
void RenderMenuItem(string Title, string Link) {
%><tr>
<td style="background-image:url(Images/MenuItem.gif)"
height="22">&nbsp;&nbsp;<img
src="Images/ArrowGrey.gif"/>&nbsp;&nbsp;<b><a
href="<%=HTML(Link)%>"><%=HTML(Title)%></a></b></td>
</td>
</tr><%
}

much better :

str &= "<tr><td class=c1>"
str &= "<img src=""Images/ArrowGrey.gif"" />"
str &= String.Format("<a class=c2 href=""{0}"">{0}</a>", Link)
str &= "</td></tr>"

Make a user control if you want HTML designer support. ASP.NET doesnt suppor
render functions, get over it?
i meant methods with codeblocks

You mean rendering functions I suppose.

After reading some of your comments in the other posts I see that you don't
understand asp.net yet. So don't expect any serious responses after you do.

Cheers,
Tom Pester
 
S

Sparky Arbuckle

I think the fact that this guy submitted a topic about fixing a
framework with 1000's of classes has something to say about his common
sense, or lack thereof.

I think his next move is to try and teach Stephen Hawkins a thing or
two about Astrophysics.
 
M

Mark Rae

After reading some of your comments in the other posts I see that you
don't understand asp.net yet. So don't expect any serious responses after
you do.

If that ever happens...
 
P

Patrick.O.Ige

hahahahhaa Kevin this one of the funniest thing i read today..
Thanks for that.
And Juan lets not waste time with such people in this forum:(
Patrick
 
L

Lucas Tam

for example, how would you do this?

void RenderMenuItem(string Title, string Link) {
%><tr>
<td style="background-image:url(Images/MenuItem.gif)"
height="22">&nbsp;&nbsp;<img
src="Images/ArrowGrey.gif"/>&nbsp;&nbsp;<b><a
href="<%=HTML(Link)%>"><%=HTML(Title)%></a></b></td>
</td>
</tr><%
}

I wouldn't... what a bunch of gobbly goop. If you want this style of
coding, I suggest you stick with ASP, PHP or Perl.
 
K

Kevin Spencer

'Winslow's Mother' was the actual name of the painting.

Darned if you aren't right! I'll have to watch it again!

--
;-),

Kevin Spencer
Microsoft MVP
..Net Developer
Paranoia is just a state of mind.
 
K

Kevin Spencer

It was Whistler's Mother when I saw it...

Gosh! I was wrong again, saying that Sparky was right! That makes me wrong
twice! In a row!

Time to drink some coffee, I suppose...

--
;-),

Kevin Spencer
Microsoft MVP
..Net Developer
Paranoia is just a state of mind.
 
G

Guest

Howdy,

John, I've just had a look on two topics created by you (this and about
debugging). Just go back your lovely VB and ASP technologies and stop making
annoying posts :)
ASP.NET is object oriented platform with quite nice background, designed to
make web programming faster and what is more important – to put some order in
big projects. I’ve seen some many messy ASP and VB applications written in
the same way you showed above. My advice John is to start understanding the
idea of new technologies and to stop complaining about everything what’s
different you got used to or you don’t understand.

Regards

Milosz Skalecki
MCP, MCAD
 
J

Joerg Jooss

John said:
i meant methods with codeblocks

as you well know

you guys are still too dumb to get it

somebody at microsoft sat down

and decided no methods with codeblocks

why?

it is possible - i just did it

and it has simplified my asp.net evaluation project
significantly

for example, how would you do this?

void RenderMenuItem(string Title, string Link) {
%><tr>
<td style="background-image:url(Images/MenuItem.gif)"
height="22">&nbsp;&nbsp;<img
src="Images/ArrowGrey.gif"/>&nbsp;&nbsp;<b><a
href="<%=HTML(Link)%>"><%=HTML(Title)%></a></b></td>
</td>
</tr><%
}

such a simple thing

yet how would you do this in .net?

Not at all (see Web Controls).

But if you seem to miss JSP programming as practiced in the year 2000,
go ahead.

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top