Author Archives: Zafar Iqbal

Google like auto complete suggestions

I like Google’s suggest feature and was thinking of using it in any of my project. ASP.NET’s AJAX Control Toolkit have a similar control (AutoCompleteExtender) which provides a basic items to complete this functionality. I searched about its usage, and found many examples, but I was not satisfied with them. They all were populating only a single field using this extender.

I then came up with an idea, why not fill a contacts detail including its name, email address, and phone numbers using just one extender, but without modifying any provided functionality, so that our code be used with newer versions. Below is what it will look after populating that contact form.

contact

Continue reading

Rollover logging in database

We are currently working on an application (window service), which grabs alerts data from a third party web application and parses each alert and process its status, reasons, and source for different attributes and then creates tickets for support staff.

In this project we were logging all detail activities of parsing alerts into our database, which alert was raised, what was the source and IP Address and so on. Our service was grabbing data from that website after five minutes interval. There were nearly hundreds of alerts on each pass. So our log table was getting heavy each day.

Continue reading

Type.GetType()

Browsing through ASP.NET Forums, I found an interesting questions raised by a member that when he tried to get type information of a class using Type.GetType it was a charm in C#, but VB did not worked in same manners. He was trying to create new instances of that class at runtime, and populate those instances with data fetched from any database.

I checked its documentation in MSDN, here are its salient points, which should always be thought out before using this.

It accepts only a parameter which must contain an assembly qualified name of required type. This parameter could be only type name (i.e. "Contact") or may include namespace in it (i.e. "Hansvits.Models.Contact").

If parameter has only type name then method will search only in the assembly in which that call was made. If any full/partial assembly name is mentioned then it will load that assembly and search in it.

Continue reading

Bucketing consecutive numbers in a range

Recently we had a little tricky problem to solve. We were displaying a report in which we had to bucket numbers in a range, such that only consecutive numbers should be in that range, if any break is there, then a new range should start. Our first solution did not worked as required. Most difficult part was identifying numbers in a sequence, and placing them in a bucket. We could not create any simple T-SQL queries which could easily sort these things out. Then we thought of first capturing the bucket of each number so that we can easily work it out, and that was not possible without cursors. Lets have a look how we did that.

Continue reading

Mod operator puzzle

Recently I saw a puzzle on SQL Server Central, I was intrigued to solve it myself, so here is what I was able to accomplish, and in less than 10 minutes.

DECLARE @i int
SET @i = 0

CREATE TABLE #X (val INT)

WHILE @i < 100
BEGIN
    SELECT @i = @i + 1
    INSERT INTO #X VALUES (@i)
END

SELECT val,
       val % 3,
       val % 5,
       CASE 
            WHEN val % 3 = 0 AND val % 5 = 0 THEN 'BIZZBUZZ'
            WHEN val % 3 = 0 THEN 'BIZZ'
            WHEN val % 5 = 0 THEN 'BUZZ'
       END xval
FROM   #X

DROP TABLE #X

Ahsan’s second birthday

Ahsan - Shahi Masjid, Lahore Today we are celebrating birthday of my son Ahsan Zafar, many many happy wishes from me. I am a bit sorry that I would not be with him on this day. He is in Multan, with his grand parents. I think he enjoys their company, and loves to express himself and impose his tiny thoughts on them. He has that liberty with them, which I think we were denied. I don’t know why in our society people love their grand children more than their own. They are bit relaxed in this age, that may be a good reason for that. Anyhow I too enjoy time spent with them, always.

how div is drawn

In IE5 and IE6

  1. A div is rectangular.
  2. Only one corner of a div can be absolutely positioned on a page.
  3. The location of the diagonally opposing corner must be determined by the width and height of the div.
  4. The width and height can be determined using dynamic properties.

In all other browsers:

  1. A div is rectangular.
  2. All four corners of a div can be absolutely positioned on a page.
  3. If the location of diagonally opposing corners has been determined, the width and height is implied.