473,654 Members | 3,280 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3305
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.com a é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.Componen tModel
Imports System.Web.UI

<ToolboxData("< {0}:ExportPanel runat=server>" _
+ "</{0}:ExportPanel >")_
Public Class ExportPanel
Inherits System.Web.UI.W ebControls.Pane l

#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("Behav ior"), DefaultValue("E xcel")_
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("Appea rance"), _
DefaultValue("F ile1")_
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("Behav ior"), DefaultValue("T rue")_
Public Property OpenInBrowser() As Boolean
Get
If ExportType = AppType.WordPer fect Then
'WordPerfect(ca n) '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.H tmlTextWriter)
If ExportType = AppType.HTML Then
MyBase.Render(o utput)
Else
'get rid of all the junk that's been
'rendered to the page so far
Page.Response.C lear()

'start a very simple html document
Page.Response.W rite("<html><he ad></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 = "applicatio n/ms-excel"
FileExtension = ".xls"
Case AppType.Word
.ContentType = "applicatio n/ms-word"
FileExtension = ".doc"
Case AppType.PowerPo int
.ContentType = "applicatio n/ms-powerpoint"
FileExtension = ".ppt"
Case AppType.WordPer fect
.ContentType = "applicatio n/wordperfect9"
FileExtension = ".wpd"
End Select
End With

'build full filename with extension (if necessary)
Dim FullFileName As String = FileName.Trim() .ToLower
If Not FullFileName.En dsWith(FileExte nsion) Then
FullFileName += FileExtension
End If

'Output the HTML header
Page.Response.A ddHeader("Conte nt-Disposition", _
OpenType + ";filename= " + FullFileName)

'Output the contents of the panel
MyBase.RenderCh ildren(output)

'End the HTML document
Page.Response.W rite("</body></html>")
Page.Response.E nd()
End If
End Sub

End Class

Reggie
"Patrice" <http://www.chez.com/scribe/wrote in message
news:3A******** *************** ***********@mic rosoft.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.com a é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
automaticall y 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
6717
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 am unable to figure out how to write to the file. Sam
15
2042
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 strings of empty size "" I thought it would be a good idea to share en empty string allocation between all uninitialized strings. However I have no idea where to place this constant? :-S I tried this:
10
2042
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 Inetpub/wwwroot/mywebsite/ Thanks.
10
2830
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 running down all the subs or functions that may contain these values, I'd like one place to change them and have that changed reflected in the subs or functions that use those values. I'd like to avoid globals; keeping the values private to only those...
10
4254
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. Because of this, I am unable to store these settings in the App.Config file, as this gets updated every time the application does, and there doesn't appear to be a way of preventing this. Most of my application settings are kept in the...
10
6813
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. IsolatedStorage is a good technique but it is for the each user only and is not machine level. Registry is not good because the user may not have access permission. Application directory is not good because the file could be deleted and so the...
24
5341
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 /site/html/Sigma.php /site/html/Common.php /site/html/Quickform.php /site/html/Quickform/
4
1736
by: 1230987za | last post by:
Hi, Let's say I have the following class: class foo { public: foo(); void addItem(int item); private:
1
1311
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 classes created by the LINQ to SQL I added them do the models. Not sure if this is the best place to add these classes or even the best way to do this.
0
8376
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8290
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8489
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8594
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5622
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2716
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1596
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.