ASP.NET Index (Controller) method that only runs when I want

Asked

Viewed 20 times

0

good night. First I apologize for the ignorance, I am beginner as a developer.

From what I understand of ASP.NET, it will automatically run all void methods of my index when this index is called. For example:

    public class HomeController : Controller
{
    public ViewResult Index()
    {
        carregarlista1();
        carregarlista2();
        carregarlista3();
    }
    void carregarlista1()
    {
        exemplo de código
    }
    void carregarlista2()
    {
        exemplo de código
    }
    void carregarlista3()
    {
        exemplo de código
    }
}

When opening this Index, it will run all 3 void methods.

I would like to know if it is possible for me to create a code like the one above, but it will only run load1(); and load2();. And only run the method load3() when I click on a button in the View. It is possible to do this?

Thank you!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.