Thanks Patrice. My bad. I miss-interpreted what was said here
http://msdn.microsoft.com/en-us/library/t990ks23(VS.80).aspx. It said you
can place the compiled assembly in the bin folder, and other code anywhere
in the Web application (such as code for pages) automatically references it.
That being said, when I compile the component and add it to the bin directy
and build the project it bombs out until I manually add the reference. At
the site above it doesn't mention that you have to add the reference. Is it
because I use it in my web page (aspx) file. It's basically a panel control
that I place things in such a gridviews that I want to export. I got this
somewhere on the web Can't remeber exactly where. The code is below. The
only reason I ask, is because I build the assemblies remotely, then ftp them
to the server to the bin folder, but I don't have access to perform the
reference manually unless there's some way to programatically do it. I will
do some research on the difference between the Web Site app proj and the Web
App Proj. Wasn't aware there is 2 different models. My app was originally
built in VS2003 now using VS2005 and as you made me aware I guess mine is a
Web App Proj. How did you know that? Is there a way to tell? Thanks again
for all your help/time!
Imports System.ComponentModel
Imports System.Web.UI
<ToolboxData("<{0}:ExportPanel runat=server>" _
+ "</{0}:ExportPanel>")> _
Public Class ExportPanel
Inherits System.Web.UI.WebControls.Panel
#Region " Public Properties "
'Contains the list of supported export applications
Public Enum AppType
HTML
Word
Excel
PowerPoint
WordPerfect
End Enum
'Manage the requested export type
Private m_ExportType As AppType
<Bindable(True), Category("Behavior"), DefaultValue("Excel")> _
Public Property ExportType() As AppType
Get
Return m_ExportType
End Get
Set(ByVal Value As AppType)
m_ExportType = Value
End Set
End Property
'Filename property
Dim m_FileName As String = "File1"
<Bindable(True), Category("Appearance"), _
DefaultValue("File1")> _
Public Property FileName() As String
Get
Return m_FileName
End Get
Set(ByVal Value As String)
m_FileName = Value
End Set
End Property
'Open the application externally or host in the browser?
Private m_OpenInBrowser As Boolean = True
<Bindable(True), Category("Behavior"), DefaultValue("True")> _
Public Property OpenInBrowser() As Boolean
Get
If ExportType = AppType.WordPerfect Then
'WordPerfect(can) 't be hosted inside IE
Return False
Else
If ExportType = AppType.HTML Then
'HTML will always be displayed
'on the current page.
Return True
Else
Return m_OpenInBrowser
End If
End If
End Get
Set(ByVal Value As Boolean)
m_OpenInBrowser = Value
End Set
End Property
#End Region
Protected Overrides Sub Render(ByVal output As _
System.Web.UI.HtmlTextWriter)
If ExportType = AppType.HTML Then
MyBase.Render(output)
Else
'get rid of all the junk that's been
'rendered to the page so far
Page.Response.Clear()
'start a very simple html document
Page.Response.Write("<html><head></head><body>")
'determine whether to open the document inside
'the browser or to an launch external app
Dim OpenType As String = "inline"
If OpenInBrowser = False Then OpenType = "attachment"
'determine the content type and file extension
Dim FileExtension As String = ""
With Page.Response
Select Case ExportType
Case AppType.Excel
.ContentType = "application/ms-excel"
FileExtension = ".xls"
Case AppType.Word
.ContentType = "application/ms-word"
FileExtension = ".doc"
Case AppType.PowerPoint
.ContentType = "application/ms-powerpoint"
FileExtension = ".ppt"
Case AppType.WordPerfect
.ContentType = "application/wordperfect9"
FileExtension = ".wpd"
End Select
End With
'build full filename with extension (if necessary)
Dim FullFileName As String = FileName.Trim().ToLower
If Not FullFileName.EndsWith(FileExtension) Then
FullFileName += FileExtension
End If
'Output the HTML header
Page.Response.AddHeader("Content-Disposition", _
OpenType + ";filename=" + FullFileName)
'Output the contents of the panel
MyBase.RenderChildren(output)
'End the HTML document
Page.Response.Write("</body></html>")
Page.Response.End()
End If
End Sub
End Class
Reggie
Patrice said:
It depends on the project model you are using. With the model you are
using (Web Application Project) all the code is compiled into a single DLL
so you have nothing special to do.
Humm... not sure but never heard about this automatic reference thing. IMO
it would be rather the other way round i.e. when you make a reference and
copy local is true then the DLL is copied into the bin directory. So this
is placed in bin because it is referenced (and not referenced because
placed in bin).
App_Code is for Web Site application project (compiled into multiple DLLs
so general code has to be placed at this particular location).
See :
http://msdn.microsoft.com/en-us/library/aa730880(VS.80).aspx for a
detailed discussion.