473,402 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Interuppted Postbacks

We have found a fundemental problem with the way that
postbacks are handled. We have a page that has about 60
postback controls that are posted back to the server when
the user clicks a link (LinkButton).

The page takes about 5 seconds to render. A problem occurs
when the user clicks the link, gets the page back to the
browser, then immediately clicks the postback link again.

In this situation the page has not finished rendering, but
gets interuppted and posts back the data to the server.

We find that only some of the postback items in the form
are being returned to the server. Instead of 60 items
coming back, we now have received only (say) 30 items.

The consequence of this, is that the postback controls
whose values were not passed back are now considered to be
blank. When the page renders again, the values of those
controls have been lost!

Someone must have come across this problem before?

How do we stop the user from pressing the postback button
before the page has finished rendering?

We thought of trapping the onSubmit of the form (in
JavaScript), but this only fires for real Submit buttons,
our postback control is a LinkButton. Alternatively, is
there a way to alter the standard __doPostBack function?

Or is there another solution?
Jul 21 '05 #1
4 1563
"Ben Barter" wrote:
We have found a fundemental problem with the way that
postbacks are handled. We have a page that has about 60
postback controls that are posted back to the server when
the user clicks a link (LinkButton).

<snip>

We thought of trapping the onSubmit of the form (in
JavaScript), but this only fires for real Submit buttons,
our postback control is a LinkButton. Alternatively, is
there a way to alter the standard __doPostBack function?


This can indeed be a problem; I solved it by extending the __doPostBack
function as you suggested.

Include some JavaScript in your application:

var blnSubmit = false;

// Grab the function of the original __doPostBack function

var __DotNet__doPostBack = __doPostBack;

// Replace the function with your own

__doPostBack = __Extended__doPostBack;

// Declare your own function

function __Extended__doPostBack(eventTarget, eventArgument)
{
if (blnSubmit == false)
{
blnSubmit = true;
__DotNet__doPostBack(eventTarget, eventArgument);
}
}

Code is not tested so it can (knowing me, *will*) contain errors. But you
get I idea.

Steven

- - -
Jul 21 '05 #2
Thanks for the code example. This is great for stopping
users pressing a submit button more than once.

However, the problem we have is trying to stop users
pressing a submit button before the page has completed
rendering.

I can use your code to stop the submit before the page
render. Unfortunately, pressing a submit button stops
rendering of the page, and we are left with an incomplete
page.
Jul 21 '05 #3
"Ben Barter" wrote:
I can use your code to stop the submit before the page
render. Unfortunately, pressing a submit button stops
rendering of the page, and we are left with an incomplete
page.


Ah, sorry, must have read your question too quickly.

A possible solution I see is to disable the submit button initially
(Enabled=false) and enable it again in JavaScript on the client when the
page is fully loaded: <body onLoad="Body_Onload();">. Build this client-side
function in your codebehind so you can you btnSubmit.ClientID to get the
client-side ID of your submit button.

As an alternative, you could use the previous code, but set blnSubmit to
"true" initially and set it to "false" on the onLoad event: <body
onLoad="blnSubmit = false;">. That way pressing the submit button will not
work before the page is fully loaded AND it can only be pressed once.

Steven

- - -
Jul 21 '05 #4

"N S S" wrote:
There is a client side window_onload Event, that fire when page is
fully loaded on the client


IIRC, this only works on IE without using onLoad="window_onload();"

Steven

- - -
Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jim Mitchell | last post by:
OK, have I come full circle.... ? 1) .NET with VS Studio seemed to be the answer to all my prayers. A) No more worries about coding for Netscape vs. IE. B) Quick Deployment C) All code in...
6
by: Jon Maz | last post by:
Hi All, I am experimenting with URL Rewriting using the techniques outlined by Scott Mitchell in his article "URL Rewriting in ASP.NET"...
3
by: Nelson | last post by:
My development environment is ASP.Net with VB.Net and .Net Framework 1.1. For a web control text box through client code(java script) I am changing the font color. After post the color is...
5
by: Dave | last post by:
(Second Try) Greetings, I have an asp.net web application that utilizes a User Control at the top of the page. My User Control contains a Server Control menu which will require postbacks. ...
3
by: John | last post by:
I have an asp.net control which on the first Load of the page has a unique ID something like: _ctl0__ctl1_GroupName__ctl1_ControlName and after the first postback it changes to: ...
4
by: Ben Barter | last post by:
We have found a fundemental problem with the way that postbacks are handled. We have a page that has about 60 postback controls that are posted back to the server when the user clicks a link...
0
by: gregfocker | last post by:
I installed the new RTM version of ASP.NET 2.0 AJAX Extensions 1.0 released on Tuesday (1/23). I made the required changes to the web.config file to go from the RC version to the RTM version. ...
1
by: Kursat | last post by:
Hi, I have a question about Ajax postbacks : - Does ASP.NET process multiple UpdatePanel postbacks in single thread when two or more different update panel postbacks occur at the same time for...
4
by: Nathan Sokalski | last post by:
I have 2 private variables in my class that I need to remember the values of between postbacks (or actually callbacks, since I am using AJAX). I want to avoid using session variables, if possible....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.