> Hi, I have to disable a button on a aspx page after the user clicks it.
I have to disable the button with javascript because the process takes
20 seconds to run the full course.
I kno I need to do this with javascript but I do not kno how.
Please tell me if you will please.
Note that javascript is not foolproof, as a lot of useragents may not be
running javascript. So, it's best to check this on the server if you can.
However, to do it via javascript, here's a method I recently used:
I wrapped my submit button in a div, and then created another div that said
'please stand by while we update the database':
<div id="updatebutto n"><asp:butt on /></div>
<div id="inprogress" >Please stand by...</div>
Then I added this javascript to my HEAD tags:
<script lang="javascrip t">
function standbyShow() { // hide all the divs
document.getEle mentById('inpro gress').style.d isplay = 'block';
document.getEle mentById('updat eButton').style .display = 'none'; }
</script>
and in my codebehind, I attached the above function to the onClick action of
the button:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
Form1.Attribute s.Add("onSubmit ", "standbyShow(); ")
End Sub
Now, in my case, I knew the people using this would have javascript (it's
for our intranet). For a public site, I'd go a step further and populate the
'standby' text in the second div via javascript as well, so that those
without javascript won't see this odd message.
-Darrel