31 March 2011

Code 128 C - SQL Function

The Code 128 barcode is a high-density linear symbology that encodes text, numbers, numerous functions and the entire 128 ASCII character set (from ASCII 0 to ASCII 128.) It is commonly used for several implementations; and is also referred to as ISBT-128, GS1-128, UCC-128, EAN-128 and USS Code 128.

Code 128 contains 106 different printed barcode patterns. Each printed barcode may have one of three different meanings depending upon which of the character sets are being used, with the availability of three different Code 128 start characters to program the initial character set. Functions are also provided in the barcode symbology to switch between character sets and encode Application Identifiers. The Code 128 barcode may be complex to use because of the different character sets, which is the primary reason IDAutomation provides the Code 128 auto function, "Code128( )", in several of the Font Tools, Components and Applications.
The complete Code 128 barcode consists of a start character, data digits, a modulo 103 check digit and a stop character.

Many developers are searching a way of how to correctly encode the string using SQL.
I had a need to dispaly a 10 characters long string (containing numbers only) as a barcode, this is why I had first to encode it correctly in Code 128 C format.

29 March 2011

Custom Insert/Update on LinqToSql and ASP.NET Dynamic Data

ASP.NET Dynamic Data brings major usability and RAD development changes to the existing ASP.NET data controls. RAD development is significantly increased by the use of a rich scaffolding framework.

If you want to create a custom insert or update for ASP.NET Dynamic data and LinqToSQL then you will have to perform the following steps:
1) Create a partial class for the entity you want to make the insert/update custom. For example if you had a table name employees then your code would look like this:
public partial class Employees

25 March 2011

Javascript Debugger does not work in IE9


As I said previously I had installed Internet Explorer 9 on my computer and I also said you that this was a very BAD idea.

Here is one more reason of why it was a bad idea - my lovely javascript command is not working anymore, I am talking about debugger;

Do you remember in Internet Explorer 7 and 8, am not sure about IE6 (I vague remember, but I think debugger was working in IE6 too), that when you put debugger somewhere in the code IE opens a popup with the message: "An error has occurred. Do you wish to Debug?", or something like that. After what you can press YES and you then can select the application with which you wish to debug your page.

For me the above behavior was something which helped me a lot.

Now with IE9 the problems starts the keyword - debugger - DOES NOT DO ANYTHING.
What is that? Why?

24 March 2011

MS SQL RowID equivalent

Hello everyone,

Many MS SQL developers ask if there is an equivalent to RowID from ORACLE in MS SQL.

The answers is NO.

But there is a workaround. You can use ROW_NUMBER() instead and where you will need to specify based on which columns to generate RowID, the order in which the ROW_NUMBER value is assigned to the rows in a partition.

Here is an example:

SELECT FirstName, LastName, ROW_NUMBER() OVER(ORDER BY SalesYTD DESC) AS 'Row Number', SalesYTD, PostalCode
FROM Sales.vSalesPerson

You can see more details on Microsoft's page about ROW_NUMBER() function: http://msdn.microsoft.com/en-us/library/ms186734.aspx

Simple, isn't it?

21 March 2011

jQuery Dialog BUG in IE6 & Quirks Mode


I have found a bug in jQuery dialog - it has strange behavior when dragging and resizing a dialog in IE6 or IE7 and up in Quirks Mode.

The problem is that when resizing or dragging many times then the Dialog:
  • Becomes smaller;
  • The content becomes bigger.
I've been trying a lot to try and fix this, I had a walk-through the jQuery UI code and found out these:
On dragging guys from jQuery performs some strange things:
  • Why do they set the height of the Dialog to it's height? "$(this).height($(this).height())". I would not have had anything against it if that piece of code would not set the height of the Dialog with 5px shorter.
    Yes, I'm serious - 5px shorter, however I could not understand how that is possible because it set's the height to the same height.

17 March 2011

Did you try Internet Explorer 9 ?

Wwwwwooooooowwww, this is what I can tell you about it.

It has a very simple and intuitive interface and it is easy to use. Till now Google Chrome was the best for me (my preference, I can tell that I was a fun), however now I see that Internet Explorer took the right way, and made so that the user have more space to view the page but not Browser's menu, tabs and buttons.

Here is a screenshot of the new Internet Explorer - Version 9.

Click on the image to enlarge:

But hold on, the new interface is not the only thing with which Microsoft is making us happy, the other thing is that this browser's speed will surprise you, it is really fast.

I personally made some tests with a page where I had a lot of Javascript with asynchronous calls to the server, I didn't even needed to use any tool to compare IE 9 with other Browsers like: Chrome, Firefox and Safari. Do you know why? Because you can see that by yourself, without any tool.

09 March 2011

CheckBox "onchange" event fired before "onclick" event in Google Chrome


      When working on another Javascript Library I have found another problem or maybe I am wrong and this is expected behavior. The problem is:
           - In Internet Explorer - onchange event is fired after the onclick event;
           - In Google Chrome - onclick event is fired after the onchange event.

      I am not sure about other browsers.

      All this refers to checkbox only, because I didn't try others, but I guess radiobuttons have the same issue.

ASP.NET __doPostBack not working


Did it happened so that you try to use __doPostBack javascript function but it didn't work?

 __doPostBack - is a function which makes a postback to the server with an target element ID, and it should also fire the corresponding Event on server-side automatically. This is a very useful function.

Well there are several possible situations that I know where it doesnt work:
1) because you are passing an invalid ID;
2) you should use btnObj.ClientID for ASP.NET controls
3) because you are trying to call __doPostBack for a button that is placed on a page with Master Page or for a button that is inside an ASCX control.

Make HTML elements like DIV, SPAN, Table focusable


When you need to detect onkeydown event it is fine to do this with focusable elements like: inputs, dropdowns,..., but what to do with non-focusable elements like DIVs, SPANs, TABLEs?

You can achieve this by adding TABINDEX attribute to these elements, this way browsers will consider that element as a focusable element.

Also depending of what value you set to tabindex attribute - it will behave differently:

ASP.NET Dynamic Data - Default sort Table by specific column(s)


      ASP.NET Dynamic Data brings major usability and RAD development changes to the existing ASP.NET data controls. RAD development is significantly increased by the use of a rich scaffolding framework.

      The DetailsView and GridView controls have been extended to display fields by using templates instead of by using hard-coded rules that are programmed in the controls. These templates are part of the project, and you can customize them to change their appearance or to specify which controls they use for rendering. This makes it very easy to make a change in one place in your site that specifies how to present dates for editing, as one example.

      But it is not so flexible as we wanted and it does not allow default sorting on tables.

      Here is a solution of how to make your ASP.NET dynamic data GridView sorted by default. This solution will require you to create an attribute - MySortByAttribute which will contain 2 proprieties: SortExpression (of type: String) and SortDirection (of type: SortDirection).

Height 100% does not work

Height 100% does not work ?

When you put a height for an element inside the page to have 100% of the parent element it does not work?
This is correct.

I have also had this problem and I have found out that this is because when you put 100% it will take 100% of the height of the html document or 100 % of the body.

But in modern browsers html's and body's default height looks to be set to 0 pixels. Which means that their height will be adjusted to the height of inner elements.

So what to do if you want your element to be 100% of the browser window?
ANSWER: make html and body to have height set to 100%, in this case these will take 100% of the window and this way you will be able to set the height for the elements inside html and body needed value in percents.

window.showModalDialog() - Cross Browser, new version


This is a continuation, or a new version for my last post about window.showModalDialog().

The new version was implemented as a jQuery function to which you can pass options which you like.
This version was made because:
    1) The impossibility of previous version to retain dialogArguments during postback;
    2) The impossibility of previous version to close the dialog when the target page is inside several iframe tags;
    3) The impossibility of previous version to retain window.returnValue during postback;
    4) It will be possible now to fire a postback of the page or to fire a postback of a element (with targetElementId) right after the dialog was closed and the callback function finished to execute;
    5) Theoretically this popup library can be used to open another popup inside an existing one (Note: I haven't tried this yet).

However, previous version of my showModalDialog can satisfy someone's requirements and it will be no need to complicate his life with the new version.

XML Parsing and other XML Utilities - Cross Browser


Are you searching for an alternative to new ActiveXObject("Microsoft.XMLDOM") which will work in all popular browsers? Then here it is a solution.

This Javascript library will give you the possibility to do almost everything what you could do with ActiveXObject("Microsoft.XMLDOM") but in different browsers.

IE window.showModalDialog() - Cross Browser solution


QUESTION: How to make window.showModalDialog() work on cross browser? or at least how to do something similar? with arguments, return value and window.close()?

ANSWER: There is no simple way to do that.

ATTENTION: dialogArguments will be lost if the page inside the popup will do a postback. For a better solution see my new version - click here.

First of all window.showModalDialog() function is something which works only on Internet Explorer and in the best case this command will open a new small window on some browsers, however this window is far from a modal window.

If you still need to have the same functionality as window.showModalDialog(), to pass some parameters / arguments to the page inside the popup and then return some values back from that page in the parent page, and also have the ability to close the popup from the inside of the popup then this article is for you.

Here I have created a modal popup, using jQuery, which gives you the ability to pass arguments to the page inside the popup almost in the same way as you would pass it through showModalDialog().

02 March 2011

SQL - How to check if a string has uppercase / lowercase characters


When you need to compare two strings in SQL to check if this string contains uppercase or lowercase values it is always a problem, because in sql "ExTremeDev.blogSpot.com23" is equal to "extremedev.blogspot.com23".

I also needed to do such thing, in order to make some rules for a password, so that it will contain numbers, uppercase characters and lowercase characters.

Here I will provide an example like that:

Need more? Leave comments and subscribe to my blog.