Showing posts with label events. Show all posts
Showing posts with label events. Show all posts

Monday, March 26, 2012

pagerequest manager events seems to be raised to many times by the browser

Hello,

I have the next issue in my web application.

On server i'm sending to the client during a server event with registerdataitem a string -an url.

On client in pageloading i'm getting the url and showing into a popup window. This is the code:

var

wind=null;

var

currenturl=null;

var

i=0;

Sys.Application.add_load(ApplicationLoadHandler);

function

ApplicationLoadHandler(sender, args)

{

//Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

Sys.WebForms.PageRequestManager.getInstance().add_pageLoading(pageLoadingHandler)

}

//function EndRequestHandler(sender, args)

function

pageLoadingHandler(sender, args)

{

var dataItems = args.get_dataItems();

wind=document.getElementById(

'popupid');if (wind!=null)return;if (document.title.indexOf("Print")>=0)

currenturl=dataItems[

'ctl00_currenturl'];else

currenturl=dataItems[

'currenturl']if (currenturl !=null )//show the popup

{

wind=window.open(currenturl,

'popupid');

//DeleteFile(dataItems['currenturl']);works fine only on ie this solution

}

}

The problem is that the ajax pagerequestmanager event is raised too many times making the popup to be created to many time and sometimes browser to run out of resources.

How could i fix it i mean the pagerequestmanager event to be raised normaly i mean once.

I 'm using ie 6.5

Thanks

Hi,

Please use try this code snippet:

Sys.Application.add_load(ApplicationLoadHandler)

function ApplicationLoadHandler(sender, args)
{
var prm = Sys.WebForms.PageRequestManager.getInstance();
if (!prm.get_isInAsyncPostBack())
{
prm.add_pageLoading(pageLoadingHandler);
}
}

Hope this helps.

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.

Saturday, March 24, 2012

Pages lifecycle with UpdatePanel.

It seems to me that I read an article says when I use an UpdatePanel not all events are rising.

Help me find the list of the events that are rising with UpdatePanel.

Thank you in advance,

Igor

Hi,

when an UpdatePanel performs a partial postback, the whole page lifecycle is executed, thus all the server-side events are being raised.


Garbin:

when an UpdatePanel performs a partial postback, the whole page lifecycle is executed, thus all the server-side events are being raised.

Thank you.


Garbin:

when an UpdatePanel performs a partial postback, the whole page lifecycle is executed, thus all the server-side events are being raised.

Thank you.


Luckily the ASP.NET team put a funky ittle feature into Atlas which will let you detect if you're in a Partial render or not.

Here's some code I put together to show this in action and how you can use it: -

1<%@. Page Language="C#" AutoEventWireup="true" CodeFile="PostBackType.aspx.cs" Inherits="PostBackType" %>23<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">4<html xmlns="http://www.w3.org/1999/xhtml">5<head runat="server">6 <title>Untitled Page</title>7</head>8<body>9 <form id="form1" runat="server">10 <atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />11 <div>12 <asp:Button ID="MyNormalButton" runat="server" Text="Cause Normal Postback" />13 <atlas:UpdatePanel ID="Panel1" runat="server">14 <ContentTemplate>15 <asp:Button ID="MyButton" runat="server" Text="Cause Partial Render Postback" />16 <h1 id="MyMessage" runat="server"></h1>17 </ContentTemplate>18 </atlas:UpdatePanel>19 </div>20 </form>2122 <script type="text/xml-script">23 <page xmlns:script="http://schemas.microsoft.com/xml-script/2005">24 <references>25 </references>26 <components>27 </components>28 </page>29 </script>30</body>31</html>

Then the C#

1using System;2using System.Data;3using System.Configuration;4using System.Web;5using System.Web.Security;6using System.Web.UI;7using System.Web.UI.WebControls;8using System.Web.UI.WebControls.WebParts;9using System.Web.UI.HtmlControls;10using Performance;111213public partialclass PostBackType : System.Web.UI.Page14{15protected void Page_Load(object sender, EventArgs e)16 {17 SetMessage();18 }1920private void SetMessage()21 {22switch (GetPostBackType())23 {24case PostBack.NotPostBack:25 MyMessage.InnerText = ("Not a Postback");26break;27case PostBack.NormalPostBack:28 MyMessage.InnerText = ("Normal Postback");29break;30case PostBack.PartialRenderPostBack:31 MyMessage.InnerText = ("Partial Render");32break;33 }34 }3536private PostBack GetPostBackType()37 {38if (!Page.IsPostBack)39 {40return PostBack.NotPostBack;41 }42else if ((Page.IsPostBack) && (!ScriptManager1.IsInPartialRenderingMode))43 {44return PostBack.NormalPostBack;45 }46else if ((Page.IsPostBack) && (ScriptManager1.IsInPartialRenderingMode))47 {48return PostBack.PartialRenderPostBack;49 }50else51 {52throw new System.NotSupportedException("This kind of Postback is not currently catered for");53 }54 }55}

NICE!!Thanks for the excellent illustration.

and for those of you doing this from a usercontrol, the code would change a little to something like this:

Dim

tempControl2As System.Web.UI.ScriptManager

tempControl2 =

CType(Page.FindControl("ScriptManager1"), System.Web.UI.ScriptManager)IfNot tempControl2.IsInAsyncPostBackThen

Painting and mouse events in asp .net

Hello

I want to make a control like paint in windows by using Atlas. So I must to handle the mouse events in asp .net and can use Atlas. Do you have any knowledge or document about this? I could not find enough information until now. And for painting,is there any control or property in Atlas and AtlasControlToolkit

You'd be better off using Macromedia Flash for something like that.
Is not there any solution by using .NET?
Not really usingASP .NET, which is designed for web applications. What you want to achieve sounds far more suited to a stand-alone Windows forms application. You could use the .NET framework for that. I think you need to realise that web applications, that run on a remote server and support many clients via a browser, differ greatly from Windows client programs, that run on a location machine. The only way you can capture mouse events in ANY web application, written in any language, is via JavaScript or using browser-plugins (like Flash or ActiveX controls). Javascript, however, runs on the client and cannot easily talk back to the server were your .NET application is running. You can perhaps look at Ajax, but this would probably be too advanced, I think.

Hello,Thank you.

Is not there any solution by using Atlas. And what do you think about transfering sound. For example for a chat program which is prepared by asp .net, users can communicate by voice not only keyboards. Can you help me about