473,382 Members | 1,147 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,382 software developers and data experts.

how to use cs files?

Dan
I know this is tupid but coming from a c++ background to asp.net in c# has
been a real awakening.

I have made my class and placed it in a .cs file but i do not know how i am
supposed to get my aspx pages to use that class when they run?

Could someone please help me in explaining how i programatically include a
cs file thanks.
Nov 19 '05 #1
8 1520
Dan,

CS files by themselves do not do much -- you can include them in an web
project, or a class library, and start using the classes they contain. So,
if you have a class within a CS file, it becomes a part of the library it is
in (either the web project, or a separate library).

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"Dan" <dv*******@aol.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
I know this is tupid but coming from a c++ background to asp.net in c# has
been a real awakening.

I have made my class and placed it in a .cs file but i do not know how i am supposed to get my aspx pages to use that class when they run?

Could someone please help me in explaining how i programatically include a
cs file thanks.

Nov 19 '05 #2
The .cs files are just containers for source code (modules). The code in
those files gets compiled into the project's assembly (.dll) which is
deployed, along with the .aspx files) to a web server.

In the .aspx files, there is a Page directive that includes an "Inherits"
clause. When a client requests a particular .aspx page, that page then
calls into the assembly and makes an instance of the class mentioned in the
..aspx file. From there, the page object can fire and respond to events and
run its compiled code.

You do not need/want to deploy the .cs files to the production web server as
these source code files get compiled into the final assembly.
"Dan" <dv*******@aol.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
I know this is tupid but coming from a c++ background to asp.net in c# has
been a real awakening.

I have made my class and placed it in a .cs file but i do not know how i
am supposed to get my aspx pages to use that class when they run?

Could someone please help me in explaining how i programatically include a
cs file thanks.

Nov 19 '05 #3
Hi Dan,

You need to compile the class file into a class library. Which is called an
assembly ( .dll ). In you visual studio make a reference to it. Also in your
code behind import it ( In C# using directive).

Create an object for the class in your code behin and you can access the
methods...

HTH,

Need any help, do post a msg back..

Happy Coding
"Dan" wrote:
I know this is tupid but coming from a c++ background to asp.net in c# has
been a real awakening.

I have made my class and placed it in a .cs file but i do not know how i am
supposed to get my aspx pages to use that class when they run?

Could someone please help me in explaining how i programatically include a
cs file thanks.

Nov 19 '05 #4
re:
I have made my class and placed it in a .cs file but i do not know how i
am supposed to get my aspx pages to use that class when they run?
You'd compile the .cs file with a command-line like :

csc /t:library /out:..\bin\YourClass.dll YourClass.cs /r:system.dll
/r:system.data.dll /r:system.xml.dll

And call it in your .aspx pages with a

<%@ Import Namespace="YourClassName" %>

Now, you can reference your methods with :

YourClassName.YourMethod

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Dan" <dv*******@aol.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...I know this is tupid but coming from a c++ background to asp.net in c# has
been a real awakening.

I have made my class and placed it in a .cs file but i do not know how i
am supposed to get my aspx pages to use that class when they run?

Could someone please help me in explaining how i programatically include a
cs file thanks.

Nov 19 '05 #5

Ypu can use Src attribute in @ Page directive, then toy .cs file will
compile on the fly then user requests a page.

<% @ Page Src="MyCSClass.cs" %>
--
Gaidar Magdanurov
VBStreets, Editor-in-Chief
mailto:ga****@vbstreets.ru / http://www.vbstreets.org

"Dan" <dv*******@aol.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
I know this is tupid but coming from a c++ background to asp.net in c# has
been a real awakening.

I have made my class and placed it in a .cs file but i do not know how i
am supposed to get my aspx pages to use that class when they run?

Could someone please help me in explaining how i programatically include a
cs file thanks.

Nov 19 '05 #6
As an additional note, you may want to configure the IIS to create the web
application for the subweb. (I believe using the root application is okay,
but I think it would be somehow more secure to create seperate application
if the page is located in a subweb, especially if you choose to prevent
upper level path access)

A web.config file may also be needed. (Not quite sure about this one.)

"Scott M." <s-***@nospam.nospam> ¦b¶l¥ó
news:uU**************@TK2MSFTNGP09.phx.gbl ¤¤¼¶¼g...
The .cs files are just containers for source code (modules). The code in
those files gets compiled into the project's assembly (.dll) which is
deployed, along with the .aspx files) to a web server.

In the .aspx files, there is a Page directive that includes an "Inherits"
clause. When a client requests a particular .aspx page, that page then
calls into the assembly and makes an instance of the class mentioned in the .aspx file. From there, the page object can fire and respond to events and run its compiled code.

You do not need/want to deploy the .cs files to the production web server as these source code files get compiled into the final assembly.
"Dan" <dv*******@aol.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
I know this is tupid but coming from a c++ background to asp.net in c# hasbeen a real awakening.

I have made my class and placed it in a .cs file but i do not know how i
am supposed to get my aspx pages to use that class when they run?

Could someone please help me in explaining how i programatically include a cs file thanks.


Nov 19 '05 #7
Talking about csc.exe, is there anyway to compile the whole site (including
the subdirs) into single DLL, just like what the VS.NET IDE would do, using
CSC without a makefile?

Just for curiosity...

"Juan T. Llibre" <no***********@nowhere.com> ¦b¶l¥ó
news:%2****************@TK2MSFTNGP12.phx.gbl ¤¤¼¶¼g...
re:
I have made my class and placed it in a .cs file but i do not know how i
am supposed to get my aspx pages to use that class when they run?


You'd compile the .cs file with a command-line like :

csc /t:library /out:..\bin\YourClass.dll YourClass.cs /r:system.dll
/r:system.data.dll /r:system.xml.dll

And call it in your .aspx pages with a

<%@ Import Namespace="YourClassName" %>

Now, you can reference your methods with :

YourClassName.YourMethod

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Dan" <dv*******@aol.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
I know this is tupid but coming from a c++ background to asp.net in c# hasbeen a real awakening.

I have made my class and placed it in a .cs file but i do not know how i
am supposed to get my aspx pages to use that class when they run?

Could someone please help me in explaining how i programatically include a cs file thanks.


Nov 19 '05 #8
Not with csc.exe, though, and you'll
need ASP.NET 2.0 to do it.

There's 2 ways to do that in ASP.NET 2.0 :

Pre-compiling a site in place and
pre-compiling a site for deployment.

See :
http://msdn.microsoft.com/asp.net/wh...etwhidbey.aspx
( Scroll down to "Pre-Compilation of Applications" )

and
http://pluralsight.com/blogs/fritz/a...1/11/3415.aspx

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:uJ*************@tk2msftngp13.phx.gbl...
Talking about csc.exe, is there anyway to compile the whole site
(including
the subdirs) into single DLL, just like what the VS.NET IDE would do,
using
CSC without a makefile?

Just for curiosity...

"Juan T. Llibre" <no***********@nowhere.com> ¦b¶l¥ó
news:%2****************@TK2MSFTNGP12.phx.gbl ¤¤¼¶¼g...
re:
> I have made my class and placed it in a .cs file but i do not know how
> i
> am supposed to get my aspx pages to use that class when they run?


You'd compile the .cs file with a command-line like :

csc /t:library /out:..\bin\YourClass.dll YourClass.cs /r:system.dll
/r:system.data.dll /r:system.xml.dll

And call it in your .aspx pages with a

<%@ Import Namespace="YourClassName" %>

Now, you can reference your methods with :

YourClassName.YourMethod

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Dan" <dv*******@aol.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
>I know this is tupid but coming from a c++ background to asp.net in c# has >been a real awakening.
>
> I have made my class and placed it in a .cs file but i do not know how
> i
> am supposed to get my aspx pages to use that class when they run?
>
> Could someone please help me in explaining how i programatically
> include a > cs file thanks.
>



Nov 19 '05 #9

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

Similar topics

2
by: Mike | last post by:
I am sure that I am making a simple boneheaded mistake and I would appreciate your help in spotting in. I have just installed apache_2.0.53-win32-x86-no_ssl.exe php-5.0.3-Win32.zip...
44
by: Xah Lee | last post by:
here's a large exercise that uses what we built before. suppose you have tens of thousands of files in various directories. Some of these files are identical, but you don't know which ones are...
0
by: Tom Lee | last post by:
Hi, I'm new to .NET 2003 compiler. When I tried to compile my program using DEBUG mode, I got the following errors in the C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7 \include\xdebug...
18
by: JKop | last post by:
Here's what I know so far: You have a C++ project. You have source files in it. When you go to compile it, first thing the preprocessor sticks the header files into each source file. So now...
3
by: pooja | last post by:
Suppose i have created a class c1 with f1()in c1.cpp and included this c1.cpp in file1.cpp file , which is also having main() by giving the statement #include "c1.cpp". the same i can do by...
11
by: ambika | last post by:
Iam just trying to know "c". And I have a small doubt about these header files. The header files just contain the declaration part...Where is the definition for these declarations written??And how...
22
by: Daniel Billingsley | last post by:
Ok, I wanted to ask this separate from nospam's ridiculous thread in hopes it could get some honest attention. VB6 had a some simple and fast mechanisms for retrieving values from basic text...
18
by: UJ | last post by:
Folks, We provide custom content for our customers. Currently we put the files on our server and people have a program we provide that will download the files. These files are usually SWF, HTML or...
0
by: wal | last post by:
How does one attach files to emails using libgmail? The following code http://pramode.net/articles/lfy/fuse/4.txt works fine when said files are simple text files, but it failes as soon as the...
3
by: aRTx | last post by:
I have try a couple of time but does not work for me My files everytime are sortet by NAME. I want to Sort my files by Date-desc. Can anyone help me to do it? The Script <? /* ORIGJINALI
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.