Problem aborting ASP.Net UpdatePanel or Telerik RadAjaxPanel - asp.net

I've been trying to solve a problem. I have a rather slow loading set of nested datarepeaters that take a couple minutes to fully render. I need to have a cancel button.
First I tried a simple updatepanel with a cancel button in an updateprogress that performed an abortPostBack. It would hide the updatepanel but wait until the datarepeater was done before you could do anything on the page.
We have the Telerik AJAX controls so, hoping they're more advanced, I've now wrapped it up in a RadAjaxPanel. This seems to have the same issue. I've even tried firing an ajaxManager.ajaxRequest back to the server and setting a bool to try and abort the databinding, but that event isn't caught by the server until the databinding completes.
Any ideas on how to get a responsive cancel to a large set of nested datarepeaters?

I think that you can cancel the ajax request from Telerik ajax panel or ajax manager only before it reaches the server, i.e. inside the OnRequestStart client event of both by setting args.set_cancel(true).
Dick

Related

asp.net fileupload server control performance

I have a fairly simple aspx page (using a MasterPage) with various buttons and server-side event handlers. When I click the buttons the event handler is hit almost immediately. However, as soon as I add the following to my page:
asp:FileUpload runat="server" ID="fileUpload"" there is a huge increase in the delay between a button click and it's event handler, the fileUpload control is not used at this point.
I am struggling to find out where the delay in the process is so that I can try and bypass it. Any help is much appreciated.
Thanks.
It turns out the issue was related to McAfee DLP https://www.mcafee.com/uk/products/total-protection-for-data-loss-prevention.aspx
Whatever is added to the aspx page / viewstate by the fileUpload control caused our McAfee DLP to kick in and perform a whole bunch of checks before the page request was finally submitted.

Is there a way to trigger an updatepanel without a click event?

I'm trying to load parts of a page at a time instead of doing all my calculations in the onLoad page event, then displaying all the calculations at once.
I think one of the ways to mimic a faster loading page is to separate parts of the page into updatepanels (correct me if I'm wrong in this approach). As such, I'm wondering if there is a way to execute some code in the onLoad event, display that on the page, then continue some other work in updatepanels and load those as they get completed.
UpdatePanels are a poor implementation of ajax. Since only a section of the page is being updated, it is easy (too easy) to think that you have reduced the execution time of your page. An UpdatePanel performs a postback and as such executes the entire life cycle of your page (lamely put, it will execute the PageLoad for your page and every usercontrol on your page not just the ones that are in the UpdatePanel). Unless you put lots of if !Page.IsPostBack in your code, you could actually end up slowing your application down. Also, since it is a postback, it will submit the runat='server' form that is on your page and submit every input (not just the stuff in the update panel) to the server, which means you aren't saving anything on payload and bandwidth by using an update panel.
to answer your question though, you just need to call __doPostBack('updatepanel1', ''). reference http://encosia.com/easily-refresh-an-updatepanel-using-javascript/
You can call the .Update method on the UpdatePanel. Set the UpdateMode to be Conditional and handle all of the Update panel updating by hand in code.

ASP.NET control event handler not firing on postback?

I have a control which has an ImageButton which is tied to an OnClick event... Upon clicking this control, a postback is performed and the event handler is not called. AutoEventWireup is set to true, and I've double checked spelling etc.... We haven't touched this control in over a year and it has been working fine until a couple of weeks ago.
We have made changes to controls which load this control... so I'm wondering, what kind of changes could we have made to stop this event handler from being called? There is quite a bit of Javascript going on, so this could be the culprit too...
Edit: Some clarification... we are dynamically loading the parent control of the ImageButton in the OnLoad event of the page... if that makes sense.
AutoEventWireup is irrelevant. Is your ImageButton loaded dynamically, i.e. not written out in mark up? If it is loaded onto the page late in the Page lifecycle e.g. in PreRender then the event will not fire.
If there is a JavaScript issue your page will not even PostBack. Is that happening?
Did you give the ImageButton an ID?
I def agree with what BritishDeveloper said. I had a similar problem where I was dynamically loading controls, but I couldn't get a reference to the control using Page.FindControl("controlName") Someone pointed out that I needed to keep the page lifecycle in mind. I found out I needed to make sure to load the control in the PageInit because after doing an async postback the control was still there, but not loaded in the postback so there was no way to find it. This was all in csharp codebehind and ajax though, but I'm guessing the control isn't getting reloaded.
So, as it turns out we set the PostbackUrl property on one of our buttons in control A... this caused the event handlers for control B not to fire when a button in control B was pressed.
If you create a control dynamically. Any time you fire a postback using the new created control, you need to recreated it. Just think that your application are running at a server. How can the server hold information on controls created dynamically? Don't use Page.IsPostBack to create postback. PostbackUrl is bad solution. Workarround will be need.
I can go into a little more detail ... I just lost several hours fixing my own issue similar to the issue described here. In the course of creating some search controls, I added a pair of ImageButtons and set the PostbackUrl properties on them. A few days later while testing new code, I noticed that none of my other buttons on the webform were posting back properly. They would fire a postback, but the code-behind was behaving as if every postback was an initial page request and none of the event handlers were firing.
After several hours of troubleshooting, I came across this post. When I went back and removed the PostbackUrl from those two ImageButtons, everything went back to normal. I don't know why it was causing this issue, but the fix mentioned here worked for me. I want to add that my ImageButtons were not dynamically added ... they were in the markup and this issue still cropped up. Search your markup for any controls with PostbackUrl set ... remove that (program around it if needed) ... see if your event handlers will fire properly.

asp.net crosspage postback on click doesn't run

I am trying to get a crosspage postback to work in asp.net 2.0 the issue I seem to be having is the button that I press is meant to use it's on click event to store some session variables based on the values of other controls. This button has crosspage postback property to the relevant page.
The on click event seems to not run at all, it just seems to perform the postback to the other page straight away.
Is this standard behavior? Any work around?
I think I have found my answer
http://community.sgdotnet.org/blogs/chuawenching/archive/2007/03/08/ASP.NET-2.0-DataGrid_2F00_GridView-CrossPage-PostBack-.aspx
Seems like the transfer will be instant, no onClick event will run. The alternative is to use Server.Transfer in the onClick event.
Any other comments appreciated.

ASP.NET - AJAX - Partial followed by full postback problem

I've a page that has a series of web controls. One of these is a textbox with AutoPostBack turned off.
The way the page operates is that a button is clicked to save the form data. This button sits outside of the updatepanel.
So when I hit the save button the partial postback happens for the dropdownlist and after this postback has completed a full postback fires for the save button. However when the full postback fires the form data is returned to the state before the save button was clicked - i.e. my changes are removed.
I believe this could be to do with the viewstate being returned from the partial update and that viewstate not updating in the page before the full postback fires - or it getting corrupted.
Does anyone have any ideas?
Thanks.
Don't mean to sound negative but these scenarios are what made me give up "by the book" ASP.net AJAX. Learning jQuery /w simplistic ASP.net forms /w NO postbacks has lead me to build more useful and cooler UI experiences than what I had to battle to get working with update panels etc.
If you set UpdateMode="Conditional" and ChildrenAsTriggers="true" on your UpdatePanel, that will ensure the partial postback only executes when the DropDownList's postback event fires, not when the Button is clicked.
Thanks for the quick response! However I need the save buttons click event to fire too. The order in which the events fire is perfect:
dropdownlist changed event (partial)
save button click event (full)
The problem is the loss of form data after the partial postback.
Many thanks.
I've already posted a solution to this on another post. This simple code will ensure that your viewstate works with both the postback and partial postback.
Ideas for how to deal with viewstate when using ASP.NET AJAX and update panels

Resources