web 2.0

Dynamic Select Lists with MVC and jQuery

Update 1/28/2010: This article is Scott Guthrie approved (Corporate Vice President in the Microsoft Developer Division). There are occasions when you are developing a form and you need to have a drop down list that dynamically populates based on the value of another control. The classic example is a contact form that dynamically populates the states and provinces list when a country is selected. For example, when I select "United States" I want the child drop down to have entries like New York, Alabama, Texas and etcetera. When I select "Canada" I would expect to see provinces like Nova Scotia and Ontario. Fortunately, this functionality is very easy to build using ASP.NET MVC and jQuery. Best of all, we can do this without any postbacks using the jQuery Ajax functions. To get started make sure you have a reference to the jQuery library, preferably in the HEAD section of your html. For the purposes of this example I am using jQuery version 1.4. You can either ... [More]

Generating Dynamic HTML Tables with jQuery From an In-Memory DataTable

By nature, web applications are stateless so you have to work a little harder to make them produce an user experience equivalent to that of a traditional windows application. In this article, I will go over the process for how to load an HTML table to a web page using Ajax and jQuery. The process will require you to execute an asynchronous query in SQL Server, load it into a DataTable and return it to the browser as JSON (JavaScript Object Notation). Finally the JSON string can be consumed by jQuery and rendered as an HTML table on the browser. Lets start out by looking at this traditional snippet of ADO.NET code: System.Data.DataTable tbl = new System.Data.DataTable();try { using (SqlConnection conn = new SqlConnection(connectString)) { SqlDataAdapter da = new SqlDataAdapter(sql, conn); da.Fill(tbl); }}catch { //do something} The code simply loads a query result into a DataTable. This is something t... [More]

Doing AJAX the easy way with JQuery and MVC

I know I have been writing a lot about MVC and JQuery lately. What can I say? JQuery makes writing JavaScript fun! Admittedly, when I first start using it, it was a little overwhelming. I was confused by the dollar sign notation and I really did not understand why it was better than plain old JavaScript. However, now that I am getting better acquainted with JQuery I can not imagine life without it. Recently I have been busy converting a Windows Form app into a MVC application. Unfortunately, when people get used to the rich user experience of a windows application they tend to have trouble adjusting to the stateless and often less extravagant experience of a web application. Most web apps function by making round trips to the server, which results in a full page refresh to display the data. This is annoying when you are scrolled halfway down a page looking at a record and the page refreshes and shoots you back to the top again. In order to avoid unnecessary post backs we can use AJAX... [More]

What Defines a Great Programming Language?

Software developers are very passionate about the programming languages that they use. For example a C++ developer will tout that C++ is the "grandfather of all programming languages". A Java programmer will tell you that Java is the best because they "write once and deploy anywhere". A C# programmer will tell you that they have better garbage collection than Java, no pointer nightmares like C++ and a powerful IDE which allows them to concentrate on real business problems rather than the basic plumbing. So what makes a programming language great? In the end, I guess it really boils down to personal preferences. The important thing is that you don't allow your personal biases to dictate your solutions. Some people get so wrapped up in the language wars that they will use a tool even if it is the wrong one for the job. I have seen people make languages do things that they were really not intended for. Sometimes this is cool but in most cases this translates into unmaintainable code, bug... [More]

Tags: , ,