?
Solved

ASP.NET C# external classes

Posted on 2007-04-11
3
Medium Priority
?
300 Views
Last Modified: 2013-12-17
Hello

I am trying to make my own login with asp.net as i do not have MS SQL

i have made it, and am wanting to use external classes. i am however finding it difficult to return values back to the original page..

this is the external class for instance.

public class Login
{
      public static string CartInfo(string username, string password)
      {
           //here i wanto recieve the username and password then send out a bool to say if it is true or false
        }
}

and this is my web page code.

public void hello(string tom, string iscorrect)
        {
              // here i wanto send the username and password information from the session
               // to the external class by code below...
                                                
            Login.CartInfo(username);
            Login.CartInfo(password);

//then recieve the bool and make a decision based on that.
        }


i am familair with classes just not the returning of values.
0
Comment
Question by:thomasmutton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 12

Expert Comment

by:craskin
ID: 18889900
just create a function in your custom namespace and class that returns the boolean. then, on your page, you can just call it like

Dim LoginTrue As Boolean = myNamespace.MyClass.LoginTest(usernameSent, passwordSent)
0
 
LVL 8

Accepted Solution

by:
sankarbha earned 2000 total points
ID: 18890241
try this:

public class Login
{
      public static bool CartInfo(string username, string password)
      {
           //here i wanto recieve the username and password then send out a bool to say if it is true or false
           //just assuming
            if(username=="someusername" && password.toString()=="somepwd")
            {
                           return true;
            }
           else
            {
                         return false;
            }
        }
}


//in your code behind page i.e. login.aspx.cs in page load event handler

if(Login.CartInfo(username.Text, password.Text)==true)
{
 //login success
}
else
{
  //login failed
}
0
 

Author Comment

by:thomasmutton
ID: 18890617
Excellent! thankyou sankarbha.
0

Featured Post

CHALLENGE LAB: Troubleshooting Connectivity Issues

Goal: Fix the connectivity issue in the lab's AWS environment so that you can SSH into the provided EC2 instance.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question