Link to home
Start Free TrialLog in
Avatar of netformx
netformx

asked on

Even Page_PreRender is fired twice

Hi,

I have aspx page on which I put user control A which derived from user control B.
When I moevd to Visual 2005 (ASP.NET 2.0), I noticed that Page_PreRender  in control B is fired twice.
When I put :
protected void Page_PreRender(object sender, System.EventArgs e)
        {

        }
in control A - the problem was solved (i.e. Page_PreRender of A is fired and Page_PreRender of B is fired only once).

But I want to understand why was it happpening?

P.S. I can't reconstruct this on simple project, created in Visual 2005. Maybe it's related to the fact that the project was migrated from Visual 2003, or there is somethign else different in my project that causes to such strange behavior?
Avatar of t_itanium
t_itanium
Flag of United Arab Emirates image

hi

i think you should rewrite your application in VS2005 from scratch... maybe opening it and converting it to newer version may cause some problems..
thats what happened to me when i used to do that between earlier versions in VS.net

cheers
Avatar of matt3ew
matt3ew

It sounds like whats happened is your B control automatically calls its prerender event and your A control generated code called control B's again. When you wrote protected void Page_PreRender(object sender, System.EventArgs e) {} you override the generated statement thus removing the duplicate call. If you where to write

protected void Page_PreRender(object sender, System.EventArgs e)
        {
            this.Page_PreRender(sender, e); 'Call the original statement
        }

it should reproduce the problem. If it doesn't reproduce then post again and hopefully we can find out exactly whats happening.

Hope this helps.
Avatar of netformx

ASKER


 "your B control automatically calls its prerender event and your A control generated code called control B's again. " - why it worked OK in Visuall 2003? Why this behavior is not reproducable on simple project created in Visual2005 (when control A does not have its protected void Page_PreRender) , what's special in my project? Is this known issue? it happened to you too?
ASKER CERTIFIED SOLUTION
Avatar of matt3ew
matt3ew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial