473,397 Members | 1,960 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,397 software developers and data experts.

Javascript before all postback

Hi all,

Is there some intelligent way to trigger a clientside JavaScript function
before a postback is triggerd by any of the controls on a page?

Thanks in advance,
Michel Mathijssen
Jul 21 '05 #1
7 2934
Michel wrote:
Is there some intelligent way to trigger a clientside JavaScript function
before a postback is triggerd by any of the controls on a page?

Use the document.onunload event. This event is invoked before the page
is posted back.

Anders Norås
http://dotnetjunkies.com/weblog/anoras/
Jul 21 '05 #2
However, this event also happens when the user navigates to a different
page, even if it is just by typing in a different we address. It also
occurrs when the user closes the browser window. There is no way to tell the
difference as to why the event is running.

"Anders Norås [MCAD]" <an**********@objectware.no> wrote in message
news:OL****************@TK2MSFTNGP15.phx.gbl...
Michel wrote:
Is there some intelligent way to trigger a clientside JavaScript function before a postback is triggerd by any of the controls on a page?

Use the document.onunload event. This event is invoked before the page
is posted back.

Anders Norås
http://dotnetjunkies.com/weblog/anoras/

Jul 21 '05 #3
Hi, Thanks for the idea, it was very promissing, and I thought it surely
would solve my problem. But:

What I need to do is select entries al the items from a selectbox, which has
changed on the clientsite. This entries needs to be submitted together with
all the other form information. When I put this script in the onUnload event
of the body, it did select the needed data, but it is not added to the form
data posted back to the server. (Probably because the data to post is
allready gathered, and maybe even sent back, when the onUnload event occures.)

I also tried to put it in the onsubmit event of the form. (alert('test');
but the code generated contained "if (!ValidatorOnSubmit()) return false;
alert('test');", and the alert was never executed, although there is no
invallid data on the page.

Is their another way to execute a Javascript function before the postback is
done?

Thanks in advance,

Michel
"Marina" wrote:
However, this event also happens when the user navigates to a different
page, even if it is just by typing in a different we address. It also
occurrs when the user closes the browser window. There is no way to tell the
difference as to why the event is running.

"Anders Norås [MCAD]" <an**********@objectware.no> wrote in message
news:OL****************@TK2MSFTNGP15.phx.gbl...
Michel wrote:
Is there some intelligent way to trigger a clientside JavaScript function before a postback is triggerd by any of the controls on a page?

Use the document.onunload event. This event is invoked before the page
is posted back.

Anders Norås
http://dotnetjunkies.com/weblog/anoras/


Jul 21 '05 #4
have you tried the this :

<form id="Form1" method="post" runat="server" onsubmit="Test();"></form>

hope this helps..

alan

"Michel" wrote:
Hi, Thanks for the idea, it was very promissing, and I thought it surely
would solve my problem. But:

What I need to do is select entries al the items from a selectbox, which has
changed on the clientsite. This entries needs to be submitted together with
all the other form information. When I put this script in the onUnload event
of the body, it did select the needed data, but it is not added to the form
data posted back to the server. (Probably because the data to post is
allready gathered, and maybe even sent back, when the onUnload event occures.)

I also tried to put it in the onsubmit event of the form. (alert('test');
but the code generated contained "if (!ValidatorOnSubmit()) return false;
alert('test');", and the alert was never executed, although there is no
invallid data on the page.

Is their another way to execute a Javascript function before the postback is
done?

Thanks in advance,

Michel
"Marina" wrote:
However, this event also happens when the user navigates to a different
page, even if it is just by typing in a different we address. It also
occurrs when the user closes the browser window. There is no way to tell the
difference as to why the event is running.

"Anders Norås [MCAD]" <an**********@objectware.no> wrote in message
news:OL****************@TK2MSFTNGP15.phx.gbl...
Michel wrote:
> Is there some intelligent way to trigger a clientside JavaScript

function
> before a postback is triggerd by any of the controls on a page?
Use the document.onunload event. This event is invoked before the page
is posted back.

Anders Norås
http://dotnetjunkies.com/weblog/anoras/


Jul 21 '05 #5
have you tried the form's onsubmit event??

"Michel" wrote:
Hi, Thanks for the idea, it was very promissing, and I thought it surely
would solve my problem. But:

What I need to do is select entries al the items from a selectbox, which has
changed on the clientsite. This entries needs to be submitted together with
all the other form information. When I put this script in the onUnload event
of the body, it did select the needed data, but it is not added to the form
data posted back to the server. (Probably because the data to post is
allready gathered, and maybe even sent back, when the onUnload event occures.)

I also tried to put it in the onsubmit event of the form. (alert('test');
but the code generated contained "if (!ValidatorOnSubmit()) return false;
alert('test');", and the alert was never executed, although there is no
invallid data on the page.

Is their another way to execute a Javascript function before the postback is
done?

Thanks in advance,

Michel
"Marina" wrote:
However, this event also happens when the user navigates to a different
page, even if it is just by typing in a different we address. It also
occurrs when the user closes the browser window. There is no way to tell the
difference as to why the event is running.

"Anders Norås [MCAD]" <an**********@objectware.no> wrote in message
news:OL****************@TK2MSFTNGP15.phx.gbl...
Michel wrote:
> Is there some intelligent way to trigger a clientside JavaScript

function
> before a postback is triggerd by any of the controls on a page?
Use the document.onunload event. This event is invoked before the page
is posted back.

Anders Norås
http://dotnetjunkies.com/weblog/anoras/


Jul 21 '05 #6
Yes I have. But it does not work either. The script is executed, but the form
data submitted does not contains my data.

My script selects all the listoptions in a selectbox. (This listbox was
altered at clientside, and I need to retrieve a list of all the options in
this selectbox. To do that, my script have to select all the options, before
the form data is submitted)

Is it possible that the data is allready gathered before ValidatorOnSubmit
function is executed? (My own function is executed after the
ValidatorOnSubmit function)

Michel

"[Alan Flores]" wrote:
have you tried the form's onsubmit event??

"Michel" wrote:
Hi, Thanks for the idea, it was very promissing, and I thought it surely
would solve my problem. But:

What I need to do is select entries al the items from a selectbox, which has
changed on the clientsite. This entries needs to be submitted together with
all the other form information. When I put this script in the onUnload event
of the body, it did select the needed data, but it is not added to the form
data posted back to the server. (Probably because the data to post is
allready gathered, and maybe even sent back, when the onUnload event occures.)

I also tried to put it in the onsubmit event of the form. (alert('test');
but the code generated contained "if (!ValidatorOnSubmit()) return false;
alert('test');", and the alert was never executed, although there is no
invallid data on the page.

Is their another way to execute a Javascript function before the postback is
done?

Thanks in advance,

Michel
"Marina" wrote:
However, this event also happens when the user navigates to a different
page, even if it is just by typing in a different we address. It also
occurrs when the user closes the browser window. There is no way to tell the
difference as to why the event is running.

"Anders Norås [MCAD]" <an**********@objectware.no> wrote in message
news:OL****************@TK2MSFTNGP15.phx.gbl...
> Michel wrote:
> > Is there some intelligent way to trigger a clientside JavaScript
function
> > before a postback is triggerd by any of the controls on a page?
> Use the document.onunload event. This event is invoked before the page
> is posted back.
>
> Anders Norås
> http://dotnetjunkies.com/weblog/anoras/

Jul 21 '05 #7
It seems that an form.submit() does not trigger the onSubmit function,
therefore the adding the script to the onsubmit will cause the function not
to be executed when a postback is called.

Does anyone have another idea how to call my Javascript function when a
postback is done?

"[Alan Flores]" wrote:
have you tried the form's onsubmit event??

"Michel" wrote:
Hi, Thanks for the idea, it was very promissing, and I thought it surely
would solve my problem. But:

What I need to do is select entries al the items from a selectbox, which has
changed on the clientsite. This entries needs to be submitted together with
all the other form information. When I put this script in the onUnload event
of the body, it did select the needed data, but it is not added to the form
data posted back to the server. (Probably because the data to post is
allready gathered, and maybe even sent back, when the onUnload event occures.)

I also tried to put it in the onsubmit event of the form. (alert('test');
but the code generated contained "if (!ValidatorOnSubmit()) return false;
alert('test');", and the alert was never executed, although there is no
invallid data on the page.

Is their another way to execute a Javascript function before the postback is
done?

Thanks in advance,

Michel
"Marina" wrote:
However, this event also happens when the user navigates to a different
page, even if it is just by typing in a different we address. It also
occurrs when the user closes the browser window. There is no way to tell the
difference as to why the event is running.

"Anders Norås [MCAD]" <an**********@objectware.no> wrote in message
news:OL****************@TK2MSFTNGP15.phx.gbl...
> Michel wrote:
> > Is there some intelligent way to trigger a clientside JavaScript
function
> > before a postback is triggerd by any of the controls on a page?
> Use the document.onunload event. This event is invoked before the page
> is posted back.
>
> Anders Norås
> http://dotnetjunkies.com/weblog/anoras/

Jul 21 '05 #8

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

Similar topics

14
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net...
12
by: Mark Fox | last post by:
Hello, I am attempting to do something very simple. I have a page MainPage.aspx and a popup window Popup.aspx. When users click on the linkbutton in the popup window I am looking to do some...
2
by: Bruce W.1 | last post by:
There's something I can't figure out. I added some javascript behavior to my datagrid, just like in this article, except in C# instead of VB: ...
21
by: Martin Eyles | last post by:
I am trying to get javascript to cause a page to post back. I have tried calling _doPostBack from my script, but generates an error "object expected". I think this is because the page's script...
2
by: Alan Silver | last post by:
Hello, I have just discovered that if you turn off Javascript, then cross-page posting does not work. The postback goes to the originating page, which basically means that nothing happens. I...
3
by: vinay | last post by:
Hi All I have a page in which i using user control .on user control i using javascript to pop up a message .when i choose wrong date in user control & submits the page it alerts the message of...
4
by: =?Utf-8?B?T3Bh?= | last post by:
Hi, I'm not sure if the title is correct. Here's what I am having trouble with: I have a server side button control where I am calling a javascript function via the OnClientClick property. I...
8
by: Deft.Jab | last post by:
This problem only exists in IE, due to UI restrictions I'm using a href in an error label to bring up a modal popup. I'm using a callback to filter a grid on the popup. The problem: The href...
4
by: Peter | last post by:
ASP.NET I have an application which use ASP.NET Autocomplete extender which works great. But I have a question how to update all the fields on the screen using Ajax. Users starts typing in a...
2
Frinavale
by: Frinavale | last post by:
JavaScript in ASP.NET Using JavaScript in ASP.NET pages can make your application seem to work faster and prevent unnecessary calls to the server. JavaScript can be used to perform client-side...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.