Board logo

標題: 網頁不會自動更新問題(asp) [打印本頁]

作者: saxontse    時間: 2007-1-7 00:06     標題: 網頁不會自動更新問題(asp)

我想問0下點解我用asp 整完個網頁之後
每當我database update 0左野,佢都唔會更新,要我click refresh 先得呢?
係咩問題呢?
thx
作者: koon    時間: 2007-1-7 14:24

If you want your web page to auto refresh, one of the simplest method is to add in the following code inside the head tag:

<meta http-equiv="refresh" content="5" >

The attribute http-equiv="refresh" calls for refresh of the page, 5 menas it will refresh every 5 seconds.

You should set the time to above 5 seconds because you have to consider the page reload time.
作者: saxontse    時間: 2007-1-17 20:10

引用:
原帖由 koon 於 2007-1-7 06:24 AM 發表
If you want your web page to auto refresh, one of the simplest method is to add in the following code inside the head tag:

<meta http-equiv="refresh" content="5" >

T ...
其實我唔係想要尼樣野

for example:

the page before I edit, and the first time I use browser was:

ABC BBQ
----------------------

After I updated the page like this:

BBQ ABC
---------------------

But after I enter the same URL, it remains:

ABC BBQ
----------------------


So I post this thread to ask how to update the page automatically without I use "Refresh buttom" to refresh the page, I don't need the page update every N seconds.

But nevermind, thank you for your reposonse
作者: s.vicente14    時間: 2007-1-18 00:49

why u update the db instead of the asp page???
作者: saxontse    時間: 2007-1-18 13:04

引用:
原帖由 s.vicente14 於 2007-1-17 04:49 PM 發表
why u update the db instead of the asp page???
You misunderstand what I mean......

here is what I want to show in abc.asp orginally:

ABC BBQ

I open the browser then see what I enter, but then I edit abc.asp as follow:

BBQ ABC

I enter the same URL/or open a new broswer, the result remains ABC BBQ, it change the value to BBQ ABC until I click "Refresh" button of broswer

My question is, how to automatically update the content without I click the "Refresh" Button, is it related to the history of browser?
作者: koon    時間: 2007-1-20 02:25

You have to ask the question correctly else it is very difficult for other to help you.

I now understand what you want......

Just add a sub to submit the form when you have updated the info, then you will see the new data.
作者: 鋼    時間: 2007-1-31 20:39

Do you mean this ?



In the I.E. browser menu, select

Tools
Internet Options ...
General/Temporary Internet files / <Settings...>

In the "Every visit to the page", select "Check for newer version of stored pages"
作者: ciahoudun    時間: 2007-2-1 23:11

收益匪浅,谢谢搂住!!!再接再厉!
作者: usnameless    時間: 2007-2-2 07:47

引用:
原帖由 saxontse 於 1/6/2007 08:06 AM 發表
我想問0下點解我用asp 整完個網頁之後
每當我database update 0左野,佢都唔會更新,要我click refresh 先得呢?
係咩問題呢?
thx
一般鞝SP用VBScript access完Database 之後, 將data presents 好就放入html 中送到 browser for display.  之後如果data 在 database 中被改動, browser 中髼tml係唔會自動被update的.  你可以好似樓上咁講去set auto-refresh.  但要考慮麉Ysystem resource.  如果每個web client/browser 每5秒都query database 一次, 咁會拖低 performance.
其實一般鵁eb-base application 都唔會咁做.  這亦係web-base application 鮢hort-coming.
作者: saxontse    時間: 2007-2-2 12:01

引用:
原帖由 usnameless 於 2007-2-1 23:47 發表


一般鞝SP用VBScript access完Database 之後, 將data presents 好就放入html 中送到 browser for display.  之後如果data 在 database 中被改動, browser 中髼tml係唔會自動被update的.  你可以好似樓上咁講 ...
尼個真係我想知既答案
謝謝
作者: koon    時間: 2007-2-3 19:55

引用:
原帖由 usnameless 於 2007-2-2 07:47 發表


一般鞝SP用VBScript access完Database 之後, 將data presents 好就放入html 中送到 browser for display.  之後如果data 在 database 中被改動, browser 中髼tml係唔會自動被update的.  你可以好似樓上咁講 ...
You are right that ASP will not auto fresh the page, but you can add a sub-routine such as button1_onclick, or if you have change something in the pull down menu, or change some text box you can use like:

Sub xxxx_onchange
  document.formx.submit()
end sub

In this case once you update the data say from ABC XYZ to DEF MNO, it will submit the form automatically and refresh the page, then you can see the new changed data immediately.

To refresh the page after you change the data in the form, you should add the line formx method= post action = abc.asp
作者: usnameless    時間: 2007-2-6 04:33

引用:
原帖由 koon 於 2/3/2007 03:55 AM 發表

You are right that ASP will not auto fresh the page, but you can add a sub-routine such as button1_onclick, or if you have change something in the pull down menu, or change some text box you can  ...
其實都唔洗code咁多, 樓主refresh個client已經可以.  問題關鍵係, 唔似一D client/server application, data in database被updated, web-client 係好難被通知而update display緊魈nformation accordingly.  例如你on-line banking時 check你個account balance, 機乎無web-application會synchronize the dispalyed balance with the database after the initial request.  Data只會係for reference only.  又好似網上購物買飛, 見到有都不一定買到, 直至payment confirmed, 你先知道.  有D seller 好人D, 你proceed to check-out時佢已幫你hold 住件貨/D 飛 until session expire.

[ 本帖最後由 usnameless 於 2007-2-5 12:34 編輯 ]
作者: koon    時間: 2007-2-8 03:06

It all depands on the application and what the programmer wants. In his earler post he mention that when he changed from ABC BBQ to BBQ ABC, the page will not show the changed until he clicks the refresh button. So, in order to show the new data without clicking the re-fresh button you can either (1) have auto re-refresh every x seconds, but this will eat up the resources, or (2) when there are changes, detect the changes and post the page again, although this involve a bit of codes, but you cannot get something from nothing right?

As for the bank, it is true that example Hang Seng and HSBC after you have done some transactions, the account summary will not show the new balance until you click the refresh. But HSBC of some branches example HSBC Malaysia, the account summary will show you the correct balance without clicking the refresh button.

So it depands on what you want the page to look like.




歡迎光臨 香港 Xocat Forum 討論區 (http://p.xocat.com/p/) Powered by Discuz! 6.0.0