Solved

ASP.NET C# external classes

Posted on 2007-04-11
3
293 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 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

895 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now