I have implemented a way to translate all may labels and linkbuttons, etc for an ASP.NET page from values of a database. The labels etc have a hardcoded Text-Value as fallback and on runtime the will be translated.
What I did is I basically wrote aBasePage
which every page inherits from. I overwrote the Page_Load
method looked for all required controls recursively and then changed the text. I learned that I have to use Page_Load
since the Header LinkButton
Text were not translated if I used On_Init
On_InitCompleted
.
However this works as expected as long as I did not click the LinkButton
on a GridView
column. Which triggers a postback (async) which runs through all my translation code. But lookin at the page, I see that the they flipped back to the hardcoded fallback text headers on the grid view (only gridview header). I am pretty sure this is something with the page life-cycle dance but cannot solve it.
I want to have all the translation logic in the BasePage and not subscribe to any GridviewEvents and change labels on binding etc.
It would be helpful to retain the translation of the gridview header through the async postback of an update panel. Any help would be greatly appreciated.
I experimented back and forth and decided to do the translation not in the beginning but in the end of the page life-cycle.
So instead of Page_Log
I do translation now in the On_PreRenderCompleted
override.
Works now!