Home Backend Development C#.Net Tutorial How to implement ASP.NET page refresh

How to implement ASP.NET page refresh

Dec 20, 2016 am 09:09 AM
.net

< meta http-equiv="refresh" content="300; url=target.html"> Use window.location.href to refresh another frame page

When writing asp.net programs, we often encounter When it comes to jumping pages, we often use Response.Redirect. If the customer wants to use prompts when jumping, this will not work, such as:

Response.Write("< script>alert('Congratulations, Registration successful! '); < /script>"); Response.Redirect("main.html"); At this time, our prompt content will not come out, and Response.Redirect("main.html"); There is no difference.

At this time, we use the following code to test the ASP.NET page refresh:

Response.Write("< script language=javascript>alert('Congratulations, registration is successful!')< /script>"); Response .Write("< script language=javascript>window.location.href='main.html'< /script>"); This fulfills our requirements and jumps to the page after the prompt.

The most important thing is that the window.location.href statement can enable the page of one frame to refresh the page of another frame after executing the server-side code (Response.Redirect cannot be reached, at least I have not found it):

For example: index.htm There are two frames in the page, namely frameLeft and frameRight. After executing the server-side code in the frameRight page, the page in frameLeft is refreshed.

The most common thing previously was to automatically refresh the login box after registration, so that the login box is replaced by the logged-in page. As long as you add a paragraph after the successful registration code, you can refresh the page of another frame. The code is as follows:

Response.Write("< script language=javascript>alert('Congratulations, registration is successful!')< /script>"); Response.Write("< script language=javascript>window. parent.frameLeft.location.href='main.html'< /script>"); ASP.NET page refresh: summary of how to automatically refresh the page:

1)

< meta http-equiv="refresh "content="10; url=jumped page"> 10 means refresh every 10 seconds

2)

< script language=''javascript''> window.location.reload(true); < ; /script> If you want to refresh an iframe, replace window with the name or ID number of the frame

3)

< script language=''javascript''> window.navigate("This page url "); < /script> 4>

function abc() { window.location.href="/blog/window.location.href"; setTimeout("abc()",10000); } Refresh this page:

Response.Write("< script language=javascript>window.location.href=window.location.href; < /script>") Refresh the parent page:

Response.Write("< script language=javascript> ;opener.location.href=opener.location.href; < /script>") Go to the specified page:

Response.Write("< script language=javascript>window.location.href='yourpage.aspx' ; < /script>")
Summary of refresh page implementation methods (HTML, ASP, JS)

' by aloxy

Refresh regularly:

1,

< script>setTimeout("location.href='url '",2000)< /script> Description: url is the URL address of the page to be refreshed

2000 is the waiting time = 2 seconds,

2,

< meta name="Refresh" content="n; url "> Description:

n is the number of seconds to wait before loading the specified URL.

url is an absolute URL to be loaded.

n, is the waiting time, in seconds

url is to Refreshed page URL address

3,

< %response.redirect url%> Description: Generally, a url parameter or form value is used to determine whether an operation has occurred and then response.redirect is used to refresh.

4, Refresh the frame page

〈script language=javascript>top.leftFrm.location.reload(); parent.frmTop.location.reload(); < /script〉 Problem with refreshing the form after it pops up

Response.Write("< script>window.showModalDialog('../OA/SPCL.aspx',window,'dialogHeight: 300px; dialogWidth: 427px; dialogTop: 200px; dialogLeft: 133px')< /script>" ); //open Response.Write("< script>document.location=document.location; < /script>"); Add < base target="_self"/> in the subform page code head

The refreshed content is added to if (!IsPostBack)

Refresh the left side on the right side of the frame page

//Refresh the left half of the frame page Response.Write("< script language=javascript>"); Response.Write("parent.left.location.href='PayDetailManage_Left.aspx'"); Response.Write("< ; /script>");
There are three ways to implement the scheduled page refresh function

:

1. Set it in html:

< title>xxxxx< /title> Then add the following line!

Refresh regularly:

< META HTTP-EQUIV="Refresh" content="10"> 10 represents the refresh interval, in seconds

2.jsp

< % response.setHeader("refresh", "1"); %> Refresh once every second

3. Use javascript:

< script language="javascript"> setTimeout("self.location.reload(); ",1000); < script> Once a second

The page automatically jumps:

1, set in html:

< title>xxxxx< /title> Then add the following line!

Regular jump and refresh:

< meta http-equiv="refresh" content="20; url=http://own URL">, where 20 means jumping to http after 20 seconds: //Own URL page.


Click the button to submit the form and refresh the upper-level window

A window opens B window

Then submit data in B to C window

Finally refresh A window

and close B window

Several javascript functions

//The first window to automatically close

< script language="javascript"> < !-- function clock(){i=i-1 document.title="This window will close in "+i+" seconds Automatically close!"; if(i>0)setTimeout("clock(); ",1000); else self.close(); } var i=2 clock(); //--> < /script> //The second function to refresh the parent page

< script language="javascript"> opener.location.reload(); < /script> //The third function to open the window

< script language=" javascript"> function show(mylink,mytitle,width,height) {mailwin=window.open(mylink,mytitle,'top=350,left=460,width='+width+',height='+height+',scrollbars =no')} < /script> Regarding the issue of asp.net page refresh, it will be useful to collect these methods

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1671
14
PHP Tutorial
1276
29
C# Tutorial
1256
24
Share several .NET open source AI and LLM related project frameworks Share several .NET open source AI and LLM related project frameworks May 06, 2024 pm 04:43 PM

The development of artificial intelligence (AI) technologies is in full swing today, and they have shown great potential and influence in various fields. Today Dayao will share with you 4 .NET open source AI model LLM related project frameworks, hoping to provide you with some reference. https://github.com/YSGStudyHards/DotNetGuide/blob/main/docs/DotNet/DotNetProjectPicks.mdSemanticKernelSemanticKernel is an open source software development kit (SDK) designed to integrate large language models (LLM) such as OpenAI, Azure

What are the employment prospects of C#? What are the employment prospects of C#? Oct 19, 2023 am 11:02 AM

Whether you are a beginner or an experienced professional, mastering C# will pave the way for your career.

.NET performance optimization technology for developers .NET performance optimization technology for developers Sep 12, 2023 am 10:43 AM

If you are a .NET developer, you must be aware of the importance of optimizing functionality and performance in delivering high-quality software. By making expert use of the provided resources and reducing website load times, you not only create a pleasant experience for your users but also reduce infrastructure costs.

Performance differences between Java framework and .NET framework Performance differences between Java framework and .NET framework Jun 03, 2024 am 09:19 AM

In terms of high-concurrency request processing, .NETASP.NETCoreWebAPI performs better than JavaSpringMVC. The reasons include: AOT early compilation, which reduces startup time; more refined memory management, where developers are responsible for allocating and releasing object memory.

C# .NET: Exploring Core Concepts and Programming Fundamentals C# .NET: Exploring Core Concepts and Programming Fundamentals Apr 10, 2025 am 09:32 AM

C# is a modern, object-oriented programming language developed by Microsoft and as part of the .NET framework. 1.C# supports object-oriented programming (OOP), including encapsulation, inheritance and polymorphism. 2. Asynchronous programming in C# is implemented through async and await keywords to improve application responsiveness. 3. Use LINQ to process data collections concisely. 4. Common errors include null reference exceptions and index out-of-range exceptions. Debugging skills include using a debugger and exception handling. 5. Performance optimization includes using StringBuilder and avoiding unnecessary packing and unboxing.

C# .NET Interview Questions & Answers: Level Up Your Expertise C# .NET Interview Questions & Answers: Level Up Your Expertise Apr 07, 2025 am 12:01 AM

C#.NET interview questions and answers include basic knowledge, core concepts, and advanced usage. 1) Basic knowledge: C# is an object-oriented language developed by Microsoft and is mainly used in the .NET framework. 2) Core concepts: Delegation and events allow dynamic binding methods, and LINQ provides powerful query functions. 3) Advanced usage: Asynchronous programming improves responsiveness, and expression trees are used for dynamic code construction.

The Continued Relevance of C# .NET: A Look at Current Usage The Continued Relevance of C# .NET: A Look at Current Usage Apr 16, 2025 am 12:07 AM

C#.NET is still important because it provides powerful tools and libraries that support multiple application development. 1) C# combines .NET framework to make development efficient and convenient. 2) C#'s type safety and garbage collection mechanism enhance its advantages. 3) .NET provides a cross-platform running environment and rich APIs, improving development flexibility.

From Web to Desktop: The Versatility of C# .NET From Web to Desktop: The Versatility of C# .NET Apr 15, 2025 am 12:07 AM

C#.NETisversatileforbothwebanddesktopdevelopment.1)Forweb,useASP.NETfordynamicapplications.2)Fordesktop,employWindowsFormsorWPFforrichinterfaces.3)UseXamarinforcross-platformdevelopment,enablingcodesharingacrossWindows,macOS,Linux,andmobiledevices.

See all articles