0

What I am trying to do is to refresh the current .aspx page when the user clicks on an image (phmg.jpg) .

I have the following code and it works:

<a href="Currpage.aspx"> 
    <img src="../../images/phmg.jpg" width="900" height="506"/>
</a> 

I am wondering if there is a better way of doing this in asp.net. To recap, when the user clicks on "phmg.jpg" I like to refresh the current page.

Note that at the top of the page in the head tag I have the following code:

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
4

1 に答える 1

1

ページやページの内容によって異なります。コンテンツが頻繁に変更される場合、キャッシュの問題が発生する可能性があります。ページは更新されますが、コンテンツは更新されません。

ページ全体を更新する必要がありますか? 更新できるページのセクションはありますか? ページの複雑さによっては、更新パネルを使用してページを更新することができます。

ただし、ページ全体を更新するように設定されている場合。URL の末尾にタイムスタンプを含むクエリ文字列を追加して、ブラウザがキャッシュされた更新ではなく完全な更新を行うようにします。

更新: この方法では、アンカー タグは必要ありません。画像クリック イベントを使用するだけです。このメソッドは、リロードする前にすべてのクエリ文字列を削除することに注意してください。

<script type="text/javascript">
        function ReloadPage() {
            window.location = window.location.href.split('?')[0] + '?t=' + new Date().getTime();            
        }
</script>
    <img src="../../images/phmg.jpg" width="900" height="506" onclick="ReloadPage();"/>
于 2013-06-06T13:52:13.387 に答える