Home » Posts tagged "events"

JavaScript bind() for cleaner code

Several weeks ago, I wrote about how closures impact calling asynchronous functions in a loop and several ways of dealing with that problem.

In my recent coding, I’ve discovered an even more simple way of dealing with this problem. In the process, it removes the anonymous function and eliminates the linting error, ‘Don’t make functions within a loop’

You see, I’ve been experimenting with JavaScript bind(). And as it turns out, we can use bind in multiple situations, including dealing with the closure issue I mentioned a couple of weeks ago.

JavaScript bind() for cleaner code
Photo credit: Connor Tarter via VisualHunt / CC BY-SA

Continue reading “JavaScript bind() for cleaner code”

Manually Adding Event Handlers in VB.NET

office-019

Typically when we write our code, the event handlers get wired up for us using the handles clause.  So we never have to worry about wiring up our event handlers manually.

But what about the case where we want to dynamically add a control to our Windows Form or our ASP.NET page?  For example, add a button.  How would you respond to the button click event?

Continue reading “Manually Adding Event Handlers in VB.NET”

Response.Redirect() executes too soon on the Server.

tp_vol4_017 I’ve seen this question a couple of times in various situations. The first involves Javascript and the second involves server side code. Both are caused by a misunderstanding of what this function does and how web pages work.

Let’s start with the easy one: server side code.

Continue reading “Response.Redirect() executes too soon on the Server.”

Overriding Events in VB.NET

Back in the day, you use to be able to override an event in VB by using the drop down list in the code window.  Today, I had a friend who is moving from Visual Studio 2003 to Visual Studio 2008 ask me, “How do I override events in VB.NET now?”  All you get in the drop downs now is the event handlers.

Continue reading “Overriding Events in VB.NET”