ASP.NET

Australian Election Day Polling Place Stall Finder

A tradition at every Australian election polling place is a variety of stalls with cakes, arts and crafts, and sausage sizzles. During my lunch break today I designed a simple web application using ASP.NET and a little AJAX that will let you search for a polling place and see what stall are available. Most stalls [...]

Avoiding ASP.NET dropdownlist has a selectedvalue which is invalid exceptions

It is often to difficult to capture the following ASP.NET dropdownlist error when the dropdownlist is bound to an sqldatasource:Â
Dropdownlistname has a SelectedValue which is invalid because it does not exist in the list of itemsÂ
This exception is frequently caused by poor validation controls during data entry and/or poor database design. For example, the previous application might [...]

Consuming a web service using ASP.NET

This is a video tutorial I created for my eBusiness class at the University of Oregon. It is an introduction to consuming a web service  and using the Google Maps API with ASP.NET and Visual Studio 2008. It highlights how to create and use a web reference on an ASP.NET web page with Visual Basic. It also provides [...]

Inserting a PayPal Buy Now Button into an ASP.NET Form

When working with ASP.NET pages, one difficulty that often arises is that you need two forms on the page – the normal form required by ASP.NET and a second form for something else such as a PayPal button or a search tool. The solution that I discovered is to not have two forms but simply [...]

Microsoft reporting: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

This error was bugging me for a long time until I found this excellent forum discussion:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=541116&SiteId=1
The following points summarize the causes and solutions from the forum and offer some additional help:
1. Check if you have changed the length of any fields in the underlying database table after creating the dataset. If you have, [...]

A better way of handling maxRequestLength exceptions

ASP.NET 2 includes the FileUpload control to make it easier to create pages that allow users to upload files. The default maximum file size is 4096 KB to minimize the potential for denial of service attacks. You can change the maximum file size by editing your configuration files (see for example http://msdn2.microsoft.com/en-US/library/system.web.configuration.httpruntimesection.maxrequestlength(VS.80).aspx and http://support.softartisans.com/kbview_825.aspx).
The problem [...]

Formatting columns in a GridView

Formatting columns in a GridView is relatively straightforward, once you know the appropriate format string.
Here are the steps if you are using Expression Web, Visual Studio, or Visual Web Developer:

Open the Task Pane of your GridView and select Edit Columns
In the Selected Fields Box, select the column you want to edit
Find the HTMLEncode property and [...]

Converting SQL Server newline character to HTML break <br/>

A common scenario (at least for me) is the following:
1. Accept text input into a web form that includes multiline text boxes. The text often includes line breaks.
2. The text is stored in a database such as SQL Server 2005. SQL Server 2005 has no problem storing the line breaks.
3. I then display the data [...]

Configuring SQL Server 2005 for database-driven web pages

SQL Server 2005 has enhanced security that prevents it initially from serving data for web pages. Here are the configuration settings to check before trying to create database driven web pages in Visual Studio, Dreamweaver, or any other web design application. Note that some of these settings reduce the security level of SQL Server 2005.
SURFACE [...]

Basic error handling for ASP.NET web sites

To avoid displaying the complicated error messages displayed by the .NET framework, you can direct users to a more user-friendly page by inserting the following tags into your web.config file:
<customErrors mode=”RemoteOnly” defaultRedirect=”errors/error.aspx”>     <error statusCode=”404″ redirect=”errors/error404.aspx”/></customErrors>
Using this method of error handling also has the added benefit of not displaying sensitive server information to the user (or [...]