在Visual Studio中调试Javascript
下面的Javascript是在我的aspx.cs中的Visual Studio中,我已经添加了一个新的脚本,但我不确定我的脚本是否正常工作或没有..so可以请某人告诉我如何调试下面的代码....在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("}");
您可以在VS2008及更高版本中直接调试javascript,但必须使用Internet Explorer作为默认浏览器进行调试。
如果IE目前不是您的默认浏览器,请右键单击解决方案资源管理器中的文件,选择“浏览...”,选择Internet Explorer,然后单击“设为默认值”。现在,当你开始在VS中进行调试时,IE会弹出并在javascript中产生断点。
这只是一个字符串。您无法从visual sutdio调试字符串。字符串是字符串:) 可以调试,手表,在浏览器中添加断点等下面的工具
- Firefox的 - 萤火
- IE - 开发工具(F12)
- 浏览器 - 开发工具
然而,当它被写入浏览器时,他可以使用visual studio和IE作为jm2的建议进行调试。 – 2012-07-26 20:31:34
他如何使用visual studio观看chkNewYorkFreeTradeZone.checked值? Visual sutdio不是浏览器... – Mehmet 2012-07-26 20:45:00
-
在Internet Explorer中:工具 - > Internet选项 - >高级
取消“派息能够脚本调试器(Internet Explorer)”
取消选中 “禁止脚本调试(其他)” 任何地方在你的JavaScript脚本,补充一点:
debugger;
-
运行该项目,并使用Internet Explorer打开网页,当提示调试页面点击Yes和VS的另一个实例将打开调试:
如果您不知道剧本是否正常工作,其他人怎么知道? – 2012-07-26 20:00:06
简单,把你的JavaScript,把它放在一个JS文件,并且不要混合和匹配编程语言。 – zzzzBov 2012-07-26 20:02:17
@ChristoferEliasson ...那是我的问题是关于我从来没有在Visual Studio中使用java脚本。所以我不知道天气我错过了sometng与我的通知....... – user1552588 2012-07-26 20:09:38