473,769 Members | 6,697 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6586
Hi Susan,

Please add the javascript function to your server control
as given below.
Button1.Attribu tes.Add("onclic k", "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 onselectedindex changed 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*****@hotmai l.com> wrote in message
news:uE******** ******@TK2MSFTN GP12.phx.gbl...
Thank you for your response, but I can't get it to work.

My control looks like this
<asp:dropdownli st id="ddlPoi" style="Z-INDEX: 125; LEFT: 32px; POSITION:
absolute; TOP: 445px" runat="server"
OnSelectedIndex Changed="lbLoco ptions_Selected IndexChanged"
AutoPostBack="T rue">

When OnSelectedIndex Changed 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.At tributes.Add("o nselectedindexc hanged", "return
lbLocoptions_on change();")

and in the client I have

function lbLocoptions_on change(){
return false;
}

Still, the AutoPostBack completes every time.

Sincerely,
S

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

Please add the javascript function to your server control
as given below.
Button1.Attribu tes.Add("onclic k", "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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2221
by: Greg T | last post by:
Hi, I have a rather long form that I don't want people submitting unless they are absolutely sure they are ready. I figured the easiest way to prevent an accidental form submission by way of hitting of the enter key was to simply not have a submit button, instead going for a regular anchor which calls a javascript confirmation box and then submits the form.
8
21612
by: MrNobody | last post by:
How do I change a window's behavior so when someone clicks the little 'X' in the upper right corner it actually hides the dialog, instead of disposing it?
0
1351
by: zoltix | last post by:
Hi, I am beginner in aspx. I would like to intercept all click events on my document. I use this function in javascipt for that document.onmousedown=click;. It works well. But I would like to continue the execution code on a other button or anything else. Example 1) Click anywhere intercept click->Execute the code in function click().
8
9366
by: Matthew Louden | last post by:
why need to set autopostback property to be true?? I know autopostback event means to send the form to the server automatically. I tried checkbox, checkbox list, radio button, and radio button list, and they all need to set autopostback property to be true, in order to make the event of the control fires. I know this is the must, but I dont know why. Please advise! Thanks!
4
9048
by: Scott M. | last post by:
If I put RequiredFiledValidators on a page and set them up with corresponding TextBoxes everything works just fine. If I add a DropDownList and set its AutoPostBack to True, I am able to post data to the server WITHOUT the validators invoking their validation. It seems that the easiest solution would have been for MS to simply give the DropDownList control a "CausesValidation" property, but it does not have one. How can I invoke the...
3
4041
by: Brad | last post by:
The first text on my form is a numeric field. I have a javascript that runs on this field for onkeyup (validate the key strokes and modifies fields on the screen) but when I do this and have the autopostback on, the autopostback does not trigger. The autopostback will trigger if I hit the enter key while in the textbox but not when I leave focus. Here is the code for the textbox. <asp:textbox class="required" AutoPostBack="True"...
0
1648
by: Jonathan | last post by:
Hi Everyone, I have a problem which I've been able to reproduce with a nice and small test ASP.NET web application. The page sets the window.onbeforeunload event so that we will get an Ok/Cancel dialog box to prompt users before navigating away from the page. There are many different types of input buttons on the page (e.g. asp:Button, asp:ImageButton, asp:LinkButton, asp:DropDownList, asp:CheckBox) and most of them work fine. However,...
1
2717
by: pleaseexplaintome | last post by:
I have a datagrid with checkboxes and I can check/uncheck the checkboxes to update a database by calling my oncheckchanged function. I would like to add popup asking the users if they are sure they want to proceed. I have written a javascript function named confirm_duplicate and it works as expected - it checks/unchecks checkboxes depending on user response.
5
13054
by: robert | last post by:
I have a dropdownlist with the autopostback set to true. I want the user to be confirm whether they do indeed want to change the value, which on post back fires a server side event (selectedindexchanged). I have tried adding an onchange attribute "return confirm('sure u wanna change this?';") but it will not postback regardless of the confirm result and the value in the list does not revert back if cancel selected. Is there a solution?
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10050
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9999
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9866
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8876
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3570
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.