Nathan's profileNates StuffPhotosBlogListsMore ![]() | Help |
|
April 20 Utah Code Camp :: Spring 2008 AnnouncementI have been doing Code Camp for over a year now (that may not seem like a lot but this will be my 3rd time presenting there). Code Camp is awesome! It's a full day of free training in a verity of topics that most developers find interesting. Topics Include:
You can visit http://www.utcodecamp.com for more information (Yes, I know I put the Microsoft technologies first -- I'm an unpaid unofficial self-proclaimed Microsoft Technologies Evangelist!). Wither you are just starting out in your career or have been doing this stuff for years you will get something out of Code Camp! It's not one of those Microsoft "For developers" class sessions where it's just a giant power point and you didn't get any real substance! In fact, that is part of the Code Camp Manifesto (http://blogs.msdn.com/trobbins/archive/2004/12/12/280181.aspx) Information: Date: April 26, 2008 (This Saturday) I will be doing the Silverlight 2.0 presentation so please come!! Thanks! April 18 Disable an ASP.NET button after clickingI was creating a payment form recently and I wanted to disable the submit button after the user had clicked it so that there was no chance of them clicking it twice on accident. This seems like one of those things that just ought to be a slam dunk! Back when I was doing ASP, this was one of the easiest things I ever did. I have done it with asp.net before, but I never needed validation to work as well. It took me a long time, many searches and trial and error but I found a solution that will disable the button and doesn't get in the way of validation. protected override void OnInit(EventArgs e) { // We need this to get our button event Form.SubmitDisabledControls = true; btnProcessPayment.UseSubmitBehavior = false; // Attach javascript code to the OnClientClick event btnProcessPayment.OnClientClick = "javascript:if ( Page_ClientValidate() ) " + "{this.disabled=true; this.value='Please Wait...'};"; base.OnInit(e); } The javascript is pretty straight-forward. We are simply calling the validation function ourselves, if it validated we disable the button and change the text. What does the rest of the code do then? Well, normally when a control is disabled it doesn't post data on postback. Fortunantly, ASP.NET makes it easy to override that default behavior. Without this data our button click event would never fire! You can also do this in the HTML as well.
<form id="form1" submitdisabledcontrols="true" runat="server"> <asp:button id="btnProcessPayment" onclick="btnProcessPayment_Click" runat="server" onclientclick="javascript:if ( Page_ClientValidate() ) {this.disabled=true; this.value='Please Wait...'};" usesubmitbehavior="false" text="Process Payment" />
I hope this is useful to someone! If you end up using it on one of your sites, please leave a comment! Thanks! April 01 Worst Objective Ever!I do a lot of tech interviews. If I'm really into it that day I'd say I give one of the better Interviews your likely to receive. I can honestly say that no one has what I would call a decent resume, but this one takes the cake for the worst objective ever!
I have been looking for a long time for someone to secure wealth in an orderly fashion. My three favorite parts are 1) Organized acquisition of wealth. 2) The hard return inside of the sentence. and 3) "reduce bad stuff". (my favorite!) --Nathan Zaugg |
|
|