Solved

ASP.NET C# external classes

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 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

19 Experts available now in Live!

Get 1:1 Help Now