Last post Jan 28, 2017 02:06 PM by dotnetnoob
Jan 27, 2017 07:52 PM|dotnetnoob|LINK
Hi All: I have a usercontrol with an update panel inside it. The async postback trigger is a button inside the update panel. The usercontrol works properly (asynchronously posts back) when it's placed in a webforms page.
When I place the usercontrol in the itemtemplate or edititemtemplate in a listview, the async button in the control causes a full page postback.
The scriptmanager on the page is set to "enable partial rendering"
When I view source on the page, I don't see any rendered code around the DIV wrapping the updatepanel that would cause it to break. I'm not sure what to check next?
Also, update mode is "conditional" in the updatepanel, and there are no static IDs on any of the elements.
Jan 28, 2017 05:19 AM|markfitzme|LINK
Don't put an updatepanel in an itemtemplate. It's meant to wrap around containers. Itemtemplates are special because their controls are dynamic. The things that could trigger the update panel could change at any time so it's impossible for them to work with
these variable control environments. When the page renders, the scripts need to know how to match up the returned update elements with an item on a page. Since an ItemTemplate isn't a fixed element on the page, it can't match it up to do the content replacement.
Wrapping the ListView does work as it's a fixed element on the page.
An easy way to think of it, if you can access it directly in code behind without using FindControl, it will work with an updatepanel.
Jan 28, 2017 02:06 PM|dotnetnoob|LINK
Thanks Mark...that makes sense...I had built the usercontrol to use outside the listview for a different purpose and was trying to shoehorn it into the itemtemplate...I can create a second one without the updatepanel in it.