Archive for the 'ASP.NET' Category

Passed my first MCSD certification exam

Posted in Technology Trends, Software, ASP.NET on August 18th, 2005

MCP Logo After working with Microsoft .NET technologies for the past 4+ years I finally decided to get certified. I passed my first exam, of many, for my MCSD. I plan on getting both my MCSD and my MCDBA by early next year.

I passed the 70-305 - Developing and Implementing Web Applications with Microsoft Visual Basic .NET and Microsoft Visual Studio .NET. Along with working with the technology everyday I also used Self Test Software as a study aid. I like this company since you don’t have to install software, it’s all web-based, so you can use it at home and work. It also helped me pass the exam with a 943 out of 1000.

My next exam, 70-320 - Developing XML Web Services and Server Components with Microsoft Visual C# and the Microsoft .NET Framework, is scheduled for early next month.

Ajax.NET - Free Ajax library for .NET

Posted in Programming, .NET, ASP.NET on July 27th, 2005

Ajax, is not necessarily new technology, in fact it’s not a single technology, but a group of technologies. Which allow you to build interactive web applications. The recently released Ajax.NET, a free and Open Source library for the .NET framework, will allow you easily include Ajax functionality in ASP.NET. You can read more about it on the Ajax.NET blog.

Build a better submit button in ASP.NET

Posted in Programming, ASP.NET on June 8th, 2005

Two routine problems you have with a web application. Either the user clicks a button and they didn’t mean too or they click a button more than once, and meant to.

You can solve the first problem by asking for a confirmation.

Say you have a Delete button a web form. And you can the user to be prompted with a “Are you sure you want to do this?” confirmation box before proceeding. Simply put this code in the page_load.

btnSubmit.Attributes.Add(”onclick”, _
“return confirm(’Are you sure you want to delete this page? ” _
& “This cannot be undone.’);”)

The second problem I was having with some users, who shall remain unnamed, clicking the submit button a little too aggressively. Their machine being a little slow, they thought pressing the button again (and again) would make it go faster. This caused havok with one of my web applications by processing an order too many times. So I sought out to write a button that could be disabled on the client-side before the postback began.

I initially tried just calling this.disabled = true when the button was pressed. This caused a problem since a disabled button wouldn’t allow a postback. So like any good programmer, I Googled this and didn’t not have to look to far for like-minded people with a good solution.

In order for a disabled button to work you would have to force postback by adding

__doPostBack('btnProcess','');

to the onClick event. Of course this is better done by calling Page.GetPostBackEventReference(Me.btnProcess) on your Page_Load.

And to get validation to work properly the standard validation script

if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate();

has to be replaced with

if (typeof(Page_ClientValidate) == 'function')
{ if (Page_ClientValidate() == false) { return false; }}

The final result for my solution was the following:

'This is the code for a Single-Click button
'Prevents a user from submitting a page more than once.
Dim sb As System.Text.StringBuilder = New System.Text.StringBuilder
'This forces the page validation, if any, to execute.
sb.Append("if (typeof(Page_ClientValidate) == 'function') { ")
sb.Append("if (Page_ClientValidate() == false) { return false; }} ")
'Changes the text of the button. Gives the user a processing message.
sb.Append("this.value = 'Processing...';")
'Prevent the button from being pressed a second time.
sb.Append("this.disabled = true;")
'Forces the page to postback.
sb.Append(Me.Page.GetPostBackEventReference(Me.btnProcess))
sb.Append(";")
Me.btnProcess.Attributes.Add("onclick", sb.ToString())

And of course if you want to combine these two functions you can simply use this code. This will ask the user for confirmation and only disable the button if the user clicks ‘yes’.

'This is the code for a Single-Click button
'Prevents a user from submitting a page more than once.
Dim sb As System.Text.StringBuilder = New System.Text.StringBuilder
'Confirm user action before processing.
sb.Append("if (confirm('Are you sure you want to process this shipment? " _
& "This cannot be undone.') == false) { return false; } ")
'This forces the page validation, if any, to execute.
sb.Append("if (typeof(Page_ClientValidate) == 'function') { ")
sb.Append("if (Page_ClientValidate() == false) { return false; }} ")
'Changes the text of the button. Gives the user a processing message.
sb.Append("this.value = 'Processing...';")
'Prevent the button from being pressed a second time.
sb.Append("this.disabled = true;")
'Forces the page to postback.
sb.Append(Me.Page.GetPostBackEventReference(Me.btnProcess))
sb.Append(";")
Me.btnProcess.Attributes.Add("onclick", sb.ToString())

And that’s it. This should be on every web application where multiple submits could cause a problem.

OpenDoubleListBox, I knew I was forgetting something

Posted in Programming, .NET, Software, ASP.NET, Open Source on May 31st, 2005

I apologize, I setup a new site and didn’t move over the OpenDoubleListBox files. I didn’t even realize it until I received an email today. Thanks for the reminder Noah.

Current files for the OpenDoubleListBox:
DoubleListBox Example Project
OpenDoubleListBox binary
OpenDoubleListBox Source Code

If you don’t know, the OpenDoubleListBox is a open source implementation of a .NET server control for a double list box . Written in C#. See an image here.

I have also received several requests for additional functionality. I hope to be releasing a new version when I get the time. You can read more about the control at ASP.NET.