This may not be possible, but how can I on a button click, disable the button and then cause the postback? I imagine this needs to be done via javascript.
Hey ken just add some javascript that disables the button to the onclick attribute of the button. When you click it the javascript will run and a postback will still occur.
.Attributes.Add("","" That'l do donkey, that'l do
Mark
If you are unsure of forum etiquette check here faq796-2540
Ken I put this following code into my page_load event handler and things worked just fine.
Only difference I can see is that you have a ";" after you call your javascript function. That and I dynamically loaded the javascript function itself but that shouldn't make a difference.
Dim sb As New StringBuilder()
sb.Append("<Script Language=javascript>"
sb.Append("function DisableButton() {"
sb.Append("alert('Hi!');"
sb.Append("}"
sb.Append("</Script>"
The reason it doesn't work is that there is already an onclick event specified for the button (the one that does the postback). If you examine the html source, you'll see it.
The workaround that I've found for this situation is to add a regularly flavored html input button, and specify an onclick for that which first disables the button, and then
Are you sure about that Paul? My code did work. And when I view the source I only see this
<input type="submit" name="Button1" value="Button" id="Button1" /></P>
<P>
<input type="submit" name="Button2" value="Button" id="Button2" /></P>
No onclick events specified That'l do donkey, that'l do
Mark
If you are unsure of forum etiquette check here faq796-2540
Guys,
I actually found away to do it with the asp button. I had to add some code to the Attribute to set the Post Back Event Reference. Also I had to turn Client Validation off on the button. Here is what it looks like now.
Code Behind:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.