473,322 Members | 1,734 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,322 software developers and data experts.

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 4424
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="btnCertifyAB" 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
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...
1
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...
2
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)...
5
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...
2
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();") ...
3
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...
7
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,...
1
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...
3
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....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.