为什么我的调试信息没有写入我的页面?

时间:2017-03-07 00:34:01

标签: html vb.net response.write view-source

我有一些调试消息(通过Response.Write()编写),当我执行“查看源代码”时,我可以看到(在VB代码中):

currentYear = Year(Now)
SQLString = "Select NewBiz from MasterUnitsprojSales where CYear = " & currentYear & " and Unit = '" & Unit & "'"
adoRS = New ADODB.Recordset
adoRS.Open(SQLString, adoCon)
IsNewBusiness = TRUE 'default (if record not found)
Category = "New Business"
If Not adoRS.EOF Then
    IsNewBusiness = adoRS.Fields.Item(0).Value <> 0 
    if Not IsNewBusiness
            Category = "Existing Business"
    End If
    Response.Write("<!-- IsNewBusiness after NOT EOF assignment = " & CStr(IsNewBusiness) & "-->")
End If
adoRS.Close()

- 和(在hmtl内):

<% Response.Write("<!-- Is New Biz = " & IsNewBusiness & "-->") %>

当我转到页面和“查看来源”时,我可以看到这些消息

但是我还有其他类似的实例没有被写出来,例如:

If Request.Form.Item("Action") = "Save" Then
    Response.Write("<!-- Made it into the Action =Save block -->")
    . . .

我知道这个块已经到达,因为它中的逻辑正在发生(数据库插入)。

为什么Response.Write()并不总是有效?

2 个答案:

答案 0 :(得分:1)

保存后,您的页面是重新加载还是重定向?这可以解释它。

答案 1 :(得分:1)

您的HTML注释行是否会附加到响应中的其他文本?

如果是这样,它可能会在您的&#34;查看来源&#34;中向右(远离视线)呈现。显示。

尝试在此文本之前和之后插入回车换行符。

Response.Write(vbCrLf + "<!-- Made it into the Action =Save block -->" + vbCrLf)

如果这是问题,请在&#34;查看来源&#34;中执行Ctrl-F查找显示可能会显示此评论行。