473,406 Members | 2,345 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Where to place class file

Hi and TIA! I have a class file located in my root directory with all me
web pages. I call/use the class and it works fine. I have no imports
statements aspx or codebehind. My question is why? I thought the class file
had to be compiled and placed in the bin directory or added to the
App_Code(as a class file) folder. I don't have it in either it's simply in
the root. Now When I compile it and place the dll in the bin and remove the
class file from the root it doesn't work until I also manually add a
reference to it in References. This brings me to another question. I read
that when you place it in the bin directory a reference is automatically
added. That doesn't happen for me. I have to manually add the reference.
And one more question(for now). You are supposed to be able to right click
the project select add/add aspnet folder/App_Code. When I do this the
App_Code file is in the list of options. I can obviously manually add the
folder, but thought this was odd. Thanks for any insight.

--

Reggie

Oct 29 '08 #1
2 3280
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/libr...80(VS.80).aspx for a detailed
discussion.

--
Patrice
"Reggie" <No*****************@yahoo.coma écrit dans le message de groupe
de discussion : uu**************@TK2MSFTNGP04.phx.gbl...
Hi and TIA! I have a class file located in my root directory with all me
web pages. I call/use the class and it works fine. I have no imports
statements aspx or codebehind. My question is why? I thought the class
file had to be compiled and placed in the bin directory or added to the
App_Code(as a class file) folder. I don't have it in either it's simply
in the root. Now When I compile it and place the dll in the bin and
remove the class file from the root it doesn't work until I also manually
add a reference to it in References. This brings me to another question.
I read that when you place it in the bin directory a reference is
automatically added. That doesn't happen for me. I have to manually add
the reference. And one more question(for now). You are supposed to be
able to right click the project select add/add aspnet folder/App_Code.
When I do this the App_Code file is in the list of options. I can
obviously manually add the folder, but thought this was odd. Thanks for
any insight.

--

Reggie

Oct 29 '08 #2
Thanks Patrice. My bad. I miss-interpreted what was said here
http://msdn.microsoft.com/en-us/libr...23(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" <http://www.chez.com/scribe/wrote in message
news:3A**********************************@microsof t.com...
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/libr...80(VS.80).aspx for a
detailed discussion.

--
Patrice
"Reggie" <No*****************@yahoo.coma écrit dans le message de groupe
de discussion : uu**************@TK2MSFTNGP04.phx.gbl...
>Hi and TIA! I have a class file located in my root directory with all me
web pages. I call/use the class and it works fine. I have no imports
statements aspx or codebehind. My question is why? I thought the class
file had to be compiled and placed in the bin directory or added to the
App_Code(as a class file) folder. I don't have it in either it's simply
in the root. Now When I compile it and place the dll in the bin and
remove the class file from the root it doesn't work until I also manually
add a reference to it in References. This brings me to another question.
I read that when you place it in the bin directory a reference is
automatically added. That doesn't happen for me. I have to manually add
the reference. And one more question(for now). You are supposed to be
able to right click the project select add/add aspnet folder/App_Code.
When I do this the App_Code file is in the list of options. I can
obviously manually add the folder, but thought this was odd. Thanks for
any insight.

--

Reggie

Oct 30 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Sam Carleton | last post by:
It is my understanding that in .Net the registry is not the prefered place to save application settings. What has Microsoft put in place to replace it? I thought it was the .config file, but I...
15
by: Lasse Skyum | last post by:
I have my own string class that I'm generally verry fond of compared to std::string. For that same reason I'm trying to improve a little on it. Since manny objects in my project will contain...
10
by: vwd2005eeb | last post by:
Visual Web Developer 2005 Express Edition Beta I did Build | Build Web site, where are the DLLs? I was expecting to see maybe one dll for each Web page in a directory (maybe still "bin") under...
10
by: Brett | last post by:
If I have many hard coded values such as file paths, file names, timeouts, etc, where is the best place to define them? Meaning, in the case something needs changing for example, rather than...
10
by: Paul Cheetham | last post by:
Hi, I am developing an application that needs to store some machine-specific settings. The application is going to be published on the network in order to keep the clients on the latest version....
10
by: Mike9900 | last post by:
Hello, I would like to store application expiration date in a file and store that file in a secure place, so the application can access the file for all the users on that computer. ...
24
by: Paul | last post by:
I am taking over an existing app and having trouble understanding their references. They have encapsulated Pear packages in the directory structure like: /site /site/html/Pear.php...
4
by: 1230987za | last post by:
Hi, Let's say I have the following class: class foo { public: foo(); void addItem(int item); private:
1
by: shapper | last post by:
Hello, On my ASP.NET MVC project I create ViewData classes to pass information from the controller to the view. Where should I place the view data classes? Since they kind of reshape the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.