<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>adam.mokan</title>
	<atom:link href="http://adammokan.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://adammokan.wordpress.com</link>
	<description>too many ideas and not enough time</description>
	<lastBuildDate>Sat, 06 Feb 2010 05:39:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='adammokan.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/bb6667f5379e9f78744af728ac10138d?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>adam.mokan</title>
		<link>http://adammokan.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://adammokan.wordpress.com/osd.xml" title="adam.mokan" />
	<atom:link rel='hub' href='http://adammokan.wordpress.com/?pushpress=hub'/>
		<item>
		<title>ELMAH = awesome</title>
		<link>http://adammokan.wordpress.com/2009/12/02/elmah-awesome/</link>
		<comments>http://adammokan.wordpress.com/2009/12/02/elmah-awesome/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 22:11:18 +0000</pubDate>
		<dc:creator>Adam Mokan</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[ELMAH]]></category>
		<category><![CDATA[Error Tracking]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://adammokan.wordpress.com/?p=19</guid>
		<description><![CDATA[So, I&#8217;m a bit late to the game on this. But ELMAH (Error Logging Modules and Handlers) is awesome. Basically just drop the dll in your bin folder on your project and adjust your web.config. It handles your error handling &#8230; <a href="http://adammokan.wordpress.com/2009/12/02/elmah-awesome/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=adammokan.wordpress.com&amp;blog=10277370&amp;post=19&amp;subd=adammokan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So, I&#8217;m a bit late to the game on this. But <a href="http://elmah.googlecode.com/">ELMAH</a> (Error Logging Modules and Handlers) is awesome.</p>
<p>Basically just drop the dll in your bin folder on your project and adjust your web.config. It handles your error handling and logging automatically. Very slick.</p>
<p>I got it in place today on a couple apps (ASP.NET webforms and ASP.NET MVC 2) and it writes to a SQL database (one of many options for logging).</p>
<p>But, as with most things I mess with, its not enough (and not its own fault). I have an internal system already in place for tracking and managing our applications. I setup the ELMAH table in the same database as my tracking app and want to have a way to tie them together. So, now I am modifying the Error.cs class in the Elmah source to allow me to put the ApplicationID in the web.config so I can query the Elmah error table in relation to my existing application metrics.</p>
<p>I highly recommend checking this little utility out if you&#8217;re doing .NET development.</p>
<br />Posted in C# Tagged: .NET, ASP.NET, ASP.NET MVC, C#, development, ELMAH, Error Tracking, Programming, SQL Server <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/adammokan.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/adammokan.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/adammokan.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/adammokan.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/adammokan.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/adammokan.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/adammokan.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/adammokan.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/adammokan.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/adammokan.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/adammokan.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/adammokan.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/adammokan.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/adammokan.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=adammokan.wordpress.com&amp;blog=10277370&amp;post=19&amp;subd=adammokan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://adammokan.wordpress.com/2009/12/02/elmah-awesome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c3e7fbc142f735503f73b542a5d6bc70?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">adammokan</media:title>
		</media:content>
	</item>
		<item>
		<title>jQuery autocomplete plugin with ASMX web service and JSON</title>
		<link>http://adammokan.wordpress.com/2009/11/04/jquery-autocomplete-plugin-with-asmx-web-service-and-json/</link>
		<comments>http://adammokan.wordpress.com/2009/11/04/jquery-autocomplete-plugin-with-asmx-web-service-and-json/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 23:24:03 +0000</pubDate>
		<dc:creator>Adam Mokan</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[ASMX]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ASP.NET web forms]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[web forms]]></category>
		<category><![CDATA[web services]]></category>

		<guid isPermaLink="false">http://adammokan.wordpress.com/?p=3</guid>
		<description><![CDATA[I&#8217;m trying to find more reasons to switch a lot of my js/ajax ui over to jQuery recently. This is due to my excursions into Rails and Sinatra outside of work, and also because I feel like some of the &#8230; <a href="http://adammokan.wordpress.com/2009/11/04/jquery-autocomplete-plugin-with-asmx-web-service-and-json/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=adammokan.wordpress.com&amp;blog=10277370&amp;post=3&amp;subd=adammokan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m trying to find more reasons to switch a lot of my js/ajax ui over to jQuery recently. This is due to my excursions into Rails and Sinatra outside of work, and also because I feel like some of the MS Ajax Toolkit extenders seem to be bloated at times. I also figure that since I intend to dip my feet more into the ASP.NET MVC framework, jQuery seems to be very standard there.</p>
<p>That brings me to (one of) the jQuery Autocomplete plugins. I need this functionality in an ASP.NET webforms application and wanted to give it a shot. I started messing with &#8220;jQuery Autocomplete plugin 1.1&#8243; by Jörn Zaefferer. You can find the code and info at <a href="http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/">http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/</a>.</p>
<p>I&#8217;m mostly interested in doing an autocomplete via a remote web service call that returns json data. The example in the zip file includes a little php page that just responds to a HTTP-GET and spits out some hard-coded json. I&#8217;m working in .NET, so I made a simple ASMX web service to query my database and return a DataTable as json. (Note &#8211; There are isues with the built-in serializer to return a DataTable as json. A google search will find you a number of functions or alternate ways to generate a json string from a DataTable.)</p>
<p>Right away, I found I was having problems with the autocomplete in this environment. First off, you have the whole issue with ASMX web methods only accepting a POST by default. This is easy to change, but not advised. You can find info on that issue here &#8211; <a href="http://encosia.com/2008/03/27/using-jquery-to-consume-aspnet-json-web-services/">http://encosia.com/2008/03/27/using-jquery-to-consume-aspnet-json-web-services/</a> and some other good info here &#8211; <a href="http://encosia.com/2008/06/05/3-mistakes-to-avoid-when-using-jquery-with-aspnet-ajax/">http://encosia.com/2008/06/05/3-mistakes-to-avoid-when-using-jquery-with-aspnet-ajax/</a></p>
<p>You&#8217;ll also notice in the above blog links that there can often be issues when POST-ing to a web method with encoding set to json, that you will need to pass your json params as a string. If you&#8217;re using something like Firebug to watch your ajax posts, you&#8217;ll catch this right away.</p>
<p>But the main issue for me were the assumptions that the autocomplete plugin makes. It, by default, will only do a HTTP-GET. You can use the $.ajaxSetup in jQuery to set your future ajax calls to a default, but I wanted the ability to make this decision when calling the autocomplete plugin.</p>
<p>I made these changes to jquery.autocomplete.js in the $.ajax section :<br />
<pre class="brush: jscript;">
$.ajax({
// try to leverage ajaxQueue plugin to abort previous requests
mode: &quot;abort&quot;,
// limit abortion to this input
port: &quot;autocomplete&quot; + input.name,
dataType: options.dataType,
//setup new options for asmx - amokan
&lt;strong&gt;type: options.httpMethod,
contentType: options.contentType,&lt;/strong&gt;
//end new options - amokan
url: options.url,
</pre></p>
<p>This allows me to now handle my client side code a little better.<br />
<pre class="brush: jscript;">
$(&quot;#task&quot;).autocomplete(
&quot;http://somecomputername/jsonServiceTest/Testing.asmx/GetData&quot;,
{
dataType: 'json',
&lt;strong&gt;httpMethod: 'POST',
contentType: 'application/json; charset=utf-8',&lt;/strong&gt;
max: 100,
scroll: true,
matchContains: true,
minChars: 3,
parse: function(data) {
var rows = new Array();
//your parsing logic
},
formatItem: function(row, i, n) {
//do something
},
width: 260
}
);
</pre></p>
<p>I&#8217;m still working on cleaning up the data parameter section of the plugin a bit before I post the full code.</p>
<p>If you&#8217;re curious, here is my ASMX method. Be sure to add the [ScriptService] attribute to your class in the ASMX file so it can handle AJAX properly. If you are using an older .NET without the System.Web.Script.Services namespace, this will not work for you. Note that the parameters &#8220;q&#8221; and &#8220;limit&#8221; are sent automatically by the autocomplete plugin. &#8220;Q&#8221; is the string currently typed into the text control so you can filter your query based on what the user has typed and &#8220;limit&#8221; is the max number of rows. Obviously, its up to you to implement these in your query if you chose to.</p>
<p><pre class="brush: csharp;">
[WebMethod]
[ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]
public string GetATCDataNoParam(string q, int limit)
{
DataTable dtSomething;

//connect to db, do your exception handling, etc
dtSomething = //your DAL or whatever you use

return GetJSONString(dtSomething); //use my method to parse the datatable into json
}
</pre></p>
<p>Hope this helps a bit and I will be sure to upload some more code as I get this working a bit smoother in my environment.</p>
<br />Posted in C# Tagged: .NET, ajax, ASMX, ASP.NET, ASP.NET web forms, C#, JavaScript, jQuery, json, Web Development, web forms, web services <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/adammokan.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/adammokan.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/adammokan.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/adammokan.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/adammokan.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/adammokan.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/adammokan.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/adammokan.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/adammokan.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/adammokan.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/adammokan.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/adammokan.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/adammokan.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/adammokan.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=adammokan.wordpress.com&amp;blog=10277370&amp;post=3&amp;subd=adammokan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://adammokan.wordpress.com/2009/11/04/jquery-autocomplete-plugin-with-asmx-web-service-and-json/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c3e7fbc142f735503f73b542a5d6bc70?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">adammokan</media:title>
		</media:content>
	</item>
	</channel>
</rss>
