How to call an ASPX page function in another project?

Asked

Viewed 884 times

1

How to call an ASPX page function in another project?

When clicking insert I call a project to make the business rules, at a certain moment I need to call a C# function that is on the page and after the return of this function continue on making the rules of business.

as I call this function?

2 answers

1

Hello.

For this to happen, you will need to reference your project (not Solution) in your BLL. However, if you have already referenced BLL in your application, VS will not allow.

A solution that I use a lot is to keep as many methods as possible in BLL, even if it is something specific, so if you need to use in aspx or in BLL itself, just call it normally.

I hope I’ve helped!!!

  • It is a function that reads an html input file and uploads the file, so it has to be on the page. But thanks for the help. I’ll see how I can do it here.

1


You could pass the method to be caller for BLL as a delegate, and then use the delegate to call the method.

Example:

Code of the BLL:

public void RegraInserir(Action metodo)
{
    metodo(); // chamando o método passado na forma de delegate
}

Page code:

public void buttonInserir_Click(EventArgs e)
{
    businessLayer.RegraInserir(this.Metodo);
}

private void Metodo()
{
    // método que será chamado pela BLL
}
  • The idea is good, the problem is that I trigger my BLL with formView with Bind() without going through page events.

  • Your BLL would have to implement an event then? That way there could be an event called Bllquerarquivo, which would be associated in the Load of the page or some other place it deems more appropriate.

Browser other questions tagged

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