Need help with custom Web Controls

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've got a page with a couple ascx files on it. One od the controls displays
a user's picture, the other contains a datagrid where a user can upload more
pictures, change their default picture, etc.

When a user selects a different picture in the contorl containing the
datagrid, the code execute when the page postsback, but the control that
displays the user's picture does not.

How do I get this control to refresh on a post back?

Thanks for your help
 
Are you saying that after a postback, the control that displays the user's
picture doesn't update (to the new picture for example)?
This is probably an event sequencing problem. When doing a postback, you
need to look at the events that are called:

(summarized, not complete list:)
1) Page OnLoad
2) Controls' Page OnLoad
3) PostBack event

If you notice, your postback event handler, which is where I imagine you are
modifying the picture, is called after the control's page load. Therefore
your control is rendering the correct image, you just changed it AFTER the
control did it's processing.

To fix this, I suggest moving your control's PageLoad functionality to an
OnPreRender event handler instead of the OnLoad handler. This may have
further implications depending on your code though. But for simple custom
controls it doesn't.

HTH

Steve
 

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

Back
Top