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

How do I call my class file?

Hello,
I have created a class file: Admin.cs with a namespace
of cs101.Code.nsAdmin.

From my ASP page: Login.aspx.cs how do I reference
Admin and then execute one of its methods
"public DataRow RetrieveUserbyUserNameNPassword(string
userName, String password)" ?
Charles

Nov 15 '05 #1
4 2178
You include it's namespace in Login.aspx.cs

using cs101.Code.nsAdmin;

then you call the methods in Admin.cs

cs101.Code.nsAdmin.Method1();

A better way for long namespaces would be to use aliasing

using Admin = cs101.Code.nsAdmin;
Admin.Method1();

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 15 '05 #2
In your case, it would be (provided you use Admin as an alias for
cs101.Code.nsAdmin)

DataRow row = Admin.RetrieveUserbyUserNameNPassword(username, password);

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 15 '05 #3
Hello,

I did:

using cs101.Code.nsAdmin;
at the top of Login.aspx.cs

and:
DataRow drUser =
cs101.Code.nsAdmin.Admin.RetrieveUserbyUserNameNPa ssword( UserName.Text,
Password.Text );

inside my click event, the error I get is:
"An object reference is required for the nonstatic field, method, or
property
'cs101.Code.nsAdmin.Admin.RetrieveUserbyUserNameNP assword(string,
string)'

what did I do wrong?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #4

Hi Charles,

Is your RetrieveUserbyUserNameNPassword method a non-static method member
of a certain class?
If it is, you should create a instance of this class and use this
new-created object to call this method.

Hope this helps,
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: Charles Wildner <cw******@bellsouth.net>
| References: <oprvulvjqrge0n9a@localhost>
| X-Newsreader: AspNNTP 1.50 (ActionJackson.com)
| Subject: Re: How do I call my class file?
| Mime-Version: 1.0
| Content-Type: text/plain; charset="us-ascii"
| Content-Transfer-Encoding: 7bit
| Message-ID: <O2**************@TK2MSFTNGP11.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Date: Sun, 21 Sep 2003 07:43:05 -0700
| NNTP-Posting-Host: actionjackson133.dsl.frii.net 216.17.147.133
| Lines: 1
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP11.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:186335
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Hello,
|
| I did:
|
| using cs101.Code.nsAdmin;
| at the top of Login.aspx.cs
|
| and:
| DataRow drUser =
| cs101.Code.nsAdmin.Admin.RetrieveUserbyUserNameNPa ssword( UserName.Text,
| Password.Text );
|
| inside my click event, the error I get is:
| "An object reference is required for the nonstatic field, method, or
| property
| 'cs101.Code.nsAdmin.Admin.RetrieveUserbyUserNameNP assword(string,
| string)'
|
| what did I do wrong?
|
|
|
| *** Sent via Developersdex http://www.developersdex.com ***
| Don't just participate in USENET...get rewarded for it!
|

Nov 15 '05 #5

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

Similar topics

7
by: Bruce W...1 | last post by:
I'm a PHP newbie coming from experience with ASP.NET. I want to have a separate PHP file to support each HTML PHP page. This would be the equivalent of an ASP.NET code-behind file but using PHP....
7
by: Tim ffitch | last post by:
Hi I have created a VB dll file that contains common functions I use across various projects in VB, Access and Excel. Rather than have to code the functions in each I decided to use the dll...
9
by: keith | last post by:
I created a class libery which has name space Assembly and class Assembly and compiled it. Then created a C# project and called a method in the external class e.g. Assembly dll;...
13
by: Bern McCarty | last post by:
I have run an experiment to try to learn some things about floating point performance in managed C++. I am using Visual Studio 2003. I was hoping to get a feel for whether or not it would make...
10
by: bienwell | last post by:
Hi, I have a question about file included in ASP.NET. I have a file that includes all the Sub functions (e.g FileFunct.vb). One of the functions in this file is : Sub TestFunct(ByVal...
5
by: SStory | last post by:
Hi all, I really needed to get the icons associated with each file that I want to show in a listview. I used the follow modified code sniplets found on the internet. I have left in...
3
by: Luis P. Mendes | last post by:
Hi, I have the following problem: I instantiate class Sistema from another class. The result is the same if I import it to interactive shell. s = Sistema("par") class Sistema:
3
by: Angus | last post by:
I have a web page with a toolbar containing a Save button. The Save button can change contextually to be a Search button in some cases. Hence the button name searchsavechanges. The snippet of...
11
by: dolphin | last post by:
Hi All! I have a question that how to call a function just using a string. For example There is a .cpp file named a.cpp.There are some functions::fun1() fun2() fun3(). I have another fucntion...
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: 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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
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,...
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,...

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.