Showing posts with label framework. Show all posts
Showing posts with label framework. Show all posts

Wednesday, March 28, 2012

PageMethods

Hi,

I ama developing web application using ASP.NET, and I use atlas framework in my app. I have a problem with using PageMethods, I want to return value which came from page to another javascript but I can not,

Normal Page Method usage

function sayHelloFromPage() {

PageMethods.HelloWorld('Mehmet',onComplete);

}

function onComplete(result) {

}

what I wantto make it

functioncallSayHelloFromPage() {

var Result = sayHelloFromPage();

}

function sayHelloFromPage() {

PageMethods.HelloWorld('Mehmet',onComplete);

}

function onComplete(result) {

return result;

}

Hi

PageMethods.HelloWorld('Mehmet',onComplete);

The above call happens asynchronously, which means the call is send to the server and the client does not wait for the call to complete; therefore, you don't see the results immediately instead you have to get the results in the onComplete event, which is fired when the call completes.

Whatever you want to do with the results, e.g. change an HTML element, you have to do it in the onComplete function.

Monday, March 26, 2012

PageMethods vs UpdatePanel

Hi,

I am a big fan of using 'Update Panels'. Not because of the only simplicity but also bcoz of my belief on the AJAX framework.

Also Scott G has kept on introdcueicng lots of new features in UpdatePanel in Orcas/S 2008


But,still lots of architects do say that, PageMethods[http://metasapiens.com/PageMethods/Tutorial/VS2005/] are moreefficient than Update Panels.
Here is the link - ASP.NET AJAX UpdatePanels are dangerous.

http://encosia.com/2007/07/11/why-aspnet-ajax-updatepanels-are-dangerous/

Afterreading the page, I am quite suspicious on Update Panel and now thinkthat really PageMethods saves perfomance overhead.But at the same time,simply by going thru few pages, accepting the same seems to be quiteimpractical.

Please let me know, is really PageMethods are moreefficient than UpdatePanel. If yes, then please list me the things thatcannot be done using PageMethods, which can be done by UpdatePanel.

Regards,

Arun

take a look at the video byJoe Stagner

How Do I: Choose Between Methods of AJAX Page Updates?

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

It will show you the big diference...

And the response by the WebMethod, give you the freedom to manipulate and interact with the HTML elements (UI) way you want ..

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)

PageRequestManagerParserErrorException, is it due to web farm?

I implemented an ASP.NET 2.0 web application with the ASP.NET AJAX framework and the AJAX Control Toolkit. When I run it in my development pc, it works perfectly. But when it runs on a production server environment, which is a web farm, the following javascript error message prompts frequently on the browser:
Sys.WebForms.PageRequestManagerParserErrorException: This message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled. Details: Error parsing near '<!DOCTYPE html P'.
Anybody helps? It's my first project in my current company...

This problem is solved by adding a machinekey to the web.config.

PageRequestManagerParserErrorException with the New ASP.Net Ajax framework

I have two simple web pages with two update panels in them. The first one calls the second one using Server.Tranfer or Server.Execute and it gives the following error message:

Sys.WebForms.PageRequestmanagerParsererrorException: The Message received from the Server could not be Parsed. Common caused for this error are when the response is modified by calls to response.Write(), response filters, HttpModules, or server trace is enabled.

Now, this never happened with the previous framework, atlas. I've tried all possible solutions I could think of, but none worked so far.

Try to take a look at the following forums for?reference.
http://forums.asp.net/thread/1467462.aspx
Wish this can help you.

Saturday, March 24, 2012

Panel close button with AJAX

Hello All,

I want to use this wonderful AJAX Framework to something very simple:

Inside an UpdatePanel I have a Panel. Now just below the Panel I want to place a button or link that when clicked will hide the Panel and do this client side (without requiring a post back). I know how to do this with a postback and a method that sets Panel.Visible = false, but I don't want to call the server for this, just hide the Panel client side.

So I ask to the MS AJAX experts out there: what is the easy and elegant way of doing this with MS AJAX Framework and/or AJAX Control Toolkit.

Thank you!

David

Use this JS for the button/link click: $get('PanelClientID').style.display = 'none';


Hi Neutrino,

My understanding of what your want is to make your panel which is indside an UpdatePanel without any postbacks. If I have misunderstood, please feel free to let me know.

You can use $get(Panel's ClientID).style.display = 'none'. Here is the sample:

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"></script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Panel ID="Panel1" runat="server" Height="50px" Width="125px"><%=DateTime.Now.ToString()%> </asp:Panel> <asp:Button ID="Button1" runat="server" Text="Button"OnClientClick="return hidePanel()"/> </ContentTemplate> </asp:UpdatePanel> <script type="text/javascript" language="javascript">function hidePanel(){ $get("<%= Panel1.ClientID%>").style.display='none'; return false; } </script> </form></body></html>

Note: Please pay special attention to the part of "Bold". IfOnClientClick don't return false, a postback will be occured in this case.

Best regards,

Jonathan


Thanks to both. Great simple solution.