2013-06-08 2 views
-1

경고 메시지를로드하지 않고 실행하려고하면 바로 homeNew.aspx 페이지로 이동합니다. 그러나 리디렉션 코드를 사용할 수없는 경우 경고 메시지가 올바르게 표시됩니다 ... 경고 메시지에 "확인"을 클릭 한 후에 두 가지 기능이 모두 필요합니다. 다음 페이지로 리디렉션해야합니다.이 문제를 극복하도록 도와주세요. 문제.자바 스크립트가이 코드에서 작동하지 않습니다

if (TextBox2.Text == nic) 
{ 
    Response.Write(@"<script language='javascript'>alert('Check your email to retrieve your user name and password!')</script>"); 
    Response.Redirect("homeNew.aspx"); 
    connection.Close(); 
} 
else 
{ 
    Response.Write(@"<script language='javascript'>alert('INVALID Email address and NIC combination, Try Again!')</script>"); 
} 
+0

변경 TextBox2.Text을 == NIC를 TextBox2.Text에 == "nic" – Satya

+0

nic은 문자열 리터럴이 아닌 매개 변수가 될 수 있습니다. – RubbleFord

+0

nic은 변수가 아니며, response.write 명령문과 response.redirect 상태는 모두 응답 만있을 때 작동하지 않습니다. 리디렉션이 작동 중입니다. 그 경우에 response.write 문이 작동하는 경우 해당 문을 사용하지 않으면 – Jiya

답변

1

"리디렉션 때문에 코딩 자바 스크립트는 브라우저에 의해 실행되지 않습니다. 당신은 자바 스크립트 내부 리디렉션 코드를 코딩 할 수 있습니다.

if (TextBox2.Text == nic) 
{ 
    Response.Write(@"<script language='javascript'>alert('Check your email to retrive your user name and password!'); window.location=""/homeNew.aspx""</script>"); 
} 
else 
{ 
    Response.Write(@"<script language='javascript'>alert('INVALID Email address and NIC combination, Try Again!')</script>"); 
} 
+0

Thanx 많이 SuperLucky ... :) – Jiya

0
alert('Check your email to retrive your user name and password!'); 
window.location = '/homeNew.aspx'; 

당신은 스크립트 태그 안에 모두를 할 필요가있다.

관련 문제