Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ASP.NET C# external classes

Posted on 2007-04-11
3
Medium Priority
?
302 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
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

926 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