全局子程序 [英] Global subroutines

查看:63
本文介绍了全局子程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨汤姆!


对于凌乱的引用感到抱歉,谷歌在

时刻对我耍花招。

Global.asax是您通常拥有全局应用程序和会话变量以及操作它们的代码的地方。它开始
并以< script>< / script>结尾标签。

你看起来像是它的编译版本。

它就像任何ASP.net页面一样。如果你使用代码内部,你用脚本标签包围代码。要将代码转换为代码隐藏文件,可以将代码移动到新文件中,并将
从脚本标记中删除。


我从未想过这样。我不是说你错了,要说实话我不确定,但是:

1)我搜索过你好并且找不到任何类似脚本的东西

标签在Global.asax。

2)必须有一个全局共享(静态)类,因为那个'这是变量被保存的


3)在VS中,与普通的aspx页面相反,你无法访问

Global.asax的HTML代码(通常,一个aspx组合有三个不同的

视图:html视图和设计视图,它们是

同一个窗口上的两个标签,以及位于另一个窗口的代码隐藏文件。

Global.asax中没有设计或html选项卡。

4)据我所知,aspx代表Active Server Page eXtended(?),

asax代表Active Server Application eXtended(?)。它应该是一个应用程序,而不是一个页面。

。例如,您不能在Global.asax上删除一个

html表,但请注意,您可以删除Windows窗体

控件!!


所以,我确实认为它不是一个aspx而是一个合适的应用程序,包含在一个

类中,而不是包含在脚本块中。再说一遍,我可能是错的。我希望有一个大师可以帮助我们。

要上课,我想你需要编译文件,就像你说的那样
你会必须在我的所有页面上都有代码隐藏/继承。我正试图解决这个问题。


无论如何你绝对需要编译文件。编译它

在bin目录中创建一个dll,没有它就没有aspx页面可以提供
(但是普通的html可以,但是那个'

场景)。你不必在任何页面上继承它,因为

结构如下:


Global.asax继承自System.Web。 HttpApplication类,并且在命名为项目命名空间的内部是
。由于它是共享的,

它可以在该命名空间内的任何其他对象中使用,因此

该命名空间内的任何页面都可以简单地通过<引用Global.asax br />
例如,使用Global.SomeMethod和Global.SomeMethod。 (如果该方法显然是公开的,那么。

页面继承自System.Web.Ui类。他们不需要从应用程序本身继承

(阅读:他们不是)。

每个页面都有一个相关的代码隐藏文件, aspx文件

继承自代码隐藏文件中的类。使用VS,

所有这些都完全透明,并由

框架照顾。

另一个问题是 - 我将如何处理2个代码隐藏文件。每个
aspx页面都有自己的代码,然后你就拥有了全局的代码。你将如何在ASP页面中设置它(你需要2个继承和2个代码隐藏语句)。


你没有。同样,我认为你的误解来自于你认为应用程序未编译的事实。

。可以这样想:应用程序

包含许多类,一些是页面,一些是代码隐藏文件,

,一个是Global对象。所有这些类都可以(理论上)

互相交谈,这就是为什么,为了回到你的

问题的开头,你可以包含共享方法全局类并使用

来自其他类(代码隐藏文件)。

昨晚我按照你的建议做了,只需等待CD 。




嗯,这对你来说是个好消息,因为我很肯定它会全部变成b $ b很快就清楚了,我也很确定你会给b $ b bb带来巨大的乐趣。 VS是我梦寐以求的最好玩具,速度快,价格高,智能,连贯,并且具有最令人印象深刻的优化。在一个半月的时间里,我已经开发了一个程序,这个程序过去花费了大约五年前的
100.000美元。我绝对没有联系等等,

很明显。


所以,玩得开心吧!


Michel

解决方案

五年前。我绝对没有联系等等,

很明显。


所以,玩得开心吧!


Michel


" fd123456" < FD ****** @ hotmail.com>在消息中写道

news:c8 ************************** @ posting.google.c om ...

嗨汤姆!

对于凌乱的引用感到抱歉,谷歌在
时刻对我耍花招。

Global.asax是您通常拥有全局应用程序和会话变量以及操作它们的代码的地方。它开始
并以< script>< / script>结尾标签。

你看起来像是它的编译版本。

它就像任何ASP.net页面一样。如果你使用代码内部,你用脚本标签包围代码。要将代码转换为代码隐藏文件,您可以将代码移动到新文件中并将
从脚本标记中删除。
我从未想过这样。我不是说你错了,说实话我不确定,但是:
1)我已经搜索过你好,我找不到Global.asax中类似于脚本
标签的任何内容。
2)必须有一个全局共享(静态)类,因为它是保存变量的地方。
3)在VS中,与普通的aspx页面相反,你无法访问Global.asax的HTML代码(通常,aspx组合有三种不同的视图:html视图和设计视图,它是同一窗口上的两个选项卡,以及位于另一个窗口中的代码隐藏文件。
Global.asax中没有设计或html选项卡。
4据我所知,aspx代表Active Server Page eXtended(?),
asax代表Active Server Application eXtended(?)。它应该是一个应用程序,而不是一个页面。例如,你不能在Global.asax上删除一个
html表,但是请注意,你可以放下Windows Forms
控件!!

所以,我相信它不是一个aspx,而是一个适当的应用程序,包含在一个
类中,而不是封装在一个脚本块中。再说一遍,我可能是错的。我希望有一位大师帮助我们。




你可能是对的。


我知道全球.asax有脚本标签(只是因为那是我之前用过的

示例程序设置的方式)。在我的书中,

,例如ASP.net:提示,教程和代码。 - 它用脚本显示它

标签。


也许没关系。也许.net就把它丢掉了。我假设如果

你没有脚本标签,而我在我的网站上没有,那就不是问题了

..net。

要创建一个类,我认为您需要编译该文件,正如您所说的那样,您必须在我的所有页面上都有代码隐藏/继承。我试图解决这个问题。
无论如何你绝对需要编译文件。编译它
在bin目录中创建一个dll,没有它就不能提供aspx页面(虽然普通html可以,但是那个'IIS在
场景下工作)。您不必在任何页面上继承它,因为
结构如下:

Global.asax继承自System.Web.HttpApplication类并且是
在命名空间后面的项目名称。由于它是共享的,
它可以在该命名空间内的任何其他对象中使用,因此该命名空间内的任何页面都可以简单地通过
使用,例如,使用Global.asax " Global.SomeMethod" (如果该方法是公开的,很明显)。
页面继承自System.Web.Ui类。他们不需要从应用程序本身继承
(阅读:他们不是)。
每个页面都有一个相关的代码隐藏文件,而aspx文件继承自代码隐藏文件中的类。使用VS,
所有这些都是完全透明的,并由
框架照顾你。




所以,如果我编译它,我会结束吗使用Global.dll?


如果有常规代码,我会像这样编译它:


vbc / t:库的东西。 vb


这会给我一些东西。


我会编译Global.asax之类的东西:


vbc / t:library Global.asax


获取Global.dll


或者我需要命名它Global.asax.vb并且执行:


vbc / t:库Global.dll

其他问题是 - 我将如何处理2个代码隐藏文件。每个
aspx页面都有自己的代码,然后你就拥有了全局的代码。你将如何在ASP页面中设置它(你需要2个继承和2个代码隐藏语句)。



你不是。同样,我认为您的误解来自于您认为应用程序未编译的事实。可以这样想:应用程序
包含许多类,一些是页面,一些是代码隐藏文件,
和一个是Global对象。所有这些类都可以(理论上)相互交谈,这就是为什么,回到你的问题的开头,你可以在Global类中包含共享方法并使用
来自其他类的代码(代码隐藏文件)。

我昨晚按照你的建议做了,只需要等待
CD。


嗯,这对你来说是个好消息,因为我很肯定它会很快变得清晰,而且我也很确定你将获得巨大的乐趣。 VS是我梦寐以求的最好的玩具,它速度快,深度,智能,连贯,并且具有最令人印象深刻的优化。在一个半月的时间里,我已经开发了一个程序,这个程序过去花费了五年之前的成本。


。我绝对没有任何关联,等等。
很明显。




应该很快就会到来。


谢谢,


Tom So,玩得开心!

Michel



Hi Tom !

Sorry about the messy quoting, Google is playing tricks on me at the
moment.

Global.asax is where you normally have the Global Application
and Session variables and code to manipulate them. It starts
and ends with <script></script> tags.

Yours looks like a compiled version of it.

It is just like any ASP.net page. If you use code-inside, you
surround the code with the script tags. To make the code into
a code-behind file, you move the code to a new file and leave
out the script tags.
I had never thought of it that way. I''m not saying you''re wrong, to be
honest I''m not at all sure, but :
1) I''ve searched hi and lo and can''t find anything resembling script
tags in Global.asax.
2) There has to be a Global shared (static) class, because that''s
where the variables are held.
3) In VS, contrarily to plain aspx pages, you don''t have access to
HTML code for Global.asax (usually, an aspx combo has three different
views : the html view and the design view, which are two tabs on the
same window, and the code-behind file which sits in another window.
There''s no design or html tab in Global.asax.
4) As far as I know, aspx stands for Active Server Page eXtended(?),
asax stands for Active Server Application eXtended(?). It''s supposed
to be an app, not an page as such. You cannot, for instance, drop a
html table on Global.asax, but mind you, you can drop Windows Forms
controls on it !!

So, I do believe it''s not an aspx but a proper app, contained in a
class, and not enclosed in a script block. Again, I could be wrong. I
wish some guru would help us there.
To have a class, I think you would need to compile the file, as you said
and you would have to have the codebehind/inherits on all my pages. I am
trying to get around this.
You definitely need to compile the file in any case. Compiling it
creates a dll in a bin directory, without which no aspx page can be
served (plain html can, though, but that''s IIS working under the
scene). You don''t have to inherit it on any page, because the
structure is as follows :

Global.asax inherits from the System.Web.HttpApplication class and is
inside the namespace that''s named after your project. As it is shared,
it can be used from any other object that is inside that namespace, so
any page inside that namespace can refer to Global.asax simply by
using, for instance, "Global.SomeMethod" (provided that method is
public, obviously).
Pages inherit from System.Web.Ui class. They don''t need to inherit
from the application itself (read : they musn''t).
Each page has an associated code-behind file, and the aspx file
inherits from the class that lies in the code-behind file. With VS,
all this is totally transparent and taken care for you by the
Framework.
The other problem is - how would I handle 2 codebehind files. Each
aspx page would have it''s own code behind and then you have the
Global one. How would you set that up in your ASP pages (you would
need 2 inherits and 2 codebehind statements).
You don''t. Again, I think your misconception comes from the fact that
you think the app is not compiled. Think of it this way : the app
contains many classes, some being pages, some being code-behind files,
and one being the Global object. All these classes can (theoretically)
talk to each other, and that''s why, to return to the beginning of your
question, you can include shared methods in the Global class and use
them from other classes (code-behind files).
I did that last night, as you suggested, and just have to wait for the CD.



Well, that''s very good news for you, because I''m positive that it''ll
all become clear very quickly, and I''m also quite sure that you''ll
have tremendous fun. VS is the best toy I ever dreamed of, it''s fast,
deep, smart, coherent and has the most impressive optimisations. In a
month and a half, I''ve developped a program that used to cost around
100.000 $ five years ago. I''m in no way affiliated blah blah,
obviously.

So, have fun with it !

Michel

解决方案

five years ago. I''m in no way affiliated blah blah,
obviously.

So, have fun with it !

Michel


"fd123456" <fd******@hotmail.com> wrote in message
news:c8**************************@posting.google.c om...

Hi Tom !

Sorry about the messy quoting, Google is playing tricks on me at the
moment.

Global.asax is where you normally have the Global Application
and Session variables and code to manipulate them. It starts
and ends with <script></script> tags.

Yours looks like a compiled version of it.

It is just like any ASP.net page. If you use code-inside, you
surround the code with the script tags. To make the code into
a code-behind file, you move the code to a new file and leave
out the script tags.
I had never thought of it that way. I''m not saying you''re wrong, to be
honest I''m not at all sure, but :
1) I''ve searched hi and lo and can''t find anything resembling script
tags in Global.asax.
2) There has to be a Global shared (static) class, because that''s
where the variables are held.
3) In VS, contrarily to plain aspx pages, you don''t have access to
HTML code for Global.asax (usually, an aspx combo has three different
views : the html view and the design view, which are two tabs on the
same window, and the code-behind file which sits in another window.
There''s no design or html tab in Global.asax.
4) As far as I know, aspx stands for Active Server Page eXtended(?),
asax stands for Active Server Application eXtended(?). It''s supposed
to be an app, not an page as such. You cannot, for instance, drop a
html table on Global.asax, but mind you, you can drop Windows Forms
controls on it !!

So, I do believe it''s not an aspx but a proper app, contained in a
class, and not enclosed in a script block. Again, I could be wrong. I
wish some guru would help us there.



You may be correct.

I know the Global.asax has script tags (only because that was the way the
example program I used a while ago had it set up). In the books I have,
such as "ASP.net: Tips, Tutorials and Code" - it shows it with the script
tags.

Maybe it doesn''t matter. Maybe .net just throws it away. I assume that if
you don''t have script tags in yours and I do in mine, it isn''t an issue with
..net.

To have a class, I think you would need to compile the file, as you said
and you would have to have the codebehind/inherits on all my pages. I am
trying to get around this.
You definitely need to compile the file in any case. Compiling it
creates a dll in a bin directory, without which no aspx page can be
served (plain html can, though, but that''s IIS working under the
scene). You don''t have to inherit it on any page, because the
structure is as follows :

Global.asax inherits from the System.Web.HttpApplication class and is
inside the namespace that''s named after your project. As it is shared,
it can be used from any other object that is inside that namespace, so
any page inside that namespace can refer to Global.asax simply by
using, for instance, "Global.SomeMethod" (provided that method is
public, obviously).
Pages inherit from System.Web.Ui class. They don''t need to inherit
from the application itself (read : they musn''t).
Each page has an associated code-behind file, and the aspx file
inherits from the class that lies in the code-behind file. With VS,
all this is totally transparent and taken care for you by the
Framework.



So if I compile it, would I end up with Global.dll?

With a regular code behind, I would compile it like so:

vbc /t:library something.vb

This would give me something.dll.

Would I compile the Global.asax something like:

vbc /t:library Global.asax

To get get Global.dll

Or would I need to name it Global.asax.vb and do:

vbc /t:library Global.dll

The other problem is - how would I handle 2 codebehind files. Each
aspx page would have it''s own code behind and then you have the
Global one. How would you set that up in your ASP pages (you would
need 2 inherits and 2 codebehind statements).



You don''t. Again, I think your misconception comes from the fact that
you think the app is not compiled. Think of it this way : the app
contains many classes, some being pages, some being code-behind files,
and one being the Global object. All these classes can (theoretically)
talk to each other, and that''s why, to return to the beginning of your
question, you can include shared methods in the Global class and use
them from other classes (code-behind files).

I did that last night, as you suggested, and just have to wait for the
CD.



Well, that''s very good news for you, because I''m positive that it''ll
all become clear very quickly, and I''m also quite sure that you''ll
have tremendous fun. VS is the best toy I ever dreamed of, it''s fast,
deep, smart, coherent and has the most impressive optimisations. In a
month and a half, I''ve developped a program that used to cost around
100.000


five years ago. I''m in no way affiliated blah blah,
obviously.



Should be here soon.

Thanks,

Tom So, have fun with it !

Michel



这篇关于全局子程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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