Showing posts with label back. Show all posts
Showing posts with label back. Show all posts

Wednesday, March 28, 2012

Difficult problem with the UpdatePanel and State

Hi,

I have a page with an UpdatePanel that display 5 news story headlines, within the UpdatePanel there are two buttons, back and next, to move the to the next 5 headlines set or to move previous 5 headlines set. Each headline has a link that goes to a new page where the full news story is shown. All this is working great, but if the user is on the second or third set of headlines, then clicks on one of the headlines to go to the page that shows the entire news story, then the user click the back button on the browser to get back to the news story headlines, the news story headlines page will display the first set of news story headlines, not the second or third set where the user originally left from.

How I can let the news story headlines page or the UpdatePanel know on which set the user left the page, so when the user came back via the back browser button, the set they left is displayed?

Hope this makes sense! Thank you.

Please, let me know if I should explain this better or differently, need help with it!

Did Features Get Fixed In RC?

I loved ASP.NET Ajax back when it was "Atlas", but I haven't used it much since. There were a few things that really bothered me about the framework, however, and I'm wondering if things have changed.

In particular:

1. Is there a concept of an "event" in the client script library for the built-in features (like are there events like "DragStart" for the drag/drop functionality for example).
2. Does ASP.NET Ajax still require the SciptManager/ScriptManagerProxy malarky? I was hoping there would be a SciptManagerSettings control and that Atlas controls automatically registered a ScriptManager "singleton" (per page request) when they're loaded (the idea being you don't have to mess with the clumsiness of worrying about whether the ScriptManager already exists somewhere a MasterPage/Page/base class).

This post from Scott Guthrie tells you exatly the bug fixes and new improvements:

http://weblogs.asp.net/scottgu/archive/2006/10/20/ASP.NET-AJAX-Beta-1-Released.aspx

Monday, March 26, 2012

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

Detailed error messages with AJAX?

I'm building the front and back ends of a website and my issue is that when an error occurs in a section that is "ajaxed", the error is displayed in a javascript pop-up.

Is there any way that I can have it at least display a line number of the file causing the error? It's driving me crazy to debug, especially when I have dozens of classes working together. Please help. Thanks!

Ryan

Hi Ryan,

There are some good articles out there on the error handling in AJAX, but probably the first thing you need to do is to use the OnAsyncPostBackError attribute of the ScriptManager tag to add an event handler - allowing you to log the exception, or do something else with it.

Then you can start looking at supressing the alert, etc.

ScottGU's blog has a post which might be a good starting point when you want to go into a bit more depth, and produce a response which is more aimed at the users than developers!


You canadd custom handling of async errors pretty easily.

In that example, check out args._error for more details. _error.lineNumber and _error.stack might be helpful to you.

Saturday, March 24, 2012

Deploying Atlas to Non Dev Machines

I have an intranent application that gets iframecall.axh errors when deployed. It if I change the script manager paths to point back to a development box.(?).

Debug error message: "A web request made using the iframe executor failed. Make sure that the app's web.config registers iframecall.axd"

What am I missing? Something must need to be done to these test machines to deploy.

The http handler is set :

<addverb="*"path="iframecall.axd"type="Microsoft.Web.Services.IFrameHandler"validate="false"/>

Each of the Web Methods.

WebOperationAttribute(true,ResponseFormatMode.Json,true)

Why does Atlas use the header name and the port to call its self? I found the cause of the problem. Its appears that since we use a CSS ( type of cysco router ) to route traffic on shared servers that the call to the service is using the host header and the port which when re-routed back to the server is incorrect. If the site is available on http://<server>:<port> but the users calls it with the host

headerhttp://<host header> the call back to iframecall ishttp://<host header>:<port>

Here is an example: http://MySite/service1.asmx if hosted onhttp://MyServer:8040/service1.asmx gets called viahttp://MySite:8040/service1.asmx and fails.

Is there a work around for this or how do I fix it?