2012-11-25 2 views
1

웹 과제가 거의 끝났습니다.하지만 호출 될 때 팝업을 거부하는 alertbox 형태의 걸림돌이 있습니다. 과제는 사용자가 웹 사이트에 개인 정보를 제출할 수있는 웹 양식을 만드는 것입니다. 일단 모든 텍스트 상자를 채우고 등록 할 버튼을 클릭하면 아래 보이는 코드 뒤에 registerMe 함수가 호출됩니다. 일단 그 기능을 수행하면 사용자가 웹 사이트에 아직 등록하지 않았는지를 먼저 확인한 다음 TextBox의 모든 값을 Session 객체로 채 웁니다 (즉, Candidate.curCandidate를 사용하는) 래퍼로서). 이 Session 개체는 응용 프로그램 상태 데이터에 저장되어 저장됩니다.이 경고 상자가 표시되지 않는 이유는 무엇입니까?

이제 이상한 점이 있습니다. 아래 if 문에서 문이 true이면 모든 값이 세션에 저장되고 응용 프로그램 상태 데이터가 원하는대로 저장되지만 Alertbox는 나타나지 않습니다. 그러나 if 문이 false이면 Alertbox가 나타납니다. 그래서, 나는이 값들을 읽고 쓰는 것이 Alertbox의 활성화를 방해하고 있다고 생각합니다. 그러나 나는 그 이유를 모릅니다.

protected void registerMe(object sender, EventArgs e) 
    { 
     String successText; 
     if (Candidate.curCandidate.appProperty == false) 
     { 
      Candidate.curCandidate.ssNumberProperty = socSec.Text; 
      Candidate.curCandidate.emailAddressProperty = email.Text; 
      Candidate.curCandidate.userIDProperty = userName0.Text; 
      Candidate.curCandidate.passwordProperty = password0.Text; 
      Candidate.curCandidate.dateOfBirthProperty = dateBirth.Text; 
      Candidate.curCandidate.firstNameProperty = fName0.Text; 
      Candidate.curCandidate.lastNameProperty = lName0.Text; 
      Candidate.curCandidate.streetAddressProperty = strAdd0.Text; 
      Candidate.curCandidate.cityProperty = city0.Text; 
      Candidate.curCandidate.stateProperty = state0.Text; 
      Candidate.curCandidate.positionProperty = jobs0.SelectedIndex; 
      Candidate.curCandidate.applicationStatusProperty = appStatus0.Text; 
      Candidate.curCandidate.appProperty = true; 
      Application[Candidate.curCandidate.ssNumberProperty]=Candidate.curCandidate; 

      successText = "Thank you. Candidate Information Added Successfully.\n" + 
       "E-Mail Address You Entered will be used to notify you of any\n" + 
       "updates for the position you applied for."; 
      ClientScript.RegisterStartupScript(this.GetType(), "myalert", 
       "alert('" + successText + "');", true); 
     } 
     else 
     { 
      successText = "Registration unsuccessful."; 
      ClientScript.RegisterStartupScript(this.GetType(), "myalert", 
       "alert('" + successText + "');", true); 
     } 
    } 

답변

0

봅니다 successText에서 \n를 제거하고 작동하는지 확인합니다. 당신이 정말로 그것을 필요하면

, 아래처럼 탈출을 두 번 시도 :

successText = "... Successfully.\\n"

+0

아, 프릭합니다. 그게 효과가 있었어. 나는 경고 문구를 사용하여 이런 방식으로 개행 문자를 사용했음을 알릴 수 있었지만, 아아. 감사. –

+0

메시지 문자열이 클라이언트 측에서 작성되면 작동합니다. 그러나 서버 측에서 생성되었으므로 이중에서 이스케이프해야합니다. 그렇지 않으면 메시지 문자열이 유효한 자바 스크립트가 아닌 새 행에 있습니다. –

관련 문제