Monday, March 26, 2012

Updating an UpdatePanel

Hello, I have just started using AJAX and ASP and could use some help with a problem I could not solve today.

Here is a link so you can check out my site setup...

http://opteron.dnsprotect.com/~verisol/HelpImage.bmp

LogSheetOperator.aspx is a content page to Site.Master and is the page that includes the AJAX ScriptManager. The VB code in this page adds the .ascx pages to the UpdatePanels of each tab.

NetWeightAuditUpdatePanel and CheckTimesUpdatePanel both contain a gridview. When the gridview in the NetWeightAuditUpdatePanel is updated, I want the CheckTimesUpdatePanel to refresh.

I made a simple test page that implements the Triggers feature of the update panel and successfully got that working with the Click method of a button. When I tried to apply that logic to the real project, it did not work. I'm guessing this is because of how the pages are structured.

Anyone have a solution or suggestions?

Thanks!
Matt


Off hand, i know there are many approaches out there, but have you considerd a single updatepanel hosting the tab containers which in turn host the dynamic ascx files.

You have the tab container hostin the tab panels which inturn hosts the updatepanels which inturn hosts the ascx files. cant 1 updatepanel provide you the support that you need.?


Daniel, thanks for that information. I just tried replacing all the update panels with a single update panel that encapsulated both Tab groups, but it still did not work. Since the content is on those .ascx pages, if I try and call a .Update() method inside the gridviews rowupdated event, it says that theUpdatePanelX.Update() is not defined, which makes sense because it is on a different page.

Any other ideas on how to get the UpdatePanel to Update?

Thanks!


what does "When the gridview in the NetWeightAuditUpdatePanel is updated" mean , are you doing some kind of editing here in the gridview or do you mean when the underlying data in updated?

i dont know if the following would be useful, but when i used ascx files sometimes i need to call some function or sub in the ascx's underlying codebehind to update the controls in the ascx.

What i do in that case is to create a public method mostly a sub, could be a function or property too. and have the hosting page call that public method of the ascx object instance. that way the ascx object will postback and the content of the ascx will update.

in your case you could explicitly call the "update" method of the ascx and let normal postback take care of the updating via the updatepanel as normal or you could go overboard and wire-up the public method of the ascx as an event handler of the rowupdated event.

So essentially you are not trying to call the .updatemethod of the updatepanel but instead trying to cause a postback in addition to firing an event in the "target" ascx that you want updated and you take it from there.

No comments:

Post a Comment