How do I reference my new class?

N

needin4mation

I have a .aspx file and it's src. I also have a third file, a class
that the src references. Everything is in the same directory/folder.
Everything has the same namespace. How do I reference the class in my
c# .src file? I don't believe this is an ASP.NET question, but a OOP
C# question, thus my post here.

I have searched and I thought it was with:

using FilterSQL; //the name of my class
using reports.FilterSQL; //name of namespace with class.

....

then on down I can instantiate it with

FilterSQL myFilter = new FilterSQL("");

I need to say that it was working until I took Visual Studio out of the
picture. I am trying to use notepad. And what happened was that I
took out my "codebehind" directive and used "src." Now, it can't find
the class.

Thank you for any help. I think not using VIsual Studio here might
actually be a good thing. I might learn what's going on.
 
D

Daniel

"using" in the context you are using it for is for including a namespace not
individual class names.

The codebehind is needed to tell the asp.net page where its code fine is,
put codebehind back.

So ref the class you do it as you would any class and your line of code is
correct. You would then use myFiler.someMethod() etc now that you have
created an instance of your class.

Make sense? What you written is all fine aside from the misuse of using and
the removal of codebehin, but you knew that broke it so not really sure why
or where you are stuck?
 
N

needin4mation

If I use codebehind, which is for Visual Studio as I understand it,
then I require the DLL. I do not want to use the DLL. I want to use
the .cs source file, so I am using src=. I am not using VS at the
moment. That is why I took the codebehind out and now I can't
reference the class.
 
J

Jianwei Sun

If I use codebehind, which is for Visual Studio as I understand it,
then I require the DLL. I do not want to use the DLL.

[What do you mean here of the DLL ?? Visual Studio is just an IDE to
improve your efficiency, it will use the same way to compile the code as
you will use on the command line.]



I want to use
 
N

needin4mation

Jianwei said:
If I use codebehind, which is for Visual Studio as I understand it,
then I require the DLL. I do not want to use the DLL.

[What do you mean here of the DLL ?? Visual Studio is just an IDE to
improve your efficiency, it will use the same way to compile the code as
you will use on the command line.]

If I use Visual Studio and build a web app. It creates a DLL in the
\bin directory. I do not want the DLL library. Instead, I just want
the asp.net c# page to use the src instead of codebehind.

Page1 up top, page directive, instead of codebehind="Page1.aspx.cs", I
have src="Page1.aspx.cs" The codebehind is for Visual Studio. Src is
for runtime to tell it to use the source code file (not the DLL). I
can change that and it will work fine src=works fine.

What I cannot do now is reference the classes that are not part of the
..cs file. They are class files outside of the .aspx.cs page. They are
standalone class files. I believe in Java all they had to do was be in
the same directory to be imported, but for some reason I cannot
reference them.
 
N

needin4mation

I suppose I can take the code out of my class and put it in each file
that needs it, but that is not the correct way to proceed, I am sure.
 
D

Daniel

Why are you so against using a dll? A dll is the way to go and is not a bad
thing. During development it will be a cs file once compiled a dll is
created but it is still, referencing inside the dll.

Use codebhind, and it works. Why you are so aginst this i do not know. You
are creating the problem here. Sounds like your stuck in java world which i
think is why your struggling. Unlearn what you have learnt ;) use codebhind,
dont question what workd and use the compiled dll. At deployment you will
never use a cs file.

If you can't take the advice, there is no use trying to help you further
'cause your gonan fight it and fight it and come back to this conclusion. If
you don't, then well, don't give up the day job.

And on another note. WHY are you using notepad? While your at it, turn off
your computer, get out a pen and paper. You seem to want to make simple
things complicated?

Seriously, think about it.
 
N

needin4mation

I do not understand the offence here. I merely asked a question to see
how it would work.

The advice, I understand, is free, and I respect that. But I simply
cannot use the dll. There are various reasons, but suffice it to say
that I cannot migrate my 1.1 server to 2.0 at this time. I cannot get
2005 to work right. I want to change one line of sql code to get a
query to work and I because I can't get eveything to compile into the
dll the way I normally do (notepad is fine for a single line of code
change). I wanted a workaround because I want everything to work. I
found that I could use the src directive and that this would do what I
needed until I can get everything working normally. It is not a
mattter of being argumentative, foolish, or just plain stupid. I need
to know. I can't always have everything working perfectly.

Yes, in Java the class can be referenced because it is in the same
directory. That is what I thought C# would allow. Apparently that is
wrong. That is why I asked the question. I would have thought this
would be a very basic question, but it appears to be a difficult one.
I simply want to instantiate a class that resides in a different file
than the cs source file of the aspx page. I thought it would be easy
for those who were more familar with the language and .net platform.

Don't get me wrong, I am thankful for any help, but I really don't get
the problem here. I have my reasons for asking the question. Under
normal circumstances I would proceed normally. I can't in this case.
 
D

Daniel

No one is offended, but your IGNORING the answer. Its like saying 1 + 1 what
does it equal? it seems to equal 2 but it cant do can someone help?

Then we all yell back IT DOES EQUAL 2....and you reply, but it can't.

Thats how it feels.

The fact you think you cannot use a dll as your server is on 1.1 of .net
shows some serious misunderstadning, form my experience the people that
question everything are the slowest to learn and your one of them.

I might edit one line of code, i'd still fire up visual studio so i can edit
and compile.

We have given you the answer.

Don't take this as insults towards you, this is constructive criticism. just
do it how it is supposed t be. your problems seem to be from a lack of
fundamental understanding here.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top