473,404 Members | 2,178 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,404 software developers and data experts.

Can a web control's postback be blocked?

I know how to add a client side event event handler to a webcontrol button
using Attributes.Add, which gives me both client side and server side
events. Sometimes I need to only do the client side event and not do the
postback to the server at all. Is there a way to block the postback
altogether? The obvious thing would be to use a HTML button that only has
client side events, but then I would have a problem when I do need the
server side event.

Much obliged,
Geoff.
Nov 19 '05 #1
3 1407
Hi,
The post back to server will not happen if the client side function you are
calling in OnClick returns false. This will stop event bubling
Regards
Sambathraj
"Geoff" <Ge******************@NOSPAMwhs.mil> wrote in message
news:ua*************@TK2MSFTNGP15.phx.gbl...
I know how to add a client side event event handler to a webcontrol button
using Attributes.Add, which gives me both client side and server side
events. Sometimes I need to only do the client side event and not do the
postback to the server at all. Is there a way to block the postback
altogether? The obvious thing would be to use a HTML button that only has
client side events, but then I would have a problem when I do need the
server side event.

Much obliged,
Geoff.

Nov 19 '05 #2
I'm not totally clear on what you're doing, but you could perhaps do
the following:

*Add both an HTML button and a webcontrol button to the page, but set
the visible property of the webcontrol button to false so that it can't
be clicked directly by the user.

*In your client side click handler for your HTML button, force a
postback from the webcontrol button by calling

__doPostBack('webcontrolbuttonid','');

Passing the id of the web control button as a parameter. This will
kick of the server side event handler for your web control button. You
can also pass additional parameters in the second argument (I left it
empty) and pick them up in the page with

Request.Form("__EVENTARGUMENT")

although you may not need it here. I'm assuming that in your client
side event handler for the HTML button, you would determine whether or
not you should be firing the server side handler and do so when it
makes sense to do so.

Bill E.
Hollywood, FL

Nov 19 '05 #3
Thanks, that did the trick.

Geoff.

"Sambathraj" <v_***********@hotmail.com> wrote in message
news:ue**************@TK2MSFTNGP15.phx.gbl...
Hi,
The post back to server will not happen if the client side function you
are calling in OnClick returns false. This will stop event bubling
Regards
Sambathraj
"Geoff" <Ge******************@NOSPAMwhs.mil> wrote in message
news:ua*************@TK2MSFTNGP15.phx.gbl...
I know how to add a client side event event handler to a webcontrol button
using Attributes.Add, which gives me both client side and server side
events. Sometimes I need to only do the client side event and not do the
postback to the server at all. Is there a way to block the postback
altogether? The obvious thing would be to use a HTML button that only has
client side events, but then I would have a problem when I do need the
server side event.

Much obliged,
Geoff.


Nov 19 '05 #4

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

Similar topics

5
by: Dan | last post by:
Hi, I'd like to find out the control that caused a postback to be raised. Obviously this could simply done in a control event handler. I am not going to do this method and would like no...
2
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
6
by: Angel | last post by:
I have a button, combo, and custom control that i created. When I click the button i want to set certain display properties of my custom control depending whats in the combo. I set those properties...
3
by: Benjamin Gavin | last post by:
Hi all, I recently stumbled upon a bug in the ASP.NET framework handling of ImageButton based postbacks. The issues derives from the fact that IE and Mozilla handle the case of a missing image...
7
by: Anand | last post by:
Hi All, The postback on my desktop stopped working. I am trying to run the webapplication locally on my desktop and the Postback on my home page won't trigger on any of my dropdown selections. The...
0
by: Mariano Padilla | last post by:
I have a form that has 12 Calendar, 1 for each month. I am retrieving information from a database separately, assigning them to an array and then in the DayRender Event, itterating through the...
8
by: Mats Lycken | last post by:
Hi, I'm working on a webproject where I have several different user controls loaded on a WebForm. A problem arises when I in one webcontrol makes a change that should be picked up by another user...
1
by: Timbo | last post by:
Hi all, This is my first message here so i'll try and include all the information that will help you help me out, if possible. Basically I am using C# in ASP.NET 2.0 and have a Repeater...
2
by: ChrisCicc | last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have...
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
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
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...
0
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...

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.