2012-02-08 3 views
0

이유는 모르겠지만 PageLoad() 함수 내에서 ASP 응용 프로그램 내부에서 자바 스크립트 경고가 표시됩니다. 그것은 잘 처리하지만, 내가 얻을 다른 작업을하려고 할 때 오류 다음 (이것은 또한 단지 IE 및 디버그 모드에서 비주얼 스튜디오()에서 발생) :C#의 자바 스크립트 문제

Line: 4056 
Error: Unspecified error. 

    Response.Write("<script language='javascript'>alert(' You currently have an incomplete quote.\\n Here is your customers information: \\n First Name: " + _firstName + " \\n Last Name: " + _lastName+ " \\n Number Of Drivers: " + _driveList.Count().ToString() + " \\n Number Of Vehicles: " + _vehicleList.Count().ToString() + " \\n Date Of Quote: " + _pendingQuote.Date.ToString() + " ')</script>"); 
+0

Visual Studio 또는 브라우저에서 생성되는 오류입니까? 코드에서 그 시점까지 도달하면 응답 스트림이 닫습니까? – NotMe

+0

C# 코드를 게시 할 수 있습니까? –

+1

이 경우 문자열 연결을 사용하지 마십시오. String.Format을 사용하십시오. –

답변

2

왜 당신은 스크립트 관리자를 사용하지 말아

ScriptManager.RegisterStartupScript(this, this.GetType(), "alertScript", string.Format("alert('{0}');",alertText), true); 
,

이 읽고 형식 훨씬 쉽게

StringBuilder buildAlertString=new StringBuilder(); 
    buildAlertString.Append("You currently have an incomplete quote."); 
    buildAlertString.Append(Environment.NewLine); 
    buildAlertString.Append(string.Format("First Name:{0}",_firstName)); 
    ... 
    string alertText=buildAlertString.ToString() 

같은 문자열 빌더의 경고 텍스트를 만들 수 있습니다. 희망이 도움이

+0

감사합니다 :), 완벽하게 근무 – shenn

1

시도 :

Response.Write("<script language='javascript'>alert(' You currently have an incomplete quote.\\n Here is your customers information: \\n First Name: " + "FNAME" + " \\n Last Name: " + "LNAME"+ " \\n Number Of Drivers: " + 6 + " \\n Number Of Vehicles: " + 6 + " \\n Date Of Quote: " + "DATE" + " ');</script>"); 

그런 시도 :

Response.Write("<script language='javascript'>alert(' You currently have an incomplete quote.| Here is your customers information: | First Name: " + "FNAME" + " | Last Name: " + "LNAME"+ " | Number Of Drivers: " + 6 + " | Number Of Vehicles: " + 6 + " | Date Of Quote: " + "DATE" + " ');</script>");