2012-07-26 2 views
-3

다음 JavaScript는 Visual Studio의 aspx.cs에 있으며 새 스크립트를 추가했지만 스크립트가 제대로 작동하는지 여부를 확인할 수 없습니다.Visual Studio에서 Javascript 디버그

sb.AppendFormat("function chkQuoteBinderValidUntilDateOverridden_OnClick()", this.chkQuoteBinderValidUntilDateOverridden.ClientID); 
      sb.AppendLine("{"); 
      sb.AppendLine(" var chkQuoteBinderValidUntilDateOverridden = document.getElementById('" + chkQuoteBinderValidUntilDateOverridden.ClientID + "');"); 
      sb.AppendLine(" var wdcQuoteBinderValidUntilDate = document.getElementById('" + wdcQuoteBinderValidUntilDate.ClientID + "');"); 
      sb.AppendLine(" var wdcQuoteBinderValidUntilDate_input = document.getElementById('" + wdcQuoteBinderValidUntilDate.ClientID + "_input');"); 
      sb.AppendLine(" var wdcQuoteBinderValidUntilDate_container = document.getElementById('" + wdcQuoteBinderValidUntilDate.ClientID + "_container');"); 
      sb.AppendLine(" var wdcQuoteBinderValidUntilDate_img = document.getElementById('" + wdcQuoteBinderValidUntilDate.ClientID + "_img');"); 
      sb.AppendLine(" var wdcQBValidUntilDate = igdrp_getComboById('" + this.wdcQuoteBinderValidUntilDate.ClientID + "');"); 
      sb.AppendLine(" var hiddenWDCQBValidUntilDate = document.getElementById('" + this.HiddenWDCQuoteBinderValidUntilDate.ClientID + "');"); 
      sb.AppendLine(" var hiddenQBValidUntilDate = new Date(hiddenWDCQBValidUntilDate.value);"); 
      sb.AppendLine(" if(chkQuoteBinderValidUntilDateOverridden.checked == true) {"); 
      sb.AppendLine("  setDateChooserDisabled(wdcQuoteBinderValidUntilDate,false);"); 
      sb.AppendLine("  wdcQuoteBinderValidUntilDate_img.setAttribute('src', wdcEnabledImageUrl);"); 
      sb.AppendLine(" }"); 
      sb.AppendLine(" else {"); 
      sb.AppendLine(" var now = new Date();"); 
      sb.AppendLine("  setDateChooserDisabled(wdcQuoteBinderValidUntilDate,true);"); 
      sb.AppendLine("  wdcQuoteBinderValidUntilDate_img.setAttribute('src', wdcDisabledImageUrl);"); 
      sb.AppendLine("  if(hiddenQBValidUntilDate) {");    
      sb.AppendLine("    wdcQBValidUntilDate.setValue(hiddenQBValidUntilDate);"); 
      sb.AppendLine("    if (lblQuoteBinderExpiresIn == null) {"); 
      sb.AppendLine("      lblQuoteBinderExpiresIn = document.getElementById('" + lblQuoteBinderExpiresIn.ClientID + "');"); 
      sb.AppendLine("    }"); 
      sb.AppendLine("    dif = ((hiddenQBValidUntilDate - now)/(86400*1000));"); 
      sb.AppendLine("    dif = (dif - (dif % 1)) + 1;"); 
      sb.AppendLine("    lblQuoteBinderExpiresIn.innerText = '(' + dif.toString() + ' days)';"); 
      sb.AppendLine("   }"); 
      sb.AppendLine(" }"); 
      sb.AppendLine("}"); 

      sb.AppendLine("function wdcQuoteBinderValidUntilDate_OnBlur(oDateChooser , dummy, oEvent) {"); 
      sb.AppendLine(" var now = new Date();"); 
      sb.AppendLine(" var wdcQuoteBinderValidUntilDate = oDateChooser.getValue();");      
      sb.AppendLine(" if (lblQuoteBinderExpiresIn == null) {"); 
      sb.AppendLine(" lblQuoteBinderExpiresIn = document.getElementById('" + lblQuoteBinderExpiresIn.ClientID + "');"); 
      sb.AppendLine(" }"); 
      sb.AppendLine(" if(wdcQuoteBinderValidUntilDate != null) {"); 
      sb.AppendLine("   dif = ((wdcQuoteBinderValidUntilDate - now)/(86400*1000));"); 
      sb.AppendLine("   dif = (dif - (dif % 1)) + 1;"); 
      sb.AppendLine("   lblQuoteBinderExpiresIn.style.visibility = 'visible';"); 
      sb.AppendLine("   lblQuoteBinderExpiresIn.innerText = '(' + dif.toString() + ' days)';"); 
      sb.AppendLine(" }"); 
      sb.AppendLine(" else {"); 
      sb.AppendLine("   lblQuoteBinderExpiresIn.style.visibility = 'hidden';"); 
      sb.AppendLine(" }"); 
      sb.AppendLine("}"); 


      sb.AppendLine("function wdcQuoteBinderValidUntilDate_CalendarValueChanged(oCalendar, oDate, oEvent) {"); 
      sb.AppendLine(" var now = new Date();"); 
      sb.AppendLine(" if (lblQuoteBinderExpiresIn == null) {"); 
      sb.AppendLine("  lblQuoteBinderExpiresIn = document.getElementById('" + lblQuoteBinderExpiresIn.ClientID + "');"); 
      sb.AppendLine(" }"); 
      sb.AppendLine(" dif = ((oDate - now)/(86400*1000));"); 
      sb.AppendLine(" dif = (dif - (dif % 1)) + 1;"); 
      sb.AppendLine(" lblQuoteBinderExpiresIn.innerText = '(' + dif.toString() + ' days)';"); 
      sb.AppendLine("}"); 

      sb.AppendLine("function colInsuredState_OnChange(isNewYork) {"); 
      sb.AppendLine(" var chkNewYorkFreeTradeZone = document.getElementById('" + chkNewYorkFreeTradeZone.ClientID + "');"); 
      sb.AppendLine(" var lblNewYorkFreeTradeZone = document.getElementById('" + lblNewYorkFreeTradeZone.ClientID + "');"); 
      sb.AppendLine(" var ddlPolicyType = document.getElementById('" + ddlPolicyType.ClientID + "');"); 
      sb.AppendLine(" var txtClassCode = document.getElementById('" + txtClassCode.ClientID + "');"); 
      sb.AppendLine(" var lnkClassCodePrompt = document.getElementById('" + lnkClassCodePrompt.ClientID + "');"); 
      sb.AppendLine(" var policyTypeId = ddlPolicyType.value;"); 
      sb.AppendLine(""); 
      sb.AppendLine(" if(isNewYork) {"); 
      sb.AppendLine("  chkNewYorkFreeTradeZone.style.visibility = 'visible';"); 
      sb.AppendLine("  chkNewYorkFreeTradeZone.checked = false;"); 
      sb.AppendLine("  lblNewYorkFreeTradeZone.style.visibility = 'visible';"); 
      sb.AppendLine("  txtClassCode.style.visibility = 'visible';"); 
      sb.AppendLine("  txtClassCode.disabled = false;"); 
      sb.AppendLine("  lnkClassCodePrompt.disabled = false;"); 
      sb.AppendLine("  lnkClassCodePrompt.style.visibility = 'visible';"); 
      sb.AppendLine("  if(policyTypeId == " + (int)Model.REF.EnumPolicyTypes.ENODPL + ") {"); 
      sb.AppendLine("    chkNewYorkFreeTradeZone.checked = true;"); 
      sb.AppendLine("    chkNewYorkFreeTradeZone.disabled = true;"); 
      sb.AppendLine("    }"); 
      sb.AppendLine(" }"); 
      sb.AppendLine(" else {"); 
      sb.AppendLine("  chkNewYorkFreeTradeZone.parentElement.style.visibility = 'hidden';"); 
      sb.AppendLine("  chkNewYorkFreeTradeZone.style.visibility = 'hidden';"); 
      sb.AppendLine("  chkNewYorkFreeTradeZone.checked = false;"); 
      sb.AppendLine("  lblNewYorkFreeTradeZone.style.visibility = 'hidden';"); 
      sb.AppendLine("  txtClassCode.value = '';"); 
      sb.AppendLine("  txtClassCode.disabled = true;"); 
      sb.AppendLine("  txtClassCode.style.visibility = 'hidden';"); 
      sb.AppendLine("  lnkClassCodePrompt.disabled = true;"); 
      sb.AppendLine("  lnkClassCodePrompt.style.visibility = 'hidden';"); 
      sb.AppendLine(" }"); 
      sb.AppendLine(""); 
      sb.AppendLine("}"); 
+1

당신이 만약 스크립트가 제대로 작동하는지 확실하지 않은 경우 다른 사람이 어떻게 알 수 있습니까? –

+2

쉽고, 자바 스크립트를 가져 와서 JS 파일에 넣고 프로그래밍 언어를 섞어서 사용하지 마십시오. – zzzzBov

+0

@ChristoferEliasson ... 내 질문에 대한 Visual Studio.so에서 Java 스크립트를 사용하지 않았다는 것에 관한 내용입니다. 날씨가 좋지 않아서 ... ... – user1552588

답변

3

사용 파이어 폭스와 Firebug 플러그인이 쉽게 자바 스크립트를 디버깅하는 .... 방법 다음 코드를 디버깅하는 말해.

+1

동일한 플러그인이없는 Chrome에서도 마찬가지입니다. –

+0

... 개발자 도구를 사용하는 IE의 경우. Chrome을 선호하지만. – Nope

+0

Chrome의 개발자 도구가 마음에 들지만 Firebug는 여전히 내가 선호하는 JavaScript 디버거입니다. –

1

VS2008 이상에서는 javascript를 직접 디버깅 할 수 있지만 디버깅을 위해 Internet Explorer를 기본 브라우저로 사용해야합니다.
IE가 현재 기본 브라우저가 아닌 경우 솔루션 탐색기에서 파일을 마우스 오른쪽 단추로 클릭하고 "찾아보기 ..."를 선택한 다음 Internet Explorer를 선택하고 "기본값으로 설정"을 클릭하십시오. 이제 VS에서 디버깅을 시작하면 IE가 팝업되고 자바 스크립트의 중단 점이 발생합니다.

0

이것은 단지 문자열입니다. visual sutdio에서 문자열을 디버깅 할 수 없습니다. 방화범

  • IE - - 개발자 도구 (F12)
  • 크롬 - 문자열은 문자열 : 당신은 디버깅 할 수 있습니다, 시계, 브라우저에서 아래 도구 등 중단 점을 추가

    1. 파이어 폭스 개발자 도구
    Internet Explorer에서
  • +0

    그러나 이것을 브라우저에 기록하면 jm2가 제안한대로 Visual Studio와 IE를 사용하여 디버깅 할 수 있습니다. –

    +0

    그가 Visual Studio에서 chkNewYorkFreeTradeZone.checked value를 (를) 볼 수있는 방법은 무엇입니까? Visual sutdio는 브라우저가 아닙니다 ... – Mehmet

    5
    1. : 도구 -> 인터넷 옵션 -> 고급

      의 선택을 취소 "지 , debugger;

    2. 프로젝트를 실행하고 Internet Explorer를 사용하여 웹 페이지를 엽니 수있는 스크립트 디버깅 (인터넷 익스플로러) (기타) "
      의 선택을 취소"스크립트 디버깅 사용 안 함 "자바 스크립트 스크립트의 어느 곳

    3. 이 추가 예 페이지를 클릭 디버깅하라는 메시지와 VS의 또 다른 예는 디버깅을 위해 열 때 :

      enter image description here

    관련 문제