advanced web statistics

ASP.NET In-line Text Editing with AJAX / Database Support

8/28/2007 1:19:19 PM

I wrote the the other day about an easier (in my opinion) solution to provide in-line text editing without having to use the ASP.NET AJAX Library.  What that solution didn't include was the very thing the other articles online didn't include: actually editing the data.  Let's face it, changing the value of a label is completely useless unless you are updating a data source whether it be SQL, XML, etc..  I have done just that. I added about 20 minutes to initial 6 minutes to bring us in under a half-hour.  The code doesn't use stored procedures (very Hello World'esque) but at least I use paramterized queries!  The Ajax page (ajax.aspx) simply Response.Writes( 0 = good, 1 = bad).  To each his own. If you want an XML response simply add an XML response.  It is also worth mentioning that XmlHttpRequest is rather misleading and it should be renamed to WebRequest in the future. It isn't meant to be used with XML and it doesn't use XML under the covers. FYI (I'll post the link later).

Also, please add CSS to this. This is very vanilla.  I would never, EVER deploy something like this in production. Maybe beta-testing...

I have included the Visual Studio 2005 website and the database .bak (located in the App_Data folder).  If you have suggestions on how I could make it better let me know.  I will tell you that my next update to this code will be to dynamically generate the div's, labels, and textboxes.  In order to do that (I haven't quite finished scoping it) I am guessing I will use Serialization (XML) and the HtmlTextWriter class.

Have fun!

By the way, from top to bottom: favorite color, favorite band (currently listening), favorite stand-up comedian.

Edit Favorite Color
screen shot

Automatically Focus() and Select()
screen shot

Changed to Blue
screen shot

Successful!
screen shot

Download
AjaxEditing.zip

AJAX, C#, Code, JavaScript

kick it on DotNetKicks.com

Leave a Comment

   

  Enter the text to proceed!