Saturday, March 24, 2012

trigger updatepanel from javascript inside updatepanel

Hello all.

Is it possible to trigger a updatepanel update from a javascript?

I have made an app with a map that I can move around by clicking some imagebuttons on the side or by using the mouse. When I use the buttons (outside the updatepanel) I don't refresh the enitre page, just the map image inside the updatePanel. But when I just the mouse, some javascripts calls the __doPostBack function. This is used to let the mapengine know that it has to make a new map.

Is there a way to make the javascript act like the button that I define with AsyncPostBackTriggers?

Thanks


Endre

Can you simulate the click of the button? This would assume that the button
has already been setup as an AsyncPostBackTrigger.

I'm interested if you can get this to happen just from the client side as I
asked a similar question a while back and was told it wouldn't work.

Wally

wrote in message news:1465688@.forums.asp.net...
> Hello all.
>
>
>
> Is it possible to trigger a updatepanel update from a javascript?
>
> I have made an app with a map that I can move around by clicking some
> imagebuttons on the side or by using the mouse. When I use the buttons
> (outside the updatepanel) I don't refresh the enitre page, just the map
> image inside the updatePanel. But when I just the mouse, some javascripts
> calls the __doPostBack function. This is used to let the mapengine know
> that it has to make a new map.
>
> Is there a way to make the javascript act like the button that I define
> with AsyncPostBackTriggers?
>
> Thanks
>
>
> Endre
>


Listen to the ASP.NET Podcast @.http://www.aspnetpodcast.com/

Not sure if this is applicable to your situation, but I have a page with many UpdatePanel controls and some WebService calls that are done entirely with javascript. There are certain conditions where I call a WebService, and upon it's return in the callback function I want to trigger an UpdatePanel. To do this I put an invisible button inside the UpdatePanel I want to refresh, e.g.,

<asp:Button ID="ReloadActivities" runat="Server" ForeColor="White" BackColor="White" Height="1px" Width="1px" BorderColor="White" BorderStyle="None" OnClick="ReloadActivities_Click" />

In my javascript code I trigger this button using the click method:


function reloadActivities()
{
document.getElementById('<%=ReloadActivities.ClientId%>').click();

}

This works great in IE, but on Firefox it triggers a complete postback (non ajax) and I haven't figured out why yet. And this new firefox bug didn't occur when I was using the June ATLAS release, just after I upgraded to the Ajax Extenstions beta.


I'm doing something similar, but instead of a WebService I'm opening a modal dialog box (only works for IE). Upon it's closure, I use a a javascript function to trigger a linkbutton in my UpdatePanel which refreshes the content.

My problem is that it doesn't seem to work any more using IE 7. Wondering if you've noticed the same?


Try the extender control I build

http://daron.yondem.com


onclick="<%= ClientScript.GetPostBackEventReference(new PostBackOptions(Button1, ""))%>">
Nice solution. However to do it, you need to have a hidden Button1 on your page :) The extender adds it automaticaly, provides JavaScript parameter transfer and its own event handler.

Awesome VR2Big Smile

This means that I can trigger an UpdatePanel from anywhere without messing with the trigger collection. That solves a major headache.

No comments:

Post a Comment