My web page uses a contact from. I want to disable the send button after they click it so that they can't spam my inbox. I am using the RequiredFieldValidator controls on my page. also have some backend validation code that displays the errors in a summary
box, in case the user has disabled JavaScript.
Right now my form works correctly. When I click the send button with errors on the form the RequiredFieldValidators display on the page. The summary doesn't display (probably because the page hasn't been submitted to the server yet. The errors were found
on the client-side.)
Now, when I add that line of code above to my web page. I click the form with errors on it, and both my RequiredFieldValidators AND my server validation summary control both show up at the same time. The send button gets disabled, but it appears that this
line forces the server to run my validation as well...
I'm just confused why this happens.. I'm not really sure how that line works. I'm thinking that it forces the page to post to the server and get loaded back every time the button is clicked.
Kensino
Member
70 Points
185 Posts
Disable Button Causes Weird Effect
Oct 19, 2011 11:19 PM|LINK
I am using this thread: http://forums.asp.net/t/1099598.aspx
I took the code
Button1.Attributes.Add("onclick", "javascript:" + Button1.ClientID + ".disabled=true;" + ClientScript.GetPostBackEventReference(Button1,""));My web page uses a contact from. I want to disable the send button after they click it so that they can't spam my inbox. I am using the RequiredFieldValidator controls on my page. also have some backend validation code that displays the errors in a summary box, in case the user has disabled JavaScript.
Right now my form works correctly. When I click the send button with errors on the form the RequiredFieldValidators display on the page. The summary doesn't display (probably because the page hasn't been submitted to the server yet. The errors were found on the client-side.)
Now, when I add that line of code above to my web page. I click the form with errors on it, and both my RequiredFieldValidators AND my server validation summary control both show up at the same time. The send button gets disabled, but it appears that this line forces the server to run my validation as well...
I'm just confused why this happens.. I'm not really sure how that line works. I'm thinking that it forces the page to post to the server and get loaded back every time the button is clicked.