Link to home
Start Free TrialLog in
Avatar of curiouswebster
curiouswebsterFlag for United States of America

asked on

I need to enable and disable a button using JavaScript, ASP and ASP.NET

I have a simple request that I would like to create a test program which uses JavaScript to disable (then re-enable) an ASP button.  I would also like to see how the same thing's done with ASP.NET.

Maybe someone could post a simple program with two buttons where when you click one, it enables the other and disables the button you clicked.   I would love to see that in ASP as well as ASP.NET.

I would be happy to write it, but I think it may be easier for someone to write than explain.

Thanks,
newbieweb
Avatar of bluV11t
bluV11t
Flag of Norway image

Hi!
Here is the JavaScript version:


<input type="button" value="Disable" onclick="JavaScript: document.getElementById('third_button').disabled = true;" />
<input type="button" value="Enable" onclick="JavaScript: document.getElementById('third_button').disabled = false;" />
<input type="submit" value="3. button" id="third_button" />

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Tomarse111
Tomarse111
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of curiouswebster

ASKER

Tomarse111,

I used your code sinnce it was all in one place.  Could you do the same thing with ASP.NET? I'm trying to learn both technologies at the same time...


newbieweb
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Where would you put that line?  LLike this?

document.getElementById('bttn2').Enable = false;

what about the controls?  How are they different?
If you are referring to ASP.NET then it would go in your code behind.
This change would occur on the server and not on the client directly.
I see.  Code behind makes it easy for me to do: I'm a WinForms C# developer.  But I need to learn the HTML side of ASP.NET.

Thanks,
newbieweb

Then the JavaScript methods above are the ebst way.  Unless you want to do it all server side with a postback!