Suppose you have a form with some ASP.NET validation controls on it, and you want to prevent users from clicking the form's submit button more than once.
It might sound easy at first. Just add some javascript to the asp:Button's OnClientClick to hide the button and show your custom message:
<script language="javascript" type="text/javascript">
function DisableButton(button)
{
button.style.display = 'none';
document.getElementById('loading').style.display = 'inline';
}
</script>
<asp:Button ID="LoginButton" runat="server" Text="Login" OnClientClick="DisableButton(this)" />
<span id="loading" style="display: none;">Logging in...</span>
Except if you do that, and you're using ASP.NET validation controls on the page, your user could end up in a situation like this:
Now your user is stuck because the Login button is gone!
So, this is how to get around that:
<script language="javascript" type="text/javascript">
function DisableButton(button)
{
Page_ClientValidate();
if (Page_IsValid)
{
button.style.display = 'none';
document.getElementById('loading').style.display = 'inline';
}
}
</script>
In the script above, you'll notice I'm using a Page_ClientValidate() method and a Page_IsValid boolean variable. Those are exposed as part of ASP.NET's Client-Side Validation API.
What's happening:
- Page_ClientValidate() forces the validation to happen immediately.
- If the validation tests pass (Page_IsValid), hide the button, show the message, and submit the page.
- If the validation tests fail, ASP.NET will handle showing the validation errors for you, and the page will not be submitted.
For more information on ASP.NET Validation, see this article on MSDN:
http://msdn2.microsoft.com/en-us/library/aa479045.aspx
30 comments:
Awesome. Thanks.
Web Casino tyuueooru
Internet Casino
There are several things to be considered when selecting the best gambling website.
[url=http://www.nhgaa.org/]Casino Free Game[/url]
In fact, there is no risk at all.
http://www.nhgaa.org/ - Best Casinos
Ensure that the one you're interested in prefer using a trustable and ideal software that you can rely on.
Interesting information about "How To: Hide a Button When Clicked on an ASP.NET Page Containing Validation Controls" This theme serves to educate people in their daily life, thanks to people like you we have more knowledge about this important issue.
Hello people want to express my satisfaction with this blog very creative and I really like the views of the focus very good indeed Thank you for the helpful information. I hope you keep up the good work on making your blog a success!
[url=http://newloans.skachatnow.co.cc/interest-only-loan-calculation.php]interest only loan calculation[/url]
[url=http://paydayloan.skachatnow.co.cc/advance-american-cash-first.php]advance american cash first[/url]
[url=http://loanstoday.skachatnow.co.cc/jumbo-mortgage-loan-houston.php]jumbo mortgage loan houston[/url]
http://loanstoday.skachatnow.co.cc/interest-loan-low-uk.php - interest loan low uk
http://paydayloan.skachatnow.co.cc/cash-bad-credit-personal-loan.php - cash bad credit personal loan
http://fastloans.skachatnow.co.cc/vehicle-loan-payment-calculator.php - vehicle loan payment calculator
[url=http://newloans.skachatnow.co.cc/low-colorado-loan-rate.php]low colorado loan rate[/url]
[url=http://fastloans.skachatnow.co.cc/private-money-loan.php]private money loan[/url]
http://newloans.skachatnow.co.cc/best-loan-rate-rv.php - best loan rate rv
[url=http://getloan.skachatnow.co.cc/loan-officer-training-class.php]loan officer training class[/url]
crossdress teen
chatting teen
cute wet teen
christian teen ministries
cute teen in thong
http://thecrazycalm.com/forums/index.php?topic=23471.new#new
http://gator28.hostgator.com/%7Ebigdave/ewaforums/index.php?topic=35823.new#new
http://riosdeliberacion.net/forum/index.php?topic=80092.new#new
http://bkforum.ru/index.php?showtopic=2682&st=180&gopid=8014&#entry8014
http://sad46.forumcity.com/viewtopic.php?p=7867#7867
http://friends.rambler.ru/canlideter@rambler.ru
http://friends.rambler.ru/perpkarcadict@rambler.ru
http://friends.rambler.ru/reteajope@rambler.ru
http://friends.rambler.ru/thedanensu@rambler.ru
http://friends.rambler.ru/fluterbipurp@rambler.ru
http://duvilali.kilu.de
http://ohojydid.kilu.de
http://zozyjiza.kilu.de
http://vegeripy.kilu.de
http://ufuzelul.kilu.de
http://jajivuru.kilu.de
http://ynujirys.kilu.de
http://itukylaj.kilu.de
http://irotides.kilu.de
http://ohuqegyl.kilu.de
http://www.adventphysics.org/forum/index.php?topic=401943.new#new lesbian milf rape http://forum.openvcp.org/index.php?topic=162.new#new milf lesbian free videos http://thezeusonline.com/forum/index.php?topic=55270.new#new blonde milf pictures http://deknumi.com/support/index.php?topic=48669.new#new milf swingers http://usproductfinder.com/forum/index.php?topic=101204.new#new hardcore milf movie
Merry Christmas and Happy New Year, may all your wishes come true!
Computer Pc Repair Orlando Computer Technician Job Hazard Analysis Toolkit Pc Diagnosis And Repair Computer Support Chicago Betson Drift Computer Problems Schwinn Recumbent And Computer Parts Best Deal New Dell Computer People Pc Computer User Tuomas Computer Computer Networking Computer Consulting Repair Sales Top Ten Best Computers To Buy Computer Shipping Companies Cheap Computer Parts Sydney Biggest Computer Store In Ohio Which Computer Brand Is Best Troubleshooting Computer Systems Ibm Thinkpad Laptop Repair Computer Parts Manchester Connect Sports Computers Error Network Parts Of The Computer Storage Computer Support Products Inc Dell Computer Support Uk Computer Networking Slogans Lumber Building Material Computer Systems Hp Computer Repair Printer Hewlett Packard Tech Support Snell Computers
http://www.box.net/shared/1bepqdkted Apple Computers For Sale Buyer http://www.box.net/shared/m6gb4gd26d Wireless Internet Connections For Home Computers http://www.box.net/shared/ptsc1jttko Gch Systems Computer http://www.box.net/shared/bleiaytbfx Computer Consulting Companies Bozeman Mt http://www.box.net/shared/ir3qfskrtc Pc Chips M810d Cpu Support http://www.box.net/shared/lilvbyxyiu 1 Fix Computer That Freeze 2 http://www.box.net/shared/ndsxptjl7j Hp Pavilion Ze Computers Networking http://www.box.net/shared/3puvcx3zxi Computer Parts Motherboards Barebones http://www.box.net/shared/n40smuvo88 Computer Store Vancouver http://www.box.net/shared/3cq15ifxzh Office Computer Operating Systems Available http://www.box.net/shared/fxutq4siiz Computer Repair Maintenance Plan Lawn Maintenance http://www.box.net/shared/3oy6t4pblk It Services Brazil http://www.box.net/shared/nbxj2ig4rg Pc 2700 Ram Upgrades http://www.box.net/shared/rdolcngcfp Pc Repair Home Business http://www.box.net/shared/yvefsmaznd Online Computer Shops In The Uk http://www.box.net/shared/jrvctj86lm Help Fim My Computer http://www.box.net/shared/sn87e8fvzc Cto Computer Networksystems Director York New http://www.box.net/shared/dpu3cx16jq Networking 2 Home Computers http://www.box.net/shared/yhgh6ismm5 Near Bordon Computer Stores http://www.box.net/shared/a67lrr5o62 Computer Virtual Reality Multi User Systems http://www.box.net/shared/gg2npzb7ez Help Someone With Computer Problems
http://www.box.net/shared/b1z0r5l6tc Repair Sound On Computers http://www.box.net/shared/aeotavszm9 Superpages Com Computers Repair http://www.box.net/shared/nv3mhqnyn3 New York State Consulting Agreement http://www.box.net/shared/r8ij5sg2q5 Computer Hacking Exam Solutions http://www.box.net/shared/hdpl9jpa43 Intel Motherboard Repairs http://www.box.net/shared/y9ti7xxahq Operating Systems For Computer Science http://www.box.net/shared/3qpuee3txx Network To Computers Command http://www.box.net/shared/npvakjtqb7 Computer Network Support Kent http://www.box.net/shared/eo8m8favse Onsite Computer Service http://www.box.net/shared/67cnjxedvd Computer Repair Technicians In Arlington Va http://www.box.net/shared/xfi34mkzzo Computer Internal Parts http://www.box.net/shared/lhtsfup678 Best Book On Computer Hackers http://www.box.net/shared/i5jjtacege What Is Clipping In Computer Networks http://www.box.net/shared/te6cqeos0p Golf Training Queens Village New York http://www.box.net/shared/gyz8mte1l3 Brisbane Computer Sales http://www.box.net/shared/5nb0himdk6 Laptop Repair Oceanside Ca http://www.box.net/shared/6vx6k0v4hs Computer Information Systems Things http://www.box.net/shared/7gu9f9xf96 Computer Game Harry Potter Pc http://www.box.net/shared/vz9ilm0vkr Computers Computer Parts Wholesale Distributor C http://www.box.net/shared/0a2crnhyxl Imac Computers Help http://www.box.net/shared/8vqli2m9ls Photo Shop Computer Soft Ware http://www.box.net/shared/vs3qf5oz33 Pc To Land Line Phone Services http://www.box.net/shared/iglh7tmoon Used Computers For Sale In Georgia http://www.box.net/shared/ygz7ssx6s2 Inspiron 1150 Motherboard Repair http://www.box.net/shared/gq4ortjkif Magnet Schools Queens New York http://www.box.net/shared/osladifu1c Computer Best For Graphic Work http://www.box.net/shared/g0y033jpx0 Shops Selling Laptops In New York http://www.box.net/shared/ce1vf0dku9 Test World Languages Computers Graphics http://www.box.net/shared/mib17kc7tm Best Computer Training In San Francisco
http://www.box.net/shared/qgs5dr9roj Computer Parts Corona Ca http://www.box.net/shared/r9iky2zmjt Computer File Problems http://www.box.net/shared/kd3inb574x Puppie Shops In New York http://www.box.net/shared/4mz7hhxuas Best Laptops For Computer Graphics http://www.box.net/shared/3u85ht7604 Computer Parts Wholesale http://www.box.net/shared/ldi788rvkv Support Phone Number Of Dell Computers http://www.box.net/shared/bkinlnnjv0 Business Computer Help Starting http://www.box.net/shared/qgfe7xd9xl Circle R On Pc Computer Keyboard http://www.box.net/shared/2hodrrnejl External Computer File Storage Comparison Best http://www.box.net/shared/u43stni74b Bank Of America Consulting New York http://www.box.net/shared/c8gm7rnyop Dell Laptop Repair Parts Indianapolis http://www.box.net/shared/0pzi270h9q Systems Touchscreen Computer http://www.box.net/shared/c48leozn1m Wireless Networking Wired Computer Things Mix http://www.box.net/shared/5x4zeh8xen Case Stickers Computers Networking http://www.box.net/shared/7oecssnzol Computer Retail Stores Vancouver http://www.box.net/shared/tp8hdpxovn Computer Store In Lehigh Acres Florida http://www.box.net/shared/af0fh4evo6 Holiday Inn Queens New York http://www.box.net/shared/uj9u70qkio Australia Computer Store http://www.box.net/shared/cmm04k7223 Computer Science Best Graduate School http://www.box.net/shared/49olafa9pr Computer Tech Support Reveiws http://www.box.net/shared/bh9vg531h9 Best In Computers http://www.box.net/shared/zvcr3vh0aq Best Home Computer Ratings http://www.box.net/shared/a598qo75y3 Job Description Computer Technician http://www.box.net/shared/ss9zjc062z 503 Computer Fix Help 725 http://www.box.net/shared/f97ra7ikrn Computer Repair Huntington Beach http://www.box.net/shared/75q12rxt0x Computer Systems Technology Huntsville Al
http://www.box.net/shared/3qhh5ojsc8 Computer Shop Online http://www.box.net/shared/go67k1fz98 High Performance Computer Systems http://www.box.net/shared/0q8gsi1qg2 Pc Cleaner And Fix http://www.box.net/shared/nj511ot57v Computer Networks Example Exercises And Answer http://www.box.net/shared/f8yyt25b9b Learning Computer Networking http://www.box.net/shared/t2ooztmdu9 Miscellaneous Music Best Buy Computers Electronics http://www.box.net/shared/e3k3uh53vs Computer Parts Mansfield Ohio http://www.box.net/shared/ytsgj6l5oe Computer Repair Haltom City Texas http://www.box.net/shared/49vq1zqla0 Military Computer Problems Worm November 2008 http://www.box.net/shared/nds9ozy9ky Repair Laptop Battery Chip http://www.box.net/shared/jm1i0gyxa5 Jes Computer Systems
Wow great post very informative, all i can add is if you would like to read more on the subject, you should visit google and find relevent sources! hope it is helpful
I wana congratulate you for such a wonderful and excellent work keep it up though its awesome
oZzy moved away earlier, I miss his cock, and i am always
hungry for sexual intercourse.
FUCK MY PUSSY!
My web page; hcg injections
Wow, fantastic blog layout! How long have you been
blogging for? you make blogging look easy. The overall look of your site
is fantastic, let alone the content!
Also visit my web blog :: Stay at home parents
I've been browsing online greater than three hours these days, yet I by no means found any interesting article like yours. It is lovely value enough for me. Personally, if all webmasters and bloggers made just right content material as you did, the web can be much more helpful than ever before.
my site: mouse click the up coming internet site
Nice respond in return of this matter with genuine arguments and describing all regarding that.
Here is my homepage ... symbol mc9060
If some one needs expert view concerning blogging afterward i suggest him/her to pay a visit this website, Keep
up the nice work.
Also visit my weblog ... Private Zusatzkrankenversicherung
Hello it's me, I am also visiting this website regularly, this website is genuinely good and the users are genuinely sharing pleasant thoughts.
Feel free to visit my homepage - CN3 Intermec
Hi there! This blog post couldn't be written much better! Going through this post reminds me of my previous roommate! He continually kept talking about this. I'll forward this article to him.
Fairly certain he'll have a good read. I appreciate you for sharing!
Here is my website book of ra kostenlos downloaden
Very good article! We are linking to this great post on our site.
Keep up the great writing.
Here is my web page - book of ra android download
I simply couldn't leave your website before suggesting that I really enjoyed the usual information an individual supply for your visitors? Is gonna be again ceaselessly in order to investigate cross-check new posts
my blog post ... book of ra tricks download
I drop a comment each time I appreciate a article on a site or I have something to add to the
conversation. It's a result of the sincerness communicated in the article I looked at. And after this article "How To: Hide a Button When Clicked on an ASP.NET Page Containing Validation Controls". I was actually moved enough to leave a comment ;) I actually do have 2 questions for you if it's okay.
Could it be only me or does it look as if like a few of the comments look like left by brain dead
individuals? :-P And, if you are posting at additional online social sites,
I'd like to follow you. Could you list the complete urls of all your communal pages like your Facebook page, twitter feed, or linkedin profile?
Have a look at my page book of ra free download chip ()
electronic cigarettes reviews, e cigarette, ecigarette, electronic cigarette, smokeless cigarettes, electronic cigarettes reviews
WordPress HostingCheap Windows Hosting
WordPress HostingCheap Windows Hosting
Post a Comment