A
Andy
I have a web page that contains a place holder control.
I create a table in code and add it to the place holder
controls collection and the table displays correctly in
html. If I set the mime type to return a word document the
table is never created. If I add any text using
response.write it returns fine. I have no idea where to
begin researching this problem. Any ideas would be greatly
appreciated.
Thanks.
---- Simple Example Code Below -----
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="TestForm8.aspx.vb"
Inherits="Version001.TestForm8"%>
<HTML>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post"
runat="server">
<asplaceHolder ID="OutputArea"
Runat="server"></asplaceHolder>
</form>
</body>
</HTML>
Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim tbl As New WebControls.Table
Dim msg As String
Dim MakeWord As Boolean
MakeWord = True
If MakeWord = True Then
Response.AddHeader("Content-
Disposition", "attachment; filename=WordDoc.doc")
Response.ContentType = "application/msword"
Response.Charset = ""
msg = ""
'based on this kb article
'http://support.microsoft.com/kb/318756/EN-US/
Else
msg = "Change MakeWord value to true to create
a word document by setting mime type. The dynamic table
will not show but response.write text will be fine."
End If
tbl.Rows.Add(New TableRow)
tbl.Rows(0).Cells.Add(New TableCell)
tbl.Rows(0).Cells(0).Text = "Dynamic Created
Table -- I will disappear when content type set to word."
OutputArea = Page.FindControl("OutputArea")
OutputArea.Controls.Add(tbl)
Response.Write("Response.Write Line -- You can
always see me.")
If MakeWord = True Then
Response.End()
Else
Response.Write("<br>" & msg)
End If
End Sub
I create a table in code and add it to the place holder
controls collection and the table displays correctly in
html. If I set the mime type to return a word document the
table is never created. If I add any text using
response.write it returns fine. I have no idea where to
begin researching this problem. Any ideas would be greatly
appreciated.
Thanks.
---- Simple Example Code Below -----
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="TestForm8.aspx.vb"
Inherits="Version001.TestForm8"%>
<HTML>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post"
runat="server">
<asplaceHolder ID="OutputArea"
Runat="server"></asplaceHolder>
</form>
</body>
</HTML>
Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim tbl As New WebControls.Table
Dim msg As String
Dim MakeWord As Boolean
MakeWord = True
If MakeWord = True Then
Response.AddHeader("Content-
Disposition", "attachment; filename=WordDoc.doc")
Response.ContentType = "application/msword"
Response.Charset = ""
msg = ""
'based on this kb article
'http://support.microsoft.com/kb/318756/EN-US/
Else
msg = "Change MakeWord value to true to create
a word document by setting mime type. The dynamic table
will not show but response.write text will be fine."
End If
tbl.Rows.Add(New TableRow)
tbl.Rows(0).Cells.Add(New TableCell)
tbl.Rows(0).Cells(0).Text = "Dynamic Created
Table -- I will disappear when content type set to word."
OutputArea = Page.FindControl("OutputArea")
OutputArea.Controls.Add(tbl)
Response.Write("Response.Write Line -- You can
always see me.")
If MakeWord = True Then
Response.End()
Else
Response.Write("<br>" & msg)
End If
End Sub