Hi,

I wonder if anyone has tried to have multiple subroutines in ASP.NET and have one call the other. For example, if the first one is called message(), and second is login(), if login() tries to call message(), how do you do that?

Or, is this not a common practice in ASP.NET at all?

When you say subroutine I take it you are using VB. I droped vb years ago in favor of C#. So in C# I can and do call a method in one class that will call a method in another class. They say what you can do in one you can do in the other.

So lets say I have a login class and inside this login class. I have a public method called SiteLogin that returns a string. If the login is true I have another class that I run all my messages through because it formats the message just the way I like it or I copy them to a database or something. :)

login.cs

class login
{
   public string SiteLogin(string loginName, string loginPassword)
   {
      // the login thing
      if (login = true)
      {
         string userMessage;
         message myMessage = new message();
         userMessage = myMessage.LoginMessage(loginName);
         return userMessage; 
      }
      else 
      {
          return userMessage = "Sorry you gave the wrong login info";
      }      
   }
}

message.cs

class message
{
   public string LoginMessage(string name)
   {
      string myMessage = "Hi " + name + " you are now logged in, have fun!";
      return myMessage;
   }   
}

Ok so this is a stupid example, but it show you that yes you can call one class method from another class method. You can also call public and/or private methods from other methods from within the same class.

Hope some of this has helped a little.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.