我修复了ASP.NET检查它 [英] I have fixed ASP.NET check it out

查看:52
本文介绍了我修复了ASP.NET检查它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这将向您展示如何在ASPX页面中实现html渲染方法

和库。


这也意味着超快速调试,因为没有重新初始化<编辑后需要
的IIS!


这可以解决ASPX页面荒谬的情况

不允许有方法。


我正在努力通过课程来实现这一目标!


以下是如何做到这一点:
<你将创建两个ASPX页面:


- FixASP.asp(实际被调用的页面)

- Library.asp (为FixASP.asp提供库方法的页面)


要注意的关键是我们通过关闭ASP.NET来编写ASP.NET编译器

使用大括号隐藏渲染方法,然后我们省略了

我们代码的最后一个结束大括号,因为ASP.NET会将它放入

us!


FixASP.asp的内容:


(开始)

<%

InitLib(__ output,parameterContainer);

PageStart(ASP.NET再次健全!);

PageHeader();

PageMethod();

PageFooter();

PageEnd();

%><! - #Intelude File = " Library.aspx" - ><%

}

void PageMethod(){

%>这是页面方法<%

%>

(完)


Library.asp的内容:

(开始)

<%}

//不要改变这一点

私有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;

}

//便利方法到这里

字符串HTML(字符串数据){

返回HttpUtility.HtmlEncode(数据);

}

字符串URL(字符串数据){

retu HttpUtility.UrlEncode(data);

}

字符串QPX(字符串名称,字符串val){

返回URL(名称)+ ; =" + URL(val)+"&";

}

//在此处添加渲染方法!

void RenderLink(string标题,字符串URL){

%>< a href ="<%= HTML(URL)%>"><%= HTML(标题)%> < / a><%

}

void PageStart(字符串标题){

%><!DOCTYPE HTML PUBLIC" ; - // W3C // DTD HTML 4.0 Transitional // EN" >

< html>

< head>

< title><%= HTML(Title)%>< ; / title>

< / head>

< body><%

}

无效PageHeader(){

%>< h1>这是页眉< / h1>< hr /><%

}

void PageFooter(){

%>< hr />< h1>这是页脚< / h1><%

}

void PageEnd(){

%>< / body>

< / html><%

}

//此后不要更改任何内容

void ButtPlug(){

//这是结束

%>

(结束)


现在将FixASP.asp设置为您的StartPage

并点击F5

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

推荐答案

您应该修改ASP.NET作为ASP的方式,

并解释为什么你在ASP.NET中使用.asp扩展名,

而不是使用.aspx。


Juan T. Llibr e $>
ASP.NET MVP
http:// asp.net.do/foros/

Foros de ASP.NET en Espa?ol

Ven,y hablemos de ASP.NET ...

======================


" John Rivers" <音响***** @ btinternet.com>在消息中写道

news:11 ********************* @ g47g2000cwa.googlegro ups.com ...
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.


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Espa?ol
Ven, y hablemos de ASP.NET...
======================

"John Rivers" <fi*****@btinternet.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
这将向您展示如何在ASPX页面中实现html渲染方法和库。

这也意味着超快的调试,因为在重新启动之后不需要重新初始化IIS。编辑!

这解决了ASPX页面荒谬的情况
不允许有方法。

我正在研究如何通过类来实现这一点好吧!

以下是如何做到这一点:

你将创建两个ASPX页面:

- FixASP.asp(实际得到的页面)调用)
- Library.asp(为FixASP.asp提供库方法的页面)

要注意的关键是我们正在欺骗ASP.NET编译器
使用大括号关闭隐藏的渲染方法,然后我们省略了代码的最后一个右大括号,因为ASP.NET会将它放入
我们这里!

FixASP的内容。 asp:

(s tart)
<%
InitLib(__ output,parameterContainer);
PageStart(ASP.NET再次健全!);
PageHeader();
PageMethod();
PageFooter();
PageEnd();
%><! - #Intelude File =" Library.aspx" - ><%
}
void PageMethod(){
%>这是页面方法<%
%>
(结束)

Library.asp的内容:

(开始)
<%}
//不要改变这一点
私有System.Web.UI.HtmlTextWriter __output;
私有System.Web.UI.Control parameterContainer;
void InitLib(System.Web.UI.HtmlTextWriter o,System.Web.UI.Control pc)
{
__output = o;
parameterContainer = pc;
}
//方便的方法就在这里
字符串HTML(字符串数据){
返回HttpUtility.HtmlEncode(data);
}
字符串URL(字符串数据){
返回HttpUtility.UrlEncode(数据);
}
字符串QPX(字符串名称,字符串val){
返回网址(名称)+" =" ; + URL(val)+"&";
}
//在此处添加渲染方法!
void RenderLink(字符串标题,字符串URL){
%> ;< a href ="<%= HTML(URL)%>"><%= HTML(标题)%>< / a><%
} void PageStart(string Title){
%><!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.0 Transitional // EN" >
< html>
< head>
< title><%= HTML(标题)%>< / title>
< / head> ;
< body><%
}
void PageHeader(){
%>< h1>这是页眉< / h1>< hr / ><%
}
void PageFooter(){
%>< hr />< h1>这是页脚< / h1><%
}
void PageEnd(){
%>< / body>
< / html><%
}
// @ Don''在此之后改变任何东西
void ButtPlug()//这是结束
%>
(结束)
现在设置FixASP。 asp作为你的StartPage
并点击F5
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



嗨John,
Hi John,
这告诉你如何在ASPX页面中实现html渲染方法和库。

这也意味着超快的调试,因为编辑后不需要重新初始化IIS!
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.




我会申请asp.net团队的工作。我认为这些家伙真的可以使用你的b $ b $


当然aspx文件可以有方法:


<%@ Page Language =" VB" %>


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


< script runat =" server">


子输出()

Response.Write(嗨约翰。我是方法,真的)

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>

<%输出()%>

< / div>

< / form>

< / body>

< / html>


干杯,

Tom Pester



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




i意味着带有代码块的方法


你知道吗


你们这些人还是太笨了而无法获得它


微软的某个人坐下来


并且决定没有使用codeblocks的方法


为什么?


它是可能的 - 我只是这样做了


它简化了我的asp.net评估项目

显着


例如,你会怎么做?


void RenderMenuItem(字符串标题,字符串链接){

%>< tr>

< td style =" background-image:url(Images / MenuItem.gif)"

height =" 22">& nbsp;& nbsp;< img

src = QUOT;图像/ ArrowGre y.gif" / &&;& nbsp;& nbsp;< b>< a

href ="<%= HTML(Link)%>">< ;%= HTML(标题)%>< / a>< / b>< / td>

< / td>

< / tr> ;<%

}


这么简单的事情


但你怎么会在.net中这样做?


response.write是荒谬的 - 这是一大块html,其中有颜色

编码和完成,更不用说从html页面复制和粘贴等。


用户控件很荒谬 - 如果我想要12个菜单项生成

动态怎么办?


自定义控件也是荒谬的


你能不能看到CORRECT方法是经典ASP的方法吗?


这种情况​​非常奇怪怀疑?


tom pester写道:

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?


tom pester wrote:
嗨约翰,
Hi John,
这告诉你如何实现html渲染方法和libra在ASPX页面中回答。

这也意味着超级快速的调试,因为编辑后不需要重新初始化IIS!

ASPX页面的荒谬情况不允许有方法。
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.



我会申请asp.net团队的工作。我认为这些人真的可以使用你了。

当然aspx文件可以有方法:

<%@ Page Language =" VB" %>

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

< script runat =" server">
子输出()
Response.Write(嗨约翰。我是方法,真的)
结束子

< / 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>

干杯,
Tom Pester



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





这篇关于我修复了ASP.NET检查它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆