Solved - last event that fires on a page

Posted on 2013-05-14
Last Modified: 2013-05-16
In this code snippet I am loading a control at runtime.


I try to call a public method of the control  (  "HideFrame"  ) which turns some <div> tags invisible, because under this circumstance, I don't want them to show.

It fails because I think the HTML for the "ptg" control is not full rendered.

  Reo.ContentControls.PostponedTaskGridPopup ptg = ((Reo.ContentControls.PostponedTaskGridPopup)LoadControl("~/ContentControls/PostponedTaskGridPopup.ascx"));

                    ptg.FillVariablesThroughPassedInData(assetTaskIdSid, this.AssetIdSid, "normal");


                    Table t = new Table();
                    TableRow trName = new TableRow();
                    TableRow trRole = new TableRow();
                    TableRow trDate = new TableRow();
                    TableRow trLink = new TableRow();


                    TableCell tdName = new TableCell();
                    TableCell tdRole = new TableCell();
                    TableCell tdDate = new TableCell();
                    TableCell tdLink = new TableCell();

                    TableCell tdPostpone = new TableCell();

                    tdPostpone.RowSpan = 4;




/////////// THIS FAILS //////////////////////

Open in new window

 public void HideFrame()
            //hide surrounding divs and layout stuff
            HtmlGenericControl fh = ((HtmlGenericControl)FindControl("frame_header"));
            HtmlGenericControl fr = ((HtmlGenericControl)FindControl("frame"));
            fh.Visible = false;

Open in new window

fh.Visible = false

fails because fh is null.

I think it is because the page rendering is not far enough along to be able to hide the <div>.

So my question is - how can I know when it is safe to hide the control (the div)
Question by:Tom Knowlton
  • 2
LVL 18

Accepted Solution

Jerry Miller earned 500 total points
ID: 39166964
This may help you out. It explains the  page life cycle in

The PreRender event may be the one that you need.

"Occurs after the Control object is loaded but prior to rendering."

Author Comment

by:Tom Knowlton
ID: 39168402
I tried PreRender.

I also tried Page_Unload, which I think is the last event  (but I think it fires after the page has been sent to the client, so is of no use)

Is there something **right before** Page_Unload, but after Pre_Render?  Like a "Post_Render" ??

I'll take a closer look at the page life cycle.

Author Closing Comment

by:Tom Knowlton
ID: 39172064
I eventually solved this with jQuery:

 $('div[id*="_divPostponedTaskGrid"]').each(function () {

            var tablecount = $(this).children('div').children().size();
            if (tablecount == 0) {
            else {
                $(this).closest('#frame').css('background-image', 'none');

Open in new window


Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Technology Resume 7 69
VB.Net creating Contact in Outlook 1 57
How to repeat the data 4 30
Dictionary and array of [N] size - performance tuned 12 41
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question