在visualstudio中调试Javascript
下面的Javascript在我的visual studio中的aspx.cs中,我已经添加了一个新脚本,但我不确定我的脚本是否正常工作..所以请告诉我如何调试下面的代码在visualstudio中调试Javascript,javascript,asp.net,Javascript,Asp.net,下面的Javascript在我的visual studio中的aspx.cs中,我已经添加了一个新脚本,但我不确定我的脚本是否正常工作..所以请告诉我如何调试下面的代码 sb.AppendFormat("function chkQuoteBinderValidUntilDateOverridden_OnClick()", this.chkQuoteBinderValidUntilDateOverridden.ClientID); sb.AppendLine("{");
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("}");
使用Firefox和插件可以轻松调试JavaScript。您可以在VS2008或更高版本中直接调试JavaScript,但必须使用Internet Explorer作为默认浏览器进行调试
如果IE当前不是您的默认浏览器,请右键单击解决方案资源管理器中的文件,选择“浏览…”,选择Internet Explorer并单击“设置为默认”。现在,当您开始在VS中调试时,IE将弹出,javascript中的断点将被命中。这只是一个字符串。无法从visual sutdio调试字符串。字符串是字符串:) 您可以在浏览器上使用以下工具调试、监视、添加断点等
取消选中“禁用脚本调试(其他)”
debugger代码>
如果您不确定脚本是否正常工作,其他人怎么知道?简单,使用javascript,将其放入JS文件中,不要混用和搭配编程语言。@ChristofReliasson…这是我的问题,我从来没有在Visual studio中使用过java脚本。所以我不确定我是否在没有通知的情况下错过了一些东西。@ZZZBOV谢谢你的帮助Chrome也一样,没有任何插件…还有IE使用开发者工具。虽然我更喜欢Chrome。我喜欢Chrome的开发工具,但Firebug仍然是我首选的JavaScript调试器。每次出现这个问题,都会有人用“使用Firebug”来回答。虽然Firebug是一个很棒的工具(我使用它比使用VS进行js调试更多),但它并没有解决眼前的问题。眼前的问题是“如何调试此JavaScript“。碰巧JS是在后台代码中写入的,但最终它将显示在浏览器上,然后可以使用Firebug或其他浏览器工具进行调试。但是,当这写入浏览器时,他可以按照jm2的建议使用visual studio和IE进行调试。他如何使用visual studio观看chkNewYorkFreeTradeZone.checked值?Visual sutdio不是浏览器。。。