Preventing button postback

K

Kevin Lawrence

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
 
S

S. Justin Gengo [MCP]

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
 
S

S. Justin Gengo [MCP]

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
 
K

Kevin Lawrence

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
 
K

Kevin Lawrence

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
 
B

Bruce Barker

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top