-3

次のJavascriptはVisualStudioのaspx.csにあり、新しいスクリプトを追加しましたが、スクリプトが正しく機能しているかどうかわかりません。次のコードをデバッグする方法を教えてください。 ...。

  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("}");
4

4 に答える 4

5
  1. Internet Explorer の場合: [ツール] -> [インターネット オプション] -> [詳細設定]

    「スクリプトのデバッグを無効にする (Internet Explorer)」
    のチェックを外す 「スクリプトのデバッグを無効にする (その他) 」のチェックを外す

  2. JavaScript スクリプトの任意の場所に、次を追加します。debugger;

  3. プロジェクトを実行し、Internet Explorer を使用して Web ページを開きます。ページをデバッグするように求められたら、[はい] をクリックします。VS の別のインスタンスがデバッグ用に開きます。

    ここに画像の説明を入力

于 2012-07-26T20:24:21.453 に答える
3

Firefox とFirebugプラグインを使用して、JavaScript を簡単にデバッグします。

于 2012-07-26T19:59:07.743 に答える
1

VS2008以降ではJavaScriptを直接デバッグできますが、デバッグ用のデフォルトのブラウザーとしてInternetExplorerを使用する必要があります。
IEが現在デフォルトのブラウザでない場合は、ソリューションエクスプローラーでファイルを右クリックし、[参照...]を選択し、Internet Explorerを選択して、[デフォルトとして設定]をクリックします。これで、VSでデバッグを開始すると、IEがポップアップし、javascriptのブレークポイントがヒットします。

于 2012-07-26T20:04:13.620 に答える
0

これは単なる文字列です。visualsutdioから文字列をデバッグすることはできません。string is string :)ブラウザの以下のツールを使用して、デバッグ、監視、ブレークポイントの追加などを行うことができます。

  1. Firefox-Firebug
  2. IE-開発ツール(F12)
  3. Chrome-開発者ツール
于 2012-07-26T20:07:08.977 に答える