|
-
Mar 28th, 2004, 08:18 AM
#1
Thread Starter
Retired VBF Adm1nistrator
When should I use Response.Write() ?
The problem I'm having, is that my page is outputting my data, before the <html> ... </html> tags. So, my stuff comes out, and then IIS is sending out the normal HTML content.
How can I have my page output data inside the html and body tags ?
VB Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strArr() As String : strArr = Split(Request.QueryString("Code"), ",")
Dim strTableName As String, strSQLStatement
Dim myConnection As New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim lngTemp As Long : myConnection.Open()
Select Case strArr(0)
Case "1" : strTableName = "tblMasterHeaders"
Case "2" : strTableName = "tblSecondaryHeaders"
Case "3" : strTableName = "tblThirdHeaders"
Case "4" : strTableName = "tblThirdHeaders"
End Select
lngTemp = strArr(0)
If Not strTableName = vbNullString Then
strSQLStatement = "SELECT * FROM " & strTableName & vbCrLf
If Not strTableName = "tblMasterHeaders" Then
If strArr(0) = 4 Then
strSQLStatement += "WHERE lngCurrentIndex = " & strArr(1)
Else
strSQLStatement += "WHERE lngParentIndex = " & strArr(1)
End If
End If
Dim myCommand As New SqlCommand(strSQLStatement, myConnection)
Dim myReader As SqlDataReader : myReader = myCommand.ExecuteReader()
Try
While myReader.Read()
If lngTemp = 1 Then
[b] Response.Write(strGenerateHeaderLink(2, strArr(1), myReader.GetValue(2)) & vbCrLf & vbCrLf)[/b]
ElseIf lngTemp = 2 Then
[b] Response.Write(strGenerateHeaderLink(3, myReader.GetValue(0), myReader.GetValue(2)) & vbCrLf)[/b]
ElseIf lngTemp = 3 Then
[b] Response.Write(strGenerateHeaderLink(4, myReader.GetValue(0), myReader.GetValue(2)) & vbCrLf)[/b]
ElseIf lngTemp = 4 Then
Dim strSAPCodes() As String = Split(myReader.GetValue(3), ",")
Response.Write(strSendComment("start of productTableHeader.html"))
Response.WriteFile("productTableHeader.html")
Response.Write(strSendComment("end of productTableHeader.html"))
Dim strTableLocation As String
strTableLocation += "<tr>" & vbCrLf
strTableLocation += "<td width=" & Chr(34) & "90%" & Chr(34) & " colspan=" & Chr(34) & 5 & Chr(34) & ">" & strDoFormatting(Replace(strGetProduct(strSAPCodes(0), modMisc.prodDetailsEnum.strSectionText), "|", " >> ")) & "</td>" & vbCrLf
strTableLocation += "</tr>" & vbCrLf
Response.Write(strTableLocation)
Dim i As Long
For i = 0 To UBound(strSAPCodes)
Response.Write(strGetProductDescriptionBySAPCode(strSAPCodes(i)) & vbCrLf)
Next
Response.Write(strSendComment("start of productTableFooter.html"))
Response.WriteFile("productTableFooter.html")
Response.Write(strSendComment("end of productTableFooter.html"))
End If
End While
Finally
myReader.Close()
myConnection.Close()
End Try
End If
End Sub
The above code is coming out as :
Code:
<a href="ProductGroup.aspx?Code=2,1">Backup Solutions</b><br><a href="ProductGroup.aspx?Code=2,2">Boards (video, sound, .)</b><br><a href="ProductGroup.aspx?Code=2,3">CAD Peripherals</b><br><a href="ProductGroup.aspx?Code=2,4">CAD Software</b><br><a href="ProductGroup.aspx?Code=2,5">Connectivity (hub, switch, router,.)</b><br><a href="ProductGroup.aspx?Code=2,6">Courses & Training</b><br><a href="ProductGroup.aspx?Code=2,7">CPU, memory, SIMMs,.</b><br><a href="ProductGroup.aspx?Code=2,8">Drives (FD, HD, etc.)</b><br><a href="ProductGroup.aspx?Code=2,9">Entertainment Software</b><br><a href="ProductGroup.aspx?Code=2,10">Extended Warranty</b><br><a href="ProductGroup.aspx?Code=2,11">Handhelds & Notepads</b><br><a href="ProductGroup.aspx?Code=2,12">Keyboards, Mice, etc.</b><br><a href="ProductGroup.aspx?Code=2,13">Monitors & Displays</b><br><a href="ProductGroup.aspx?Code=2,14">Networking Hardware</b><br>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title></title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
</body>
</HTML>
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|