2012-10-02 5 views
0

나는 새 페이지로 리디렉션 할 수 있지만 사용자가 읽을 수 있도록 메시지를 표시하고 작은 대기 기간을 가지고 싶습니다aspx를 새 페이지로 리디렉션하지만 메시지와 함께 대기 하시겠습니까?

을 나는이 작업을 수행 할 수 있습니다 알고

<script runat="server"> 
protected override void OnLoad(EventArgs e) 
    { 
    Response.Redirect("new.aspx"); 
    base.OnLoad(e); 
    } 
</script> 

그러나 어떻게 메시지를 보여주고 기다릴 수 있습니까?

감사합니다. 대신에 서버 측 코드를 사용

답변

2

, 당신은 meta refresh로, HTML에서 할 수 있습니다

<html> 
<head> 
    <title> Redirect </title> 
    <meta http-equiv="refresh" content="60;URL='http://foo/new.aspx'"/> 
</head> 

<body> 
    <p>You will be redirected in 60 seconds</p> 
</body> 
</html> 

당신은 당신이 사용자가 대기 할 초에 meta 태그의 content 속성에 60을 변경할 수 있습니다 .

0

당신은

<HTML> 
<HEAD> 
<!-- Send users to the new location. --> 
<TITLE>redirect</TITLE> 
<META HTTP-EQUIV="refresh" 
CONTENT="10;URL=http://<URL>"> 
</HEAD> 
<BODY> 
[Your message here] 
</BODY> 
</HTML> 
0

당신이 메타 새로 고침 태그를 사용하여 시도 가지고 예를 들어 클라이언트 측 기술, 메타 태그를 사용할 수 있습니까?

문서는 여기에서 찾을 수 있습니다 : http://en.wikipedia.org/wiki/Meta_refresh

는 기본적으로, 당신은 당신의 HTML의 <head/> 섹션에서 메타 새로 고침 태그를 넣고 URL과 함께 대기 시간을 지정합니다.

위의 예에서

<meta http-equiv="refresh" content="15;URL='http://www.something.com/page2.html'"> 

는 페이지 15 초를 기다린 다음 http://www.something.com/page2.html로 리디렉션된다.

그래서 메시지가있는 페이지를 만들고 헤더에 메타 새로 고침을 추가 할 수 있습니다. 설정된 시간이 지나면 new.aspx로 "새로 고침"됩니다.

<html> 
    <head> 
    <title>Redirecting</title> 
    <meta http-equiv="refresh" content="15;URL='new.aspx'"> 
    </head> 
    <body> 
    <p>Thanks for visiting our site, you're about to be redirect to our next page. In the meantime, here's an interesting fact....</p> 
    </body> 
</html> 
0

당신은 메시지 및 매개 변수

string msg = Request["Message"] 
string time = Request["Time"] 

당신은 사용자가 필요 잡을 수 new.aspx의를 Page_Load에서 쿼리 문자열에

Response.Redirect("new.aspx?Message=Your_Message&Time=3000") 

을 기다리는 시간을 전달할 수 있습니다 메시지를 보려면 x 초 동안 기다리시겠습니까? 예인 경우 자바 스크립트로해야합니다.

첫째, 자바 스크립트 함수를

protected void Page_Load(object sender, EventArgs e) 
    { 
     string msg = Request["Message"].ToString(); 
     string tempo = Request["Time"].ToString(); 
     string script = String.Format(@"setTimeout(""ShowMessage('{0}')"", {1})", msg, tempo); 
     ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "key", script, true); 
    } 

그것은 표시됩니다의 new.aspx의 뒤에 코드에서

function ShowMessage(msg) { 
     alert(msg); 
    } 

다음 메시지를 보여 매개 변수를 얻고 호출하는 자바 스크립트 함수를 만들 3 초 후 메시지.

관련 문제