RegisterRequiresPostback failing to call LoadPostData

J

John Burke

I am getting a curious problem where LoadPostData is not being called after
registering the control using RegisterRequiresPostback. Other controls not
requiring postback registration are having LoadPostData called. Each
control calling RegisterRequiresPostback does have a uniqueid and exists for
the lifetime of the page, so it's not a mis-referencing problem.

It's worth noting that this was working fine until I killed the Viewstate
and emitted an empty Viewstate hidden field instead. Is it possible that
somewhere in the inner workings of the page class there is some dependency
between RegisterRequiresPostback and the Viewstate?

Any clues?

JB
 
T

Teemu Keiski

Hi,

there is dependency such way that Page class checks existence of VIEWSTATE
and EVENTTARGET form elements at the beginnig of request to detect the
postback mode (it returns the request data collection based on this). If
both __VIEWSTATE and __EVENTTARGET hidden form elements are missing
completely, request collection is null.This same collection is the one that
is passed to the LoadPostData method (still LoadPostData should be called in
any case). But I suppose you have removed only the __VIEWSTATE hidden field,
so it can't be the problem.

Can you tell/post some code that demonstrates where do you do the
registration for postback handling?

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke



I am getting a curious problem where LoadPostData is not being called after
registering the control using RegisterRequiresPostback. Other controls not
requiring postback registration are having LoadPostData called. Each
control calling RegisterRequiresPostback does have a uniqueid and exists for
the lifetime of the page, so it's not a mis-referencing problem.

It's worth noting that this was working fine until I killed the Viewstate
and emitted an empty Viewstate hidden field instead. Is it possible that
somewhere in the inner workings of the page class there is some dependency
between RegisterRequiresPostback and the Viewstate?

Any clues?

JB
 
S

Sam

Is it possible that somehow the Viewstate is carrying the ID of the
malfunctioning control? If it wasn't restored before LoadPostData
then of course that event wouldn't fire.

Make sure the ID of the control is being set in Init (either
explicitly or because you add it the the Controls collection) and
doesn't change during the lifecycle. But I assume you've already
tried these simple tests... Once though I had a similiar problem
because I added the control in Init and explicity set its ID in Page
Load, thus inadvertantly skipping the 1st ProcessPostData stage.

-Sam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top