8

I've got some debug msgs (written via Response.Write()) that I can see when I do a "View Source" like so (within VB code):

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()

-and (within hmtl):

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

I can see these messages when I go to the page and "View Source"

But I have other similar instances that are not being written out, such as:

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

I know this block is bring reached, because the logic in it is taking place (database inserts).

Why would the Response.Write() not always work?

B. Clay Shannon
  • 1,055
  • 124
  • 399
  • 759
  • 1
    Try putting response right at the end of the function and see if it makes any difference? It might be doing a micro reload and you dont notice. – Deckerz Mar 17 '17 at 16:55

2 Answers2

1

Is your page reloading or redirecting after the Save? That would explain it.

Chalky
  • 1,435
  • 14
  • 20
1

Is your HTML comment line being appended to other text in the Response?

If so, it might be rendered far to the right (out of sight) in your "View Source" display.

Try to insert carriage return - line feed characters before and after this text.

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

If this is the problem, doing a Ctrl-F find in the "View Source" display may reveal this comment line.

JohnH
  • 1,646
  • 1
  • 22
  • 27