Setting Content Type No Longer Returns Dynamic Controls

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">
<asp:placeHolder ID="OutputArea"
Runat="server"></asp:placeHolder>
</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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top