Let’s say I want to run the same function on every one of my .aspx pages. Let’s say this function always results in a UTC DateTime and the user’s DateTime, for example. How can I write code in one place that will both compute these values for every page load and then make their values available to the entire .aspx page?
I realize I could declare these variables in each page and then call the function, but isn’t there a way to write it once to avoid writing the same code repeatedly? Thanks.
Let’s say I want to run the same function on every one of my
Share
I would suggest using a master page. Even if you do not have anything visible from the master page, you could have its onload or oninit do the calculation, the store it as a property of the master page.
then from the child page you can access the master page