1/26/11

How to put breaklines between tags or the great notepad++

This is a small post that will be devoted to notepad++ - which i think, is a great tool for webdeveloper. This is free, lightweight, but smart code editor. Not that it can completely replace Visual Studio, but in some ways it seems to have advantages on Microsoft technology.
Take a quick look on what can you do with this notepad:

Say  you have to modify some details xml file that have all the tags gathered in one line. If you need each tag to be displayed in separate line you can do Replace with the following options:






Now you can see the result:: each tag on his own line.



Using Regular expressions:
Say you have an CSS file in which you need replace the images url of background property:
from  To  

And for some reason the code somtimes appears in this way:


and sometimes in this way:


You cannot replace all apearances with the same way. So you need to use RegularExpresson:
Firstly replace all appearances without brackets:
And after-with brackets:
Now you can anjoy the fixed code!

1/24/11

Thoughts about Jquery autocomplete plugin

I'm sure you have experinence of building autocomplete functionality in some way. There many ways to do it -for example with  AJAX Control Toolkit. Since i'm teaching myself a jquery now i want to implement the jquery autocomplete plugin in my ASP.NET site.



Its looks easy as it appears in the exapmle :


After placing this javascript you only need to create input with id -"LOCATION" and the things start working.

So far so good.
The only problem for me with this code is that values coming from the Array(cities). I want values to come from the WebService. So i desided to build some small  site project to experience with plugin.
This is the WebService code:

As you can see there is no logic at all- web method returns the ";" deleimted Cities names in string.
Firstly i tryed to fill the values in separate ajax request-But its

Just Not Worked


Why?
Because the AJAX request that fills data in 'cities' Array is asyncronic. It means that when compiler reaches the '.autocomlete(cities' -the cities is still empty.

One way to work this around is to put the 'autocomplete' inside the 'success'  function of request:

This works fine [Download source]
But I'm not content with this solution because i want the 'suggested' values to be filled in response of user enter characters:
For this ,as i saw in plugin documentation i can put the WebService Url directly inside statement:



Here the things started to be messy. The problem is the break point in the code of webservice became not reacheable.

It taked me a long time to figure out what is the problem. I figured that after inside plugin code (jquery.autocomplete.js) in the 'request' funciton i put the error handler



inside '$.ajax' call. Yes, the ajax call of the plugin cannot reach the server unless you put following code inside web.config under 'system.web' node:



Now, after i can reach the server i started to get another error inside 'parse' function inside the plugin that tryes to split the data to rows with '\n' key.
As solution to this problem i decided to override the 'parse' function:

Now the things started to work. Now we see all cities in the list no matter wath user has
entered.
To repair this i had modifyed the WebService- GetCities method:

So now the method getting user input as parameter.
The only thing left is to modify the 'data' sended with the request inside the 'request' function of the plugin:

Now the thing is realy working:




[Download the source]

Getting started with docker

It is very simple to get started usig docker. All you need to do-is download the docker desktop for your system Once you get docker syste...