Justin Cooney

Web Development Tips and Examples

  • If you work a lot with ASP.NET then it’s likely that at some point or another you will ask yourself how to hook up an XML Data Source with a DropDownList control.

    This just makes sense if you want to manage your drop-downs from a file rather than from a database, and carries a range of advantages. For example, not having to go through a DBA to update a simple DropDownList item would be a good reason in my books.

    (more…)

  • The ASP.NET system libraries offer powerful string manipulation functionality in the form of extensive Regular Expression support as well as String-specific functions such as Split and Replace. In 99% of cases these functions are sufficient to use to quickly manipulate strings. However in one case I had to put together a special function of my own.

    What was the problem & why build a custom function?

    The UI to be developed was rather simple. I wanted to write a basic search Web page that contained a TextBox for the user to enter their search text, a Submit button to run the search, and a ListView control to display the search results.

    Although from the UI perspective everything was very straightforward, the catch became clear with the requirement to have the search term bolded in the search results shown by the ListView control. This became a problem for the following reasons: (more…)

  • I’ve been playing around with hooking up the JQuery AutoComplete widget with an ASP.NET Web Service. This is a really neat idea that adds a lot of whizzbang to a standard Web-based form. In theory one could also use ASP.NET UpdatePanel controls with traditional ASP.NET/HTML form controls, but I really wanted to look further into the JQuery Ajax functionality since this fits together very neatly with the JQuery AutoComplete widget.

    I found three really good articles on the topic that I am listing below:

    1. Mudassar Khan’s ASP Snippets Blog article – Implement jQuery Autocomplete using Web Service in ASP.Net
    2. Andy Marshall’s article on CodeProject – Introduction to using jQuery with Web Services
    3. Luca Congiu’s article on MSDN – Use Jquery Autocomplete With Web Service (ASMX) DataSource

    From reading the articles I have been able to adapt the information these authors presented into the logic I am looking for.

    The Desired Functionality

    Specifically what I am looking to do is to have a Web form with a text entry area that will offer a user suggestions for text while a user is  typing. The options should be selectable and should pass an id value.

    Furthermore, the suggestion list will kick in after the user has entered a minimum of two characters and will match anywhere within the database name field text for matches to show. To reduce lag and the amount of data being transmitted I am capping the returned results to a maximum of 500. Furthermore I am using the JSON protocol to keep the transferred data lightweight.

    (more…)