Why is my debug msg not writing to my page?

I have a debug msgs (written via Response.Write ()) that I can see when I do "View Source", like this (in 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 (inside 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 recorded, for example:

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

I know that this block is reached because the logic in it happens (inserts the database).

Why doesn't Response.Write () always work?

+8
html view-source
source share
2 answers

Is your HTML comment line added to other text in the response?

If so, it can be displayed to the right (out of sight) on the "View Source" screen.

Try inserting carriage return characters before and after this text.

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

If this is a problem, then searching for Ctrl-F on the Source View screen may open this comment line.

+1
source share

Does your page reload or redirect after saving? That would explain it.

+1
source share

All Articles