I have a method in MyWebpage.aspx.cs lik so:
public partial class MyWebpage : PageBase
{
private readonly DataAccessLayer dataAccessLayer;
protected string GetMyTitle(string myVar, string myId)
{
if (string.IsNullOrEmpty(myVar))
{
return string.Empty;
}
return dataAccessLayer.GetMyTitle(Convert.ToInt32(myId), myVar);
}
}
In the DataAccessLayer class, I have a methoud that talks to the DB and does the DAL stuff and returns the title.
What's the best practice on accessing the DAL from MyWebPage.aspx.cs class (as in do I need to create a new DataAccessLayer() object each time? Where should I create it in my PageBase class or everytime I call it in a code behind?