473,785 Members | 2,396 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Preventing button postback

Hi

I need to be able to prevent a Server Button from posting back when clicked,
the reason for this is so I can use client-script to disable the button and
then when there is a postback to save its state...

Kev
Feb 7 '06 #1
6 4445
Add a HTML attribute: onclick="return false;"
"Kevin Lawrence" <sp******@spam. com> wrote in message
news:3a******** *************** ***@news.rmplc. co.uk...
Hi

I need to be able to prevent a Server Button from posting back when
clicked, the reason for this is so I can use client-script to disable the
button and then when there is a postback to save its state...

Kev

Feb 7 '06 #2
Kevin,

I have code in a Javascript component that I give away for free on my site
(including source code) that uses a javascript to disable a button after
it's clicked. The code first calls the microsoft javascript to check the
page validators so the button won't be disabled if the page won't be posted
back.

You may see a demo and download the code from here:
http://www.aboutfortunate.com?page=javascriptdemo (example #3)

The code is downloadable as a .NET 1.1 project. It's easily converted to
2.0. I'm working on converting many of the objects on my site, but haven't
finished yet.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Kevin Lawrence" <sp******@spam. com> wrote in message
news:3a******** *************** ***@news.rmplc. co.uk...
Hi

I need to be able to prevent a Server Button from posting back when
clicked, the reason for this is so I can use client-script to disable the
button and then when there is a postback to save its state...

Kev

Feb 7 '06 #3
Kevin,

I was in a rush here and re-reading your post I realize that what I posted
doesn't really apply to what you're doing here. Still I hope you find some
of the code useful.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Kevin Lawrence" <sp******@spam. com> wrote in message
news:3a******** *************** ***@news.rmplc. co.uk...
Hi

I need to be able to prevent a Server Button from posting back when
clicked, the reason for this is so I can use client-script to disable the
button and then when there is a postback to save its state...

Kev

Feb 7 '06 #4
Like this?

<asp:Button runat="server" ID="btnCertifyA B" EnableViewState ="true" onclick="return
false" OnClientClick=" this.disabled = true" Text="Certify" />

It doesn't seem to like it...

Kev
Add a HTML attribute: onclick="return false;"

"Kevin Lawrence" <sp******@spam. com> wrote in message
news:3a******** *************** ***@news.rmplc. co.uk...
Hi

I need to be able to prevent a Server Button from posting back when
clicked, the reason for this is so I can use client-script to disable
the button and then when there is a postback to save its state...

Kev

Feb 7 '06 #5
Ok, I added the onclick attribute and it works ok except when I want to query
the .Enabled property it's obviously enabled - how would I be able to tell
if the user has disabled if it won't post back the state?

Thanks
Kev
Add a HTML attribute: onclick="return false;"

"Kevin Lawrence" <sp******@spam. com> wrote in message
news:3a******** *************** ***@news.rmplc. co.uk...
Hi

I need to be able to prevent a Server Button from posting back when
clicked, the reason for this is so I can use client-script to disable
the button and then when there is a postback to save its state...

Kev

Feb 7 '06 #6
html doesn't postback state. a postback consists of only name/value pairs
for all input, select, and textareas in the posting form. if a submit button
is clicked, the browser include it in the name/value pair list.

if you need to have the browser send state, create a hidden field, and have
client script fill it in.

-- bruce (sqlwork.com)

"Kevin Lawrence" <sp******@spam. com> wrote in message
news:3a******** *************** ***@news.rmplc. co.uk...
Ok, I added the onclick attribute and it works ok except when I want to
query the .Enabled property it's obviously enabled - how would I be able
to tell if the user has disabled if it won't post back the state?

Thanks
Kev
Add a HTML attribute: onclick="return false;"

"Kevin Lawrence" <sp******@spam. com> wrote in message
news:3a******** *************** ***@news.rmplc. co.uk...
Hi

I need to be able to prevent a Server Button from posting back when
clicked, the reason for this is so I can use client-script to disable
the button and then when there is a postback to save its state...

Kev


Feb 7 '06 #7

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

Similar topics

5
3202
by: dje | last post by:
In the OnClick event on a radioButtonList, I run a javascript to show/hide the appropriate div along with a submit button, which displays as expected. The problem is the submit no longer works on the button. If I quit using the divs, and do a postback on the radiobutton selection, showing/hiding tables instead, the button is ok and continues to work. I've tried a variety of controls instead of the button in a variety of places but it...
1
3549
by: Miro | last post by:
I have a webform with lots of <asp:...controls but I need couple of buttons that doesn't cause an automatic postback. I use javascript to handle these buttons. I tried two approaches with different results: <IMG onmouseup="src='Bitmaps/Controls/measure_over.bmp';" onmousedown="src='Bitmaps/Controls/measure_pressed.bmp';" id="measure" onmouseover="src='Bitmaps/Controls/measure_over.bmp';" style="LEFT: 170px; WIDTH: 24px; POSITION:...
2
1435
by: MER78 | last post by:
I have two radio buttons (RB1 + RB2). The page starts with RB2 selected. Both are enabled. Action 1 - I press RB1 a postback event happens... but the event handler for RB1 (CheckedChanged) isn't called. Action 2 - I press RB2 a postback even happens... everything works good. Action 3 - I press RB1 a second time... postback event happens + the event
5
2647
by: | last post by:
Hi all, Has anyone been able to write some custom javascript on the onclick event of submit button to do certain things like disable submit button, only submit form once etc. This was a breeze in 1.1 since I could edit the .js file. Now in 2.0 I can no longer do this. Also, my code would have to be called after all client-side validation was done and was successful. Any ideas? TIA!
2
5957
by: darrel | last post by:
I am using a javascript WYSIWYG text editor for our CMS. To grab the proper content we need to add a javacsript call to the form: Form1.Attributes.Add("onSubmit", "myOnSubmitEventHandler();") That works fine. However, we also have some dropDownLists that trigger a postback. If we change these, I still need to update the text editor, so I added attributes to them:
3
3175
by: Bill | last post by:
I have a v2.0 site that has a form with a GO button which runs another application and then returns some data which is then processed and then I issue a response.redirect to another form to display the returned data. My problem is that it is possible for a user to click the button several times causing the external app to run several times. My first thought was to set the button.enabled = false as soon as it is clicked but that does...
7
4627
by: Tim_Mac | last post by:
hi, using .net 2.0, i have a web form with lots of textboxes, drop-down-lists etc. There are lots of required field validators and regular expression validators. When i click the 'save' button, the client-side validation is executed immediately and the errors flash up on screen. However at the same time, a post-back is performed and the page is obviously un-usable while it is awaiting a response from the server. it looks very poor from...
1
1261
by: gomzi | last post by:
hi, I have two buttons in my page. Now, the problem that I am facing is that , every time i refresh the page, the event of the button which was clicked last gets fired. I really don't know as to what might be going wrong here. any help would be appreciated, thanks, gomzi.
3
2051
by: gerry | last post by:
Sung the ASP.NET AJAX framework, and following the control creation examples from the ajax toolkit I have created a simple custom control that includes a button with a client side onClick handler. Returning false from the handler prevents postbacks in IE but in firefox the handler fires and does its thing but the postback still occurs as well. I read that changing this from an INPUT SUMIT to a BUTTON would fix this problem, however that to...
0
9645
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
10341
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10095
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
9954
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
8979
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
7502
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
5383
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.