If you want to load that function on the time of load only then do like this
protected void Page_Load(object sender, EventArgs e)
{
if(!isPostBack)
{
display();
}
}
public void display()
{
// some block statements
}
as this will load only once. But if u want to load it on each post back then do like this
protected void Page_Load(object sender, EventArgs e)
{
if(!isPostBack)
{}
dispplay();
}
public void display()
{
// some block statements
}
There's a default event called Page_LoadComplete
which will execute when page is loaded fully
But,If you write your code in a Page_Load
Event that code will execute and your controls will be accessible there
So best to call like in a page_load for once with first postback ;)
But, still if you want to go after page load then go for the Page_LoadComplete
protected void Page_LoadComplete(object sender, EventArgs e)
{
display();
}
public void display()
{
// some block statements
}