469,648 Members | 1,182 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,648 developers. It's quick & easy.

autopostback - javascript intercept and cancel

Hi All,

How do I intercept an autopostback on the client side
and prevent it from executing the submit?

In classic ASP I used to intercept the on_submit and
just

return false;

but it doesn't seem to work anymore.

Any ideas?

Sincerely,
S
Nov 17 '05 #1
2 6320
Hi Susan,

Please add the javascript function to your server control
as given below.
Button1.Attributes.Add("onclick", "return FunctionName
();");

Now put the function in html section. If success then you
can return true else false.

So it wont submit the page if client side function fails.

Let me know if you ned furtehr help.
Regards
Sreejumon

-----Original Message-----
Hi All,

How do I intercept an autopostback on the client side
and prevent it from executing the submit?

In classic ASP I used to intercept the on_submit and
just

return false;

but it doesn't seem to work anymore.

Any ideas?

Sincerely,
S
.

Nov 17 '05 #2
The reason that doesn't work, is because by setting AutoPostBack to true,
that generates an onselectedindexchanged handler, which just submits the
form. So the one you created, just get ignored.

I would instead suggested that you turn autopostback to false, and just keep
your handler. This handler should then sometimes manually submit the form by
calling its submit method.

"Susan van Houen" <sv*****@hotmail.com> wrote in message
news:uE**************@TK2MSFTNGP12.phx.gbl...
Thank you for your response, but I can't get it to work.

My control looks like this
<asp:dropdownlist id="ddlPoi" style="Z-INDEX: 125; LEFT: 32px; POSITION:
absolute; TOP: 445px" runat="server"
OnSelectedIndexChanged="lbLocoptions_SelectedIndex Changed"
AutoPostBack="True">

When OnSelectedIndexChanged is fired I want it to pass through a client side javascript where I can evaluate if I actually want the autopostback to
complete or not.

In the Page_Load of the behind code I have

lbLocoptions.Attributes.Add("onselectedindexchange d", "return
lbLocoptions_onchange();")

and in the client I have

function lbLocoptions_onchange(){
return false;
}

Still, the AutoPostBack completes every time.

Sincerely,
S

"Sreejumon[MVP]" <sr********@hotmail.com> wrote in message
news:01****************************@phx.gbl...
Hi Susan,

Please add the javascript function to your server control
as given below.
Button1.Attributes.Add("onclick", "return FunctionName
();");

Now put the function in html section. If success then you
can return true else false.

So it wont submit the page if client side function fails.

Let me know if you ned furtehr help.
Regards
Sreejumon

-----Original Message-----
Hi All,

How do I intercept an autopostback on the client side
and prevent it from executing the submit?

In classic ASP I used to intercept the on_submit and
just

return false;

but it doesn't seem to work anymore.

Any ideas?

Sincerely,
S
.


Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Greg T | last post: by
8 posts views Thread by MrNobody | last post: by
reply views Thread by zoltix | last post: by
4 posts views Thread by Scott M. | last post: by
3 posts views Thread by Brad | last post: by
1 post views Thread by pleaseexplaintome | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.