Showing posts with label pagerequestmanager. Show all posts
Showing posts with label pagerequestmanager. Show all posts

Monday, March 26, 2012

PageRequestManager : Whats the difference between doPostBack and _doCallBack ?

I want some parts of my web page refresh after a focus or changed event being made on a TextBox. What I want to acheive is get back to the server to do some code. I check the PageRequestManager and saw to way to make a postback to the server. What I want to do is get back to the server like I put a submit button without the whole page refresh. Some advices on that would be really appreciate !

It's not overly clear what your trying to do. Are you currently using UpdatePanels? If not, look into them:

http://www.asp.net/ajax/documentation/live/overview/UpdatePanelOverview.aspx

http://www.asp.net/learn/ajax-videos/video-78.aspx

http://www.asp.net/learn/ajax-videos/video-159.aspx


I know it's not clear. I'm sorry. I'll try to explain more clearly.

On a client event like OnFocus or OnBlur or OnChange, I'll check some client state for the input (TextBox) and take decision if I need to get back to the server to refresh some part of my menu. I try to implement a sort of contextual menu. So, when some part (say inside panel1) got focus, I want to make an ajax request to add some stuff to the menu. When the panel lost focus, maybe I'll switch the visibiliy of some parts of the menu on the client side or got back to the server to do some job.

I'm building a sort of UIManager. This Manager need to check some client state(hidden field) and decide to get back to server if I doesn't have all the state it need to add some part of the menu for the contextual part.

So, I put the menu inside and UpdatePanel UpdateMode=Always. When a control (maybe TextBox, RadioButton or panel) got focus, maybe I need to get back to the server. I want to know if it's necessary to put the control inside and Update Panel or I can write some code to submit the form and use eventArgument to know what I have to do...

I hope is it a little be more clear. I appreciate a lot the time you take to help me !


Hi,

Thank you for your post!

Based on my understanding, you just want to refresh the updatepanel via javascript(e.g On a client event like OnFocus or OnBlur or OnChange).

Check out like this:

use __doPostBack to refresh the UpdatePanel

If you have further questions,let me know.

Best Regards,


Hi,

Thank you for this great anwser. It's really what I was searching.

I have another question. I need a way to pass parameter from the client to know what to do when the page refresh on the server. For example, when the TextChanged occured on the TextBox1, I want to update some parts of the menu. Is it a good approach to pass parameter on the EventArguments of the __doPostback ? And which format do you recommand I use ? Or can you recommand me another way of doing that ?

function TextChanged(){ __doPostBack('ClientAjaxComm','');}
Thanks!

Hi,

It is a good approach to pass parameter on the EventArguments of the __doPostback.

Or you can store something into something hiddenfield,and get them at the server side.

It is up to you to which approach you use.

Thanks!

Pagerequestmanager

Hi All,

the AJAX technology isn't a new one. In IE 5 we where already able to do asynchrone HTTP request with the XMLHTTP object, but you had to communicate directly with the XMLHTTP object. well my question is:

Is the pagerequestmanager THE object that arrange al the communication with the XMLHTTP object so that we don't have to do that anymore? and this pagerequestmanager is the object where the scriptmanager communicates with so indirectly the scriptmanager is responsible for the communcation ?

A collegue of my is using AJAX in CRM. Is it also possible to do calls in CRM (Javascript) to webservices with the use of the scriptmanager? does the version of CRM makes any difference?

Kind regards,

Does nobody have any idea?

Hi Dennis,

I will try to answer to your questions:

1. The PageRequestManager handles the partial rendering mechanism on the client side where the ScriptManager object is the central control that coordinates several things like the scripts rendered to the client, the partial page mechanism , the client proxies used for communicating with the web services, applications services or page methods.

2. I think that the first answer also represents an answer for this question. By using the ScriptManager in your project you can enable calls to your web services.

You can check the docs available for the Beta2 release where you can find for yourself the means for doing all the things mentioned above.

Bogdan



hello.

pagerequestmanager is an important class and it's?only used when you define partial refreshing zones through updatepanels (ie, you generally don't use it directly in your code and it's injected on the page by the scriptmanager server control).

regarding the xmlhttpobject question, atlas introduces a network stack which has several layers. to communicate with the server, you can use the low level calsses or the high level classes.?the?object responsible?for?communicating?with?the?server?is?known?as?an?executor?(currently,?there's?only?one?executor,?XmlHttpExecutor,?which?uses?the?XmlHttpRequest?object?to?communicate?with?the?server?side).

normally, all remote requests are performed through the webrequest class, which let's you set several aspects of the current request (ex.: headers). if you want, you can use the high level classes (_webmethod class) or even generate a client javascript proxy (if your web service is hosted on an ajax enabled web site).

btw, you should note that web service calls don't depend on the scriptmanager control. having said this, it's important to note that?if?you're?developing?an?aspx?page,?then?you?can?also?add?theproxies?to?the?page?through?the?services?property?of?that?control.
hello.

just one more note: currently, there are 2 executors. the 2nd one is on the preview bits and it's called iframeexecutor.

Hi guys,

Sorry for my late response. i gave up the hope for an answer. Thanks for your replies. The reason why i posted this question is that i was reading a book about the old school AJAX technology. And as you will also know, they are working a lot with the XMLHTTPRequests (XHR). So i was curious on what layer did Microsoft build to abstract the direct calls with the XHR object. So i was interested in the whole proces from the scriptmanager to the XHR object.

So is it correct that the webrequestmanager is the layer which is responsible for managing the communication (XMLHTTPExecutor, XHR) for client side to server side. But i dont see the connection between the Pagerequestmanager / Sciptmanager and the webrequestmanager. Thanks in advance.

Regards,

PageRequestManager updatePanelIds issue

Hi,

I'm trying to use and update panel on a page that uses a master page. I've noticed that the uniquePanelId's in the pageRequestManager xml-script are separated by ":" not by "$". Because of this atlas is not finding my update panel.

1. Is there a setting I'm missing that determines what the separator is?

2. If not the above is there a way to modify the atlas.js function uniqueIdtoClientId to include the ":" character? right now the code is:

function uniqueIDToClientID(uniqueID) {return uniqueID.replace(/\$/g,'_');

}

3. Or any other suggestions.

This only seems to happen when I use a master page.

Has anyone ever come up for a soluation to this problem?

I'm running into it with an update panel being on a user control.

PageRequestManager Question

Hello,

I have an update panel which contains a gridview control. When the update panel refreshes or there is a partial postback I would like an indicator that this event has occured in my client side script. I plan to use an if/then statement based on this. I believe this can be done by using an instance of the PageRequestManager class. Could you provide an example of this?

Thanks,

-Robert

It sounds like this tutorial goes over what you're looking for:

http://ajax.asp.net/docs/tutorials/AnimateUpdatePanels.aspx

In your handler for the pageLoaded event, you use the panelsUpdated property to figure out which panels were updated. You can then show whatever indicator you want based on that information.

PageRequestManager only processes one asynch callback at a time?

I was under the impression that the asp.net ajax framework was capable of handling multiple asynch callbacks simultaneously and processing the results of each in the order that they come back. However, I accidentally discovered something interesting: it seems that if you begin an asynch callback from the browser while a previous asynch callback is still in process, the first one gets cancelled by the client-side PageRequestManager instance before it begins the second one.

To see what I'm talking about, you can go to this official MS ajax example:http://ajax.asp.net/docs/Samples/System.Web.UI.UpdateProgress1/cs/Default.aspx

Try clicking the first button, then quickly clicking the second button before the first date gets updated on the page. Notice that after a few seconds, the second date changes as a result of the second asynch callback, but the first date never gets updated. This is because the asp.net ajax framework is prematurely ending the first request as soon as you initiate the second request by clicking the second button.

I'm working on a project with multiple UpdatePanels on a page that do completely separate things in their server-side code, and ideally we would like the user to be able to initiate a callback in one panel and then immediately initiate a callback in the second panel, and have both of the asynchronous callbacks processing at the same time. At the moment, it doesn't seem like this is a possibility in the asp.net ajax framework.

If anybody can tell me how I might be able to get around this issue I would be very appreciative.

hello.

well, what you ask isn't doable with the current code of the platform. you can only have more than one remote call if you're using web services (and even in these cases you might face some problems which have been described here: http://www.codeproject.com/Ajax/aspnetajaxtips.asp)

PageRequestManager events being called too many times

I'm studying the PageRequestManager event lifecyle. It appears that when the number of times i click the linkbutton to perform the asynch postback, that same number of times the event is being called. Here's the scenario: I click the linkbutton once. Alerts for all events are called. I click the linkbutton once again. Alerts for all events are called twice. I click the linkbutton once again. Alerts for all events are called 3x. ... etc. Heres the sample code:

/*************************** aspx code ************************/

<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Path="AsynchronousLifeCycle.js" />
</Scripts>
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Date: "></asp:Label><br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Push me!" />
</ContentTemplate>
</asp:UpdatePanel>
</form>

/******** js code *************************************/

Sys.Application.add_load(ApplicationLoadHandler)
Sys.Application.notifyScriptLoaded();


function ApplicationLoadHandler(sender, args)
{
Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(InitializeRequest);
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequest);
Sys.WebForms.PageRequestManager.getInstance().add_pageLoading(PageLoading);
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(PageLoaded);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequest);
}

function InitializeRequest(sender, args)
{
alert("InitializeRequest");
}

function BeginRequest(sender, args)
{
alert("BeginRequest");
}

function PageLoading(sender, args)
{
alert("PageLoading");
}

function PageLoaded(sender, args)
{
alert("PageLoaded");
}

function PageLoaded(sender, args)
{
alert("PageLoaded");
}

function EndRequest(sender, args)
{
alert("EndRequest");
}

hi,

Please refer below URL:

http://ajax.asp.net/docs/ClientReference/Sys.WebForms/PageRequestManagerClass/PageRequestManagerBeginRequestEvent.aspx

Thanks

kishore

www.relgo.com.

PageRequestManager endRequest event not always firing

Hi,

I am using the ModalUpdateProgress control (http://www.codeproject.com/Ajax/ModalUpdateProgress.asp) and this hooks up an event handler to the PageRequestManager endRequest event but this is not always getting fired in Opera and Firefox. I can repro the problem in Opera but not FF (one user has reported this in FF).

I have posted a message to the forum for this control but thought that it might be a wider problem related to ASP.NET AJAX.

Any ideas?

Thanks,

Jason

Hi,Jason

Have you tested the PageRequestManager endRequest event without ModalUpdateProgress control?

If the PageRequestManager endRequest event always firing in other cases(I mean without PageRequestManager),The issue can be only a ModalUpdateProgress issue rather than an AJAX issue~

Thanks


Hi,

I tested hooking into the endRequest event manually (without the ModalUpdateProgress control) and it still doesn't get fired on this one page using Opera. It seems to work on all other pages though:

function pageLoad()
{
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequest);
}
function endRequest(sender, arg)
{
alert("here");
}

So, it does appear to be an issue with ajax rather than just the ModalUpdateProgress.

Any suggestions as to how I can debug this further?

Thanks,

Jason


OK...after discovering the error console in the Opera browser, I was able to determine that the problem is being caused by sliders within a modalpopup. These are generating a JS error that has a ripple on effect that breaks my pageLoad scripts, thereby preventing the endRequest from getting called. I have logged a bug report in codeplex for the sliders and will put protective code in my pageLoad scripts so that they don't error.

PageRequestManager blocks any other instance of XMLHttpRequest?

I'm trying to implement a progress bar that reports on the contents of session variables during the course of a slow method on one of my pages. The slow method in question populates/updates a datagrid inside an update panel.

I'm aware that it's only possible to have one request at a time using PageRequestManager, so i thought i would use some of my old own ajax libraries, and make a manual call to a webservice which would return the contents of the relevant session variables. However, even using this approach, the call to the webservice does not go through until the slow method has finished, which is obviously not ideal. Does PageRequestManager block any other instances of XmlHttpRequest on the page?

I read an article that suggested what i was attempting to do was possible using PageMethods, but since the latest release, where pagemethods have to not only reside in the aspx file but also have to be static, this is just not feasible.

I'd be grateful if anyone could shed some light on this, cheers

I'm not sure if something is awry with my installation, but now i am unable to request any other page from within the current application whilst the ajax request is in process - it just hangs, and then processes when the current ajax operation is complete. For slow methods that retrieve a lot of data, i'm sure you can see why this is almost ludicrous behaviour. Surely this isn't intended?

hello.

in previous releases, you could only make a partial refresh at a time (ie, you could only start a partial refresh after a previous one ended). in the last version, i think this has been changed and now what happens is that the last request overrides the previous one. this only happens when you're using UpdatePanels (ie, the behavior i've described only happens when you use updatepanels). you can still use xmlhttprequest as you see fit in your pages and you should be able to make several calls.


Thanks for the reply.

Are you aware of any other scenario in which setting a long running method running on one page would block any other requests to other pages within the same application until it is complete? I'm not accessing or modifying session data in either page.

Cheers


hello.

well, even though you're not using session data, it all depends on the way your final page is rendered. for instance, i think that if you don't set the enableSessionstate attribute on the page directive, the page will still use read/write session state. do you think that this might be the problem you're having?


I was unaware i had to specifically set the enableSessionState directive to "false" - even "readonly" still made the page block.

Thanks a lot for the help, appreciated.