&QUOT包括(including)QUOT;所有.aspx页面的全局 [英] "including" a global for all .aspx pages

查看:91
本文介绍了&QUOT包括(including)QUOT;所有.aspx页面的全局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一些方法可以创建一个文件(.cs),其中包含一些常见的C#代码

类正在我的网页上的每个.aspx页面上加载,而我不需要

每次都声明它吗?

配置文件中的某些东西也许?


因为我有这些将在每个页面上使用的类,我希望它们能够

就像是云悬停在我的网络上用户正在浏览的任何页面...

is there some way to make a file (.cs) containing some common C# code
classes being loaded on every .aspx page in my web without me having to
declare it every time?
Something in the config file perhaps?

since I have these classes that will be used on every page, I want them to
be like a "cloud hovering over my web" whatever page the user is browsing...

推荐答案

作为示例我想要一个代码,将内容添加到< head>控制

而不必在我的.aspx页面中考虑它...
as an example I want to have a code which adds stuff to the <head> control
without having to think about it in my .aspx pages...


大卫你好,


不确定我理解你的问题...


正在加载的课程(...),我不必每次都申报

;

- 您可以使用公共共享你的程序集中的方法。

你不需要实例化,但可以简单地称它们为

(无状态)。


"作为一个例子,我希望有一个代码可以添加东西到/ b $ b< head>控制

而不必在我的.aspx页面中考虑它......"

- 查看这篇文章
http://www.devtrain.de/artikel_774.aspx (对不起它是德国人

语言,但代码示例似乎是可以理解的 -

,如果不只是告诉我)


如果你真的不想触摸aspx页面并希望

你的动态内容...

- 也许检查httphandlers或httpmodules(从未尝试过

这个我自己......)


msdn关于httphandlers的部分:
http://msdn.microsoft.com/library/default.asp?

url = / library / en-us / cpguide / html / cpconhttphandlers.asp )


msdn-mag关于httpmodules的文章:
http://msdn.microsoft.com/msdnmag/is...05/asp/default

aspx

希望这会有所帮助!


问候,


Tom
Hello David,

not sure I understand your problem...

"classes being loaded(...)without me having to declare it
every time"
- you could use public "shared" methods in your assembly.
you do not need to instantiate but can simply call them
(stateless).

"as an example I want to have a code which adds stuff to
the <head> control
without having to think about it in my .aspx pages..."
- check this article
http://www.devtrain.de/artikel_774.aspx (sorry it`s german
language, but the code examples seem to be understandable -
if not just tell me)

if you really do not want to touch the aspx pages and want
your "dynamic" content...
- maybe check httphandlers or httpmodules (never tried
this on my own...)

msdn section on httphandlers:
http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/cpguide/html/cpconhttphandlers.asp )

msdn-mag article on httpmodules:
http://msdn.microsoft.com/msdnmag/is...05/asp/default.
aspx
Hope this helps!

Regards,

Tom
- ---原始消息-----
是否有一些方法可以在我的web
中的每个.aspx页面上创建一个包含一些
常见C#代码类的文件(.cs)我每次都要声明它吗?
配置文件中的某些东西也许?

因为我有这些将在每个
页面上使用的类,我希望它们像一个 ;云悬停在我的网络上
用户正在浏览的任何页面...

-----Original Message-----
is there some way to make a file (.cs) containing some common C# codeclasses being loaded on every .aspx page in my web without me having todeclare it every time?
Something in the config file perhaps?

since I have these classes that will be used on every page, I want them tobe like a "cloud hovering over my web" whatever page the user is browsing...

.



我正在使用文本编辑器进行编码(不是VS)所以我不使用程序集...


我认为解决方案是使用src =" initpages.cs"在@page

指令中,在.cs文件中有一个Page_Load()事件处理程序,它将附加必要的标题标记等等......


目前正在处理它,如果这个想法很荒谬,也许你让我知道了。

a .Net新手我很容易做蠢事:)
I am coding with a text editor (not VS) so I''m not using assemblies...

I think the solution will be to use src="initpages.cs" in the @page
directive and have a Page_Load() event handler in that .cs file that would
append neccesary header tags etc...

currently working on it, if the idea is ridicilous maybe you let me know as
a .Net newbie I easily do stupid things :)


这篇关于&QUOT包括(including)QUOT;所有.aspx页面的全局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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