Showing posts with label detecting. Show all posts
Showing posts with label detecting. Show all posts

Monday, March 26, 2012

Detecting which UpdatePanel was updated for endRequest

I've got an issue where I'm trying to execute some javascript when a specific UpdatePanel on my page (I have about 5) is updated. I've added event handlers for initializeRequest and endRequest. I know that I can get the ID of the element that *caused* the postback - but I really don't want that. I need the id of the UpdatePanel that is being updated.

Then endRequest method that gets called after an UpdatePanel gets updated is called for any and all UpdatePanels - this ambiguity makes it difficult to know which UpdatePanel caused this request.

Any ideas?

Cheers,

Bobby

The endRequest event doesn't have the information you want. If you handle the pageLoaded event, the args parameter that gets passed in to your handler has a panelsUpdated property which returns an array containing the panels that were updated.

Detecting UpdatePanel postback Vs regular postback

Probably a stupid question...

Is it possible to detect on the server-side whether or not the request is a full post back or an updatepanel postback?

Reason is I have a couple of controls on the page that are rather database-intensive and if since an UpdatePanel postback causes a full page cycle, if I could detect it I could avoid having those problem doing the db-intensive rendering task.

Thanks!

Ben

Hi Ben,

You can ask the scriptmanager if it's in a partial page postback, see my example in VB

If ScriptManager.GetCurrent(Me).IsInAsyncPostBack()Then'is in partial postbackEnd If


EACH CONTROL has its own events. if you bind the other controls in the page load event, enclose them with:

if not page.ispostback then

end if

the UpdatePanel has its own events where you can work on.


hi,

i don't think there is any method to identify which postback is done. According to my observation both postbacks are same


First to Check if it is AsyncPostback you can use the YourScriptManager.IsAsyncPostBack and to detect which control casued the postback use the YourScriptManager.AsyncPostBackSourceElementID.


Thanks Richard, that worked just fine (I knew that had to be simple!), marked your reply as answer.

Thanks all for your replies too.

Cheers,

Ben

Detecting UpdatePanel postback so can prevent onbeforeunload from firing

Hi, I was wondering if any of you AJAX gurus could help me out or point me in the right direction...

I'm using onbeforeunload on a form that has UpdatePanels. Anyone know how to detect the postback is an AJAX partial page update rather than a full page postback so I can prevent the onbeforeunload dialog showing in such cases?

Cheers.

No worries, I've just found this thread that gave me the info I needed to resolve my issue -http://forums.asp.net/p/1153470/1887704.aspx

Detecting point of click on Table

Hi all.
I have a Table on my page. By xml-script I can detect clicks on it.

<components>
<button id="Table1" click="DoSomething" />
</components
But I want to know coordinates of the point on this table, which was clicked. Specifically I want to have them in my function "DoSomething()"
Please, help me.

There are examples here for tracking mouse position:http://www.irt.org/script/pointer.htm

-Damien


DoSomething should be a function like so:

function DoSomethign(ev){}

ev.clientX and ev.clientY will give you the coordinates, and so on.

detecting partial page postback

I read it somewhere here before, but can;t seem to find the reference today.

What is the code for separating the different types of postbacks (full page, partial postback, etc.)? I need to do this prammatically from a user control.

Hi,

You have ScriptManager.IsInAsyncPostBack to check if the page is performing an asyncpostback and UpdatePanel.IsInPartialRendering to check whether that particular updatepanel is performing a partial rendering.

Hope this helps,

Juan


Thanks for the info, that helps alot.

For anyone out there doing this from within a usercontrol, here is some code:

Dim tempScriptAs ScriptManager

tempScript =CType(page.FindControl("scriptManager1"), ScriptManager)

Dim asyncAsBoolean = tempScript.IsInAsyncPostBack

--

<

asp:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering="true">

</asp:ScriptManager>

Detecting browser closing in session

Hi

Sorry if this is obvious but I'm new to Microsoft Ajax. Is there anything in Microsoft Ajax/Asp.net to detect when the browser is closed via the 'X' button?

thanks

No, the browser does not notify that is closes, it just quits asking data from the webserver.


No. There's no reliable way to notify the server about the browser being closed. May be some java script hack is available but it is not recommended.