PostBack Question

  • Thread starter Thread starter Jeffrey A. Voigt
  • Start date Start date
J

Jeffrey A. Voigt

What is the best way to tell when a page is posted back (if it was due to a
button click, or if it was due to a form.submit() function begin called)?

The reason why I'm asking this is because I'm forcing a postback
(form.submit()) every 10 seconds and I need to know if the post back was due
to that OR if it was a valid button on the page being clicked.

Thanks,
- jv
 
IsPostBack()


--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.
 
I don't think you understand the quesiton. IsPostBack returns true when I
post back from javascript (form.submit() ) and it will be true if I click on
a button. I want a way to tell the difference between the two on the page
load event.

Thanks,
- jv
 
Aren't you worried that auto-posting that form every 10 seconds will annoy your users

Anyway, There a couple of ways that server side controls link events to the control clicked. Directly submitting the form, like buttons, or by executing a small piece of client side code to set the EVENTTARGET and the EVENTARGUMENT and then submitting programatically. This allows the server to fire the appropriate event(s) for the selected control. Controls that require the client side code, such as hyperlink columns in a datagrid, will not fire any event if you do not set the target and argument

It sounds like what you want to do is save the form on every postback and then take an additional action if the user clicked a particular button. If so, I suggest saving of the form via your standard post back handler, then handle the exception by mapping an event handler to the Click event of your buttons

Hope that help

Joh
 
Just to answer your first question, the user won't even know there was a
post back (unless there are changes in a database table). The screen will
not flicker and/or refresh at all.

Thanks for the answer though.. that will work!

John Scragg said:
Aren't you worried that auto-posting that form every 10 seconds will annoy your users?

Anyway, There a couple of ways that server side controls link events to
the control clicked. Directly submitting the form, like buttons, or by
executing a small piece of client side code to set the EVENTTARGET and the
EVENTARGUMENT and then submitting programatically. This allows the server
to fire the appropriate event(s) for the selected control. Controls that
require the client side code, such as hyperlink columns in a datagrid, will
not fire any event if you do not set the target and argument.
It sounds like what you want to do is save the form on every postback and
then take an additional action if the user clicked a particular button. If
so, I suggest saving of the form via your standard post back handler, then
handle the exception by mapping an event handler to the Click event of your
buttons.
 
Back
Top