Javascript before all postback

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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.
 
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
 
have you tried the this :

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

hope this helps..

alan
 
have you tried the form's onsubmit event??

Michel said:
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
 
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
 
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?
 
Back
Top