Mail :info@sharpdev.net

Blog

Our Thoughts and Ideas.

jLinq – JQuery LINQ to JSON

The other day, I was writing some code for having my entity objects transformed to XML or JSON as simple as ToJSON and ToXML, and it got me wondering, what if I could have something like this on client-side?
Did some research (google.com?q=jquery+linq) and WOW, JQuery has a plugin that allows me to perform LINQ queries on my JSON data?? Jackpot!

Let me show you some code so you can reset your mindset:

How cool is this? Are you thinking about the millions of applications for this? The millions of possibilities and richer web applications we can build with this? So am I!

Go to this page and download it right away, because this has some really untapped potential, congrats to Hugoware for this great achievement!

See you soon, enjoy it.

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 🙂

JQuery pass parameter to event handler

How can you pass values into a event handler, plain and simple?

here it is!

And here comes the magic, on the bind function, in the second parameter, you define the data structure to pass on to your anonymous event handler (which can be multiple parameters, comma separated).
(notice that you have to receive the event parameter on the handler function, so you can access the data you sent)

So, what’s the use of this? you can send data that is accessible in your current context, where you are defining the handler, but inside the handler it’s unreachable.

Hope this is as useful for you as it was for me!

See you soon 🙂

Deserialize JSON with C#

You’re using JQuery, making some fancy ajax requests, but tired of Request[“setting”] to get data from client-side, starving for a strong-typed approach? STOP! I’ve got just what you need, and supports single object, and even lists of objects (arrays)!

Example:

For the single, the .NET Framework has the key, you need to create a class that has public fields or properties matching the field names on your JSON string, example:

And the code to serialize your Single JSON is this:

and voilá! you got yourself a strong-typed object with client-side data, sweet!

But and if I want a list of data of the same type, say an Array, how is it done? The .NET Framework hasn’t got the answer for this one..
You have to download and reference the following DLL

Once it’s done:

and yes! you’re done 🙂

How easy is this? It’s perfect for your lightweight ajax applications with .NET backend.

Please post comments!

See you soon

JQuery and XML

Today I’ve started to use JQuery for XML navigation for the first time. For what I’ve seen it seems that it is pretty easy, just like using it for HTML, like:

nice hã?

JQuery Searchable Select Plugin

This is my first release of this plugin, many things need to get better, yes, but I think as it is will still help and allow me to upgrade it with your suggestions and feedback.
The usage is:

The available parameters are:
arrowImage: absolute image path
arrowImageOver: absolute image path
arrowImageDown: absolute image path
highlightItemBgColor: css color
highlightItemTextColor: css color
elementStyle: css style ()

You can download it here