Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP Buttons

Status
Not open for further replies.

BurcBoyar

Programmer
Feb 18, 2002
24
0
0
TR
Is there a way to disable ASP buttons? (not hide, just disable)
Thanks for answers...
 
When you say ASP buttons, do you mean form inputs such as submit or button?

If so, you can use the disabled property (disabled=true).

To enable and disable dynamically I don't think you can do it in ASP, but you can do it client-side in javascript or vbscript, using something like, for example...

If something then
frmForm.ButtonName.Disabled = true
end if
 
Well, thanx for your answer sweevo. I think that the best way to do is vbscript too. I just wanted to know if there is a way with ASP too.
 
You could send the HTML back to the browser with the DISABLED attribute set for the button inside the button tag. This would sort of be using ASP to do it. The question I would have is do you want to disable the button under program control and if so when.
 
rkfox, I have an ASP page with four buttons; first, prior, next and last and a memo box. I'm getting the text of memo from a database. The problem is when it is at the beginning of the database I want to disable first and prior buttons, and when it is at the end last and next buttons.
 
Off the top of my head try something along the lines of:

<% 'All you DB connecion stuff etc here

response.write &quot;<form name=frmName method=Post action=whatever.asp>&quot;

if recordsetname.BOF then
response.write &quot;<input type=button name=name value=prev&quot; & _
&quot;disabled=true>&quot;
elseif recordsetname.EOF then
response.write &quot;<input type=button ... =next disabled=true&quot;
end if
%>

Might be better to do separate if blocks for both BOF and EOF...

if rs.BOF then
response.write &quot;<input .... first.... disabled=true>&quot;
response.write &quot;<input .... prev .... disabled=true>&quot;
else
response.write &quot;<input .... first....>&quot;
response.write &quot;<input .... prev ....>&quot;
end if

if rs.EOF then
response.write &quot;<input .... last.... disabled=true>&quot;
response.write &quot;<input .... next.... disabled=true>&quot;
else
response.write &quot;<input .... last....>&quot;
response.write &quot;<input .... next....>&quot;
end if

This will build your form dynamically depending on the recordset gained from your database.

Just some a quick examples for you to play around with.

Hope that is useful.
 
Yeah, it worked out. Thanx for your help sweevo...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top