I’m wondering how I can go about accessing page controls from a separate class I’ve made. I’ve tried a few things I found using google, but no luck 🙁
What I’m trying to do is keep a function that is used often, in a global class.
The function then accesses a page literal and calls ScriptManager.RegisterStartupScript. I was hoping this is possible, so then this function wouldn’t have to be copied to all of the pages.
I’m not sure whether I understood you correctly – if not, post some sample code.
If you have your page ex Default and the code behind like this:
You can make a helper class like this:
And if you want it to work with all pages, you can “find” the control like the following. You should, however, use Master pages and the code behind if there is something that need to be done on all pages.