Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > how to use cs files?

Reply
Thread Tools

how to use cs files?

 
 
Dan
Guest
Posts: n/a
 
      03-06-2005
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.


 
Reply With Quote
 
 
 
 
Manohar Kamath
Guest
Posts: n/a
 
      03-06-2005
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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.
>
>



 
Reply With Quote
 
 
 
 
Scott M.
Guest
Posts: n/a
 
      03-06-2005
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>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.
>



 
Reply With Quote
 
=?Utf-8?B?VmlzaG51LUNoaXZ1a3VsYQ==?=
Guest
Posts: n/a
 
      03-06-2005
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.
>
>
>

 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      03-06-2005
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隳l
Ven, y hablemos de ASP.NET...
======================

"Dan" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>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.
>



 
Reply With Quote
 
gaidar
Guest
Posts: n/a
 
      03-06-2005

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
(E-Mail Removed) / http://www.vbstreets.org

"Dan" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>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.
>



 
Reply With Quote
 
Lau Lei Cheong
Guest
Posts: n/a
 
      03-07-2005
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." <(E-Mail Removed)> 在郵件
news:(E-Mail Removed) 中撰寫...
> 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" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> >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.
> >

>
>



 
Reply With Quote
 
Lau Lei Cheong
Guest
Posts: n/a
 
      03-07-2005
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" <(E-Mail Removed)> 在郵件
news:%(E-Mail Removed) 中撰寫...
> 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隳l
> Ven, y hablemos de ASP.NET...
> ======================
>
> "Dan" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> >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.
> >

>
>



 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      03-07-2005
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隳l
Ven, y hablemos de ASP.NET...
======================

"Lau Lei Cheong" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> 在郵件
> news:%(E-Mail Removed) 中撰寫...
>> 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隳l
>> Ven, y hablemos de ASP.NET...
>> ======================
>>
>> "Dan" <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>> >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.
>> >

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Could not use ''; file already in use. M K ASP .Net 11 04-09-2008 11:35 AM
where to use CPLD & where to use FPGA? kulkarku@math.net VHDL 6 03-06-2006 07:27 AM
How do I know when to use the Viewstate and when to use the posted data? :-) Simon ASP .Net 1 11-09-2004 02:32 AM
Can I use XPath or something to a remote Mac or Linux box and just query an xml file, not using web services and use encyrption? jake ASP .Net 0 07-06-2004 02:16 PM
Cannot use the profile "default" because it is in use, not. please.post@yur.re.ply Firefox 1 07-04-2004 03:41 AM



Advertisments