Showing posts with label items. Show all posts
Showing posts with label items. Show all posts

Wednesday, March 28, 2012

UpdatePanel - DataGrid - Client Refresh

hi
I have a GridView inside a UpdatePanel


the case is: The user open a new window, select new items witch afect the data displayed in the DataGrid.

I want to update de GridView content via a Javascript method is there a way to do that?


thanks for any help

hello.

an easy way to do this is to add a dummy button and then perform a click programatically on that button. this should be enough to force the postback. you can also take a look at the postbackaction or event call the _dopostback method directly.


That Works fine
Thanks Madeira  
function RefreshGridView(){__doPostBack('Button1','');//Button.click();}

That Works fine
Thanks Luis Abreu
function RefreshGridView(){__doPostBack('Button1','');//Button.click();}

Does this only work from within the update panel?

I'm trying it from outside the panel and it is refreshing the whole page.

UpdatePanel - Javascript Refresh

hi
I have a GridView inside a UpdatePanel


the case is: The user open a new window, select new items witch afect the data displayed in the DataGrid.

I want to update de GridView content via a Javascript method is there a way to do that?


thanks for any help

I think this is possible. I've got the initial idea fromhere.
So put a hidden div into the UpdatePanel, for example:

<div style="display:none;">
<asp:Button id="btnHidden" runat="server" OnClick="btnHidden_Click" UseSubmitBehavior="false" /></div>

Then "trigger" this button in your popup window from javascript:

var refreshHelper = window.opener.document.getElementById( "btnHidden" );
refreshHelper.click( );

It works for me, but maybe there is smarter solutions than this.

hello.

well, currently you have 2 options: use the "dummy" button or use the postback action introduced by atlas.


Luis Abreu:

hello.

well, currently you have 2 options: use the "dummy" button or use the postback action introduced by atlas.

Luis (or anyone else), can you provide an example of using postback action? I'm trying to accomplish something very similar and the dummy button approach doesn't appeal to me.

-Lee


hello.

well, the dopostback action (or, if you want to use javascript, the __doPostBack method) will only work out correctly if there's a control placed inside the form which will be considered responsible for the postback.


Hi Luis,

I do have a a DropDownList that is inside the form so I that would work. I suppose I could just call the __doPostPack method, but I was hoping there would be something that was specific to ATLAS that would force the UpdatePanel to refresh.


hello again,

well, i guess that the answer is no, there isn't. and the reason is simple too: the update panel is just a delimiter that identifies a region which will be refreshed dinamically. all the partial postbacks are controlled by the pagerequestmanager object which uses the updatepanels defined on the page (normally divs or spans) to decide if it should perform a partial or a complete postback.


Ok, so what would you say would be the best way to accomplish this? It sounds as though the options are limited to the dummy button approach or explicitly calling __doPostBack.

hello again.

yep, that's it. i think that currently, there's no other option to perform that kind of operation.

Saturday, March 24, 2012

UpdatePanel and custom Extender: two components with the same id cant be added to the appl

I am experiencing some strange behavior in my UpdatePanel which contains a ListView with a DataPager control. The items in the list view each have a custom ModalPopupExtender that is dynamically generated as well as a custom extender control that does some manipulation on an image.

The first page of results loads correctly, and I can move to the next page fine as well. However, when I move back to the first page, Firebug shows me the 'two components with the same id can't be added to the application' exception thrown on each of the items on the first page of the list, on the behavior associated with my custom extender. This to me seems that the partial update does not destroy or dispose the extender's behaviors when I move to the next page, so when I try to render the first page again, those extenders are still sitting in memory.

Now the kicker is, if I go to the next page and back to the first page a second time, my behaviors load correctly. Repeat and they don't show up and new errors are fired. I know this has to do with the lifecycle but I can't seem to pin it down.

Now my custom extender is fairly straightforward and only calls the base dispose() method for its own dispose() function. What am I missing?


I have narrowed down the issue to the fact that the Extender control uses a callback to attach an event to an image that has loaded dynamically from a web service call:

_onMethodComplete : function(result, userContext, methodName)
{
// Wire up image effect
var i = this.get_element();
i.onload = function(i)
{
asyncEffect(i); // This function lives in an external effects.js file
}

// Do after onload event to pick up change
this._setImage(result);
}

Doing this prevents the extender from disposing, possibly because it's still got a handle to an external JS file. I blanked out the image's onload event after the effect completes and the extender works for images that weren't previously on the page, but is still not disposing the extender correctly. Commenting out the wire up code above corrects the issue (obviously without the effects the JS file would bring).

How can I cleanly dispose an extender that references an external JS script?