Question

I have the following case:

Page1.aspx this page has the master page master.aspx.

I have some code in the master page :

 if (!Page.IsPostBack)
            {
                adjustServiceBar();

            }

when i click any button in the Page1.aspxit enters the !Page.IsPostBack and execute the method !!

i want this method in the !Page.IsPostBack) only

Was it helpful?

Solution

One way to do this is to set a session variable and then check that variable to ensure your code will fire only once. Another way is to set a hidden control on your form and play with its text or value property.

According to each scenario the solution may be very complex such as custom derived masterpages and pages that extend the current events functionality to suit your needs.

OTHER TIPS

I believe it is more consistent to check for IsPostBack in content page. You can move this condition to Page1.aspx and expose adjustServiceBar() method in your master page, so that content pages can call it, like Master.adjustServiceBar().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top