Josh Gough

<September 2008>
SuMoTuWeThFrSa
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011


Navigation

Subscriptions

Post Categories



Wednesday, September 13, 2006 - Posts

Themes: PreInit and Custom Controls? Never the twain shall meet?
I want to be able to add a "PrintButton", derived from ImageButton to a page. When the user clicks this button, it should set the Page.Theme to "Print". All the examples I've seen about themes tend to rely on QueryString since you can access that within the PreInit event of the page.

First, is there a way to add a query string to a form's action URL so that the postback could actually have a query string?

Secondly, is there a way to add your own event handlers to Page.PreInit from controls?

I tried to do it in the PrintButton constructor, but Page is null at that point. Trying it in PrintButton.Init is too late since Page.PreInit event handlers have already been fired.

I already got it to work by putting code in my BasePage's PreInit handler, but I'd rather than have that code run on every single page, because not every page is going to have a PrintButton on it. The code loops through Request.Form and looks for a key whose name contains "ctlPrint", which will contain cltPrint.x and ctlPrint.y coordinates when the imagebutton is clicked.

But, I just wonder if anyone knows another way to do this that will keep all the logic within the PrintButton control itself.

Thanks

posted Wednesday, September 13, 2006 11:17 AM by JoshuaGough with 679 Comments




Powered by Dot Net Junkies, by Telligent Systems