Mail :info@sharpdev.net

Archive for November, 2009

JQuery Autocomplete – more complete!

Hi there!
A couple of days ago I started to develop something that needed a fancy, unobtrusive jquery autocomplete plugin, that could accept JSON as data source and created light HTML and I found this one.
But then, it missed two simple functionalities that I added:

One -> the for each of your result items, isn’t controlled by you, it expects that your JSON contains a value property, and uses it, but my JSON was a little more complex than that, so I coded a setting to the autocomplete plugin, so you can define, or not, your drawing function!
Two -> If you needed to force your autocomplete list to show up, you couldn’t, and I coded that two.

So here’s the result

or here:

Make it good use! ๐Ÿ™‚

Top 10 worst Microsoft products of all time

Just found this top, simple curiosity: http://www.v3.co.uk/v3/news/2252318/top-worst-microsoft-products

Execute CMD command on ASP.NET App

Hello guys, this time I spent one full day digging my way into this one..
The main question here is: How can I execute a command or a list of commands as if I where on the command prompt, and get the response?

I can give you right now the answer! (after banging my head over and over on the keyboard for one day…)

How simple is it? You just create a Process, set the RedirectStandardOutput and RedirectStandardInput to true, so you can create a Stream for reading and writing to/from that process, the FileName is the prompt itself and the UseShellExecute is a pre requisite.
Then start writing out your instructions to the command prompt, always followed by a Environment.NewLine (simulate a Return) and afterwards, you get the output on the reader Stream, that simple!

And, you don’t need to change any permissions on the user executing your worker process or app pool for your application, which is great so you don’t create any security holes on your web server.

Hopefully this will save you hours, like it would if I had this before!

See you soon

Colorize C# code with RegEx and HTML

Hi guys.
This time I needed to colorize some basic sample c# code and haven’t found any simple and usable componente to do that, so I decided to code one, but very simple and basic.
I know it lacks some functionality, like coloring a class on a static method call, because this is not so simple as that, but it’s a start, here is the code:

and that’s it! of course for your case, you change the markup I added..

See you soon ๐Ÿ™‚

JQuery – ajax call with dynamic parameters

This one was discovered because a colleague of mine asked me, and I started to wonder and realized I never used it before, never really needed it..But indeed, it can be quite handy!
Before you make the $.ajax call or $.post call or whatever, you do this:

Then, when you’re making the actual request, you pass your object on the data field

and voilรก! you can build your parameters in a nice way, instead of “prop1=value1&prop2=value2”

Be back soon ๐Ÿ™‚