在每个页面的入口处运行脚本 [英] Run script at entry of each page

查看:59
本文介绍了在每个页面的入口处运行脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在每个页面输入时运行脚本或函数,而不必在每个页面中调用



定期,每次输入页面时我都会找到我想要做的事情。

我必须进入每个页面并在我的asp.net代码中添加一行或2行。这就是很多页面,我很容易错过一个。


例如,我有一个我构建的用户对象,我刚添加了一个字段 -

LastPageVisited。这是必要的,因为显然,你不能依赖推荐人获得最后一页的
。我需要这个来告诉我,我来自我网站的
,或者我是否来自我网站的某个页面,或者用户是否只需输入
浏览器的地址行。


现在我只需添加行


Session(" User")。LastPageVisited =" This页面。


但我必须将其添加到大约150页。


如果我对此进行更改,我需要制作每150页更改一次。


谢谢,


Tom

Is there a way to run a script or function on entry of each page without
having to put a call in each page?

Periodically, I find something I want to do each time a page is entered and
I have to go into each page and add a line or 2 in my asp.net code. That''s
a lot of pages and I could easily miss one.

For example, I have a user object that I built that I just added a field -
LastPageVisited. This was necessary because, apparently, you can''t depend
on the referrer to have the last page. I need this to tell me where I came
from in my site or if I even came from a page in my site or whether a user
just typed the URL into the address line of the browser.

So now I just add the line

Session("User").LastPageVisited = "This Page".

But I have to add this to about 150 pages.

If I make a change to this, I need to make the change to each 150 pages.

Thanks,

Tom

推荐答案

我想说的最好是创建一个名为说BaseForm.aspx的页面,并在其页面中编写你的会话(用户)。LastDoVisited =" This Page"。然后

在其他表单的代码隐藏中更改继承

System.Web.UI.Page toInherits BaseForm。坏消息是你还在用

来改变150页来自BaseForm,但是如果你的代码改变了它

只改变了基数而你没有在派生表单的Page_Load中更新会话变量




" tshad" < TS ********** @ ftsolutions.com>在消息中写道

新闻:Ox ************** @ TK2MSFTNGP14.phx.gbl ...
Best I would say is to create a page called say BaseForm.aspx and in its
Page_Load you code your Session("User").LastPageVisited = "This Page". Then
in the code-behind of the other forms change the "Inherits
System.Web.UI.Page" to "Inherits BaseForm". Bad news is you still are going
to change 150 pages to derive from BaseForm, but if your code changes it
changes in the base only and you don''t have to update the session variable
in the Page_Load of the derived forms.

"tshad" <ts**********@ftsolutions.com> wrote in message
news:Ox**************@TK2MSFTNGP14.phx.gbl...
有没有办法在每个页面的输入上运行脚本或功能而不必在每个页面中打个电话?

每次输入页面时,我会发现我想要做的事情我必须进入每个页面并在我的asp.net代码中添加一行或2行。
这是很多页面,我很容易错过一个。

例如,我有一个我建立的用户对象,我刚刚添加了一个字段 -
LastPageVisited。这是必要的,因为显然,你不能依赖推荐人来获得最后一页。我需要这个来告诉我在我的网站上来自哪里,或者我是从我网站的某个页面来的,还是
用户只是在浏览器的地址行输入了URL。 />
所以现在我只需添加一行

会话(用户)。LastPageVisited =" This Page"

但我必须添加这大约150页。

如果我对此进行更改,我需要对每150页进行更改。

谢谢,
Tom
Is there a way to run a script or function on entry of each page without
having to put a call in each page?

Periodically, I find something I want to do each time a page is entered
and I have to go into each page and add a line or 2 in my asp.net code.
That''s a lot of pages and I could easily miss one.

For example, I have a user object that I built that I just added a field -
LastPageVisited. This was necessary because, apparently, you can''t depend
on the referrer to have the last page. I need this to tell me where I
came from in my site or if I even came from a page in my site or whether a
user just typed the URL into the address line of the browser.

So now I just add the line

Session("User").LastPageVisited = "This Page".

But I have to add this to about 150 pages.

If I make a change to this, I need to make the change to each 150 pages.

Thanks,

Tom



" Chris Botha" < CH *********** @ AThotmail.com>在留言中写道

新闻:Ol ************** @ TK2MSFTNGP10.phx.gbl ...
"Chris Botha" <ch***********@AThotmail.com> wrote in message
news:Ol**************@TK2MSFTNGP10.phx.gbl...
我会说最好的是创建一个名为BaseForm.aspx的页面,并在其页面_Load中编码你的会话(用户)。LastPageVisited =" This Page"。
然后在其他表格的代码隐藏中更改继承
System.Web.UI.Page toInherits BaseForm。坏消息是你仍然要改变150页来源于BaseForm,但如果你的代码改变了它只改变了基础,你不必更新
会话派生表单的Page_Load中的变量。


问题是我没有使用Code-Behind页面。


Tom
" tshad" < TS ********** @ ftsolutions.com>在消息中写道
新闻:Ox ************** @ TK2MSFTNGP14.phx.gbl ...
Best I would say is to create a page called say BaseForm.aspx and in its
Page_Load you code your Session("User").LastPageVisited = "This Page".
Then in the code-behind of the other forms change the "Inherits
System.Web.UI.Page" to "Inherits BaseForm". Bad news is you still are
going to change 150 pages to derive from BaseForm, but if your code
changes it changes in the base only and you don''t have to update the
session variable in the Page_Load of the derived forms.
Problem with this is I am not using Code-Behind pages.

Tom
"tshad" <ts**********@ftsolutions.com> wrote in message
news:Ox**************@TK2MSFTNGP14.phx.gbl...
有没有办法运行脚本或每个页面的输入功能,而不必在每个页面都打电话?

我每次都会在每次页面输入时找到我想做的事情
我有进入每个页面并在我的asp.net代码中添加一行或2行。
这是很多页面,我很容易错过一个。

例如,我有一个我构建的用户对象,我刚刚添加了一个
字段 - LastPageVisited。这是必要的,因为显然,你不能依赖推荐人来获得最后一页。我需要这个来告诉我/我来自我网站的地方,或者我是否来自我网站的页面
或者用户是否只是将URL输入到地址行中
浏览器。

所以现在我只需添加一行

会话(用户)。LastPageVisited =" This Page"

但是我必须将其添加到大约150页。

如果我对此进行更改,我需要对每150页进行更改。

谢谢,
Tom
Is there a way to run a script or function on entry of each page without
having to put a call in each page?

Periodically, I find something I want to do each time a page is entered
and I have to go into each page and add a line or 2 in my asp.net code.
That''s a lot of pages and I could easily miss one.

For example, I have a user object that I built that I just added a
field - LastPageVisited. This was necessary because, apparently, you
can''t depend on the referrer to have the last page. I need this to tell
me where I came from in my site or if I even came from a page in my site
or whether a user just typed the URL into the address line of the
browser.

So now I just add the line

Session("User").LastPageVisited = "This Page".

But I have to add this to about 150 pages.

If I make a change to this, I need to make the change to each 150 pages.

Thanks,

Tom




哇,这可能是重新考虑的好时机:-)


" tshad" < TS ********** @ ftsolutions.com>在消息中写道

news:ut ************* @ TK2MSFTNGP15.phx.gbl ...
Wow, this may be a good time to reconsider :-)

"tshad" <ts**********@ftsolutions.com> wrote in message
news:ut*************@TK2MSFTNGP15.phx.gbl...
" Chris Botha" < CH *********** @ AThotmail.com>在消息中写道
新闻:Ol ************** @ TK2MSFTNGP10.phx.gbl ...
"Chris Botha" <ch***********@AThotmail.com> wrote in message
news:Ol**************@TK2MSFTNGP10.phx.gbl...
最好我会说是创建一个页面叫做BaseForm.aspx并在其页面_Load中编码你的会话(用户)。LastPageVisited =" This Page"
然后在其他表格的代码隐藏中改变继承
System.Web.UI.Page toInherits BaseForm。坏消息是你仍然要改变150页来源于BaseForm,但如果你的代码改变了它只改变了基础,你不必更新
会话派生形式的Page_Load中的变量。
Best I would say is to create a page called say BaseForm.aspx and in its
Page_Load you code your Session("User").LastPageVisited = "This Page".
Then in the code-behind of the other forms change the "Inherits
System.Web.UI.Page" to "Inherits BaseForm". Bad news is you still are
going to change 150 pages to derive from BaseForm, but if your code
changes it changes in the base only and you don''t have to update the
session variable in the Page_Load of the derived forms.



问题是我没有使用Code-Behind页面。

Tom



Problem with this is I am not using Code-Behind pages.

Tom


tshad < TS ********** @ ftsolutions.com>在消息中写道
新闻:Ox ************** @ TK2MSFTNGP14.phx.gbl ...

"tshad" <ts**********@ftsolutions.com> wrote in message
news:Ox**************@TK2MSFTNGP14.phx.gbl...
有没有办法运行脚本或每个页面的输入功能,而不必在每个页面都打电话?

我每次都会在每次页面输入时找到我想做的事情
我有进入每个页面并在我的asp.net代码中添加一行或2行。
这是很多页面,我很容易错过一个。

例如,我有一个我构建的用户对象,我刚刚添加了一个
字段 - LastPageVisited。这是必要的,因为显然,你不能依赖推荐人来获得最后一页。我需要这个来告诉我/我来自我网站的地方,或者我是否来自我网站的页面
或者用户是否只是将URL输入到地址行中
浏览器。

所以现在我只需添加一行

会话(用户)。LastPageVisited =" This Page"

但是我必须将其添加到大约150页。

如果我对此进行更改,我需要对每150页进行更改。

谢谢,
Tom
Is there a way to run a script or function on entry of each page without
having to put a call in each page?

Periodically, I find something I want to do each time a page is entered
and I have to go into each page and add a line or 2 in my asp.net code.
That''s a lot of pages and I could easily miss one.

For example, I have a user object that I built that I just added a
field - LastPageVisited. This was necessary because, apparently, you
can''t depend on the referrer to have the last page. I need this to tell
me where I came from in my site or if I even came from a page in my site
or whether a user just typed the URL into the address line of the
browser.

So now I just add the line

Session("User").LastPageVisited = "This Page".

But I have to add this to about 150 pages.

If I make a change to this, I need to make the change to each 150 pages.

Thanks,

Tom





这篇关于在每个页面的入口处运行脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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