Monday 23 February 2015

Show waiting symbol on page postback

Here is a quick code for displaying waiting symbol, whenever a button click takes a long time, in .aspx pages.

Create css entries as shown below:

<style type="text/css">
        .modal
        {
            position: fixed;
            z-index: 999;
            height: 100%;
            width: 100%;
            top: 0;
            left: 0;
            background-color: white;
            filter: alpha(opacity=60);
            opacity: .6;
            -moz-opacity: 0.8;
        }
        .center
        {
            z-index: 1000;
            margin: 300px auto;
            padding: 10px;
            width: 65px;
            overflow: auto;
            background-color: white;
            border-radius: 10px;
            filter: alpha(opacity=60);
            opacity: .6;
            -moz-opacity: 1;
        }
        .center img
        {
            position: absolute;
            filter: alpha(opacity=100);
            opacity: 1;
            top: 50%;
            left: 50%;
            margin: -27px 0px 0px -75px;
        }
     
    </style>

Place all your controls in "UpdatePanel" section. In "UpdateProgress" section, mention the image\div which you want to show as a waiting symbol (in this example, we are using image as waiting symbol)

<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
    <div class="modal">
        <div class="center">
            <img alt="loading..." src="img.gif" />
        </div>
    </div>
</ProgressTemplate>
</asp:UpdateProgress>

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
// place all the controls which should show waiting symbols on event postback
    </ContentTemplate>
</asp:UpdatePanel>

Monday 23 December 2013

SQL Server Joins - Mystery Resolved

Working with SQL server was always a troublesome experience for me, especially when I had to pick up data from multiple tables. Working with multiple tables (Joins) was never my forte and used to give goose bumps whenever I work with those. I always used to feel like a tail ender batsman, who is facing a fiery spell from a lead bowler of opposite team, until I saw a FB post where joins are explained with the help of pictures. That gave me a bit of confidence, so I thought of sharing the same with of you. 

For explanation, I am assuming that circles represents 2 different tables, say TABLE1 and TABLE2, with COLUMN1 as the common field between 2 tables, and highlighted portion (in red) is the result of query.

Here are the tables, I am using for below examples:

TABLE1
EMPID
EMPNAME
DESIGNAION
SALARY
1001
AAA
MANAGER
2,000,000
1002
BBB
TEAM LEAD
1,500,000
1003
CCC
SR. DEVELOPER
1,200,000
1004
DDD
DEVELOPER
900,000
1005
EEE
DEVELOPER
700,000

TABLE2
EMPID
EMPNAME
DESIGNAION
SALARY
1001
AAA
MANAGER
2,000,000
1002
BBB
TEAM LEAD
1,500,000
1005
EEE
DEVELOPER
1,200,000
1007
GGG
DEVELOPER
900,000
1008
HHH
DEVELOPER
700,000

-------------------------------------------------------------------------------------------------

Inner Join


SELECT
*
FROM
TABLE1 TBL1
INNER JOIN
TABLE2 TBL2
ON
                TBL1.EMPID = TBL2.EMPID

TABLE1
TABLE2
EMPID
EMPNAME
DESIGNAION
SALARY
EMPID
EMPNAME
DESIGNAION
SALARY
1001
AAA
MANAGER
2,000,000
1001
AAA
MANAGER
2,000,000
1002
BBB
TEAM LEAD
1,500,000
1002
BBB
TEAM LEAD
1,500,000
1005
EEE
DEVELOPER
1,200,000
1005
EEE
DEVELOPER
1,200,000

-------------------------------------------------------------------------------------------------

Left Join


SELECT
*
FROM
TABLE1 TBL1
LEFT JOIN
TABLE2 TBL2
ON

                TBL1.EMPID = TBL2.EMPID


TABLE1
TABLE2
EMPID
EMPNAME
DESIGNAION
SALARY
EMPID
EMPNAME
DESIGNAION
SALARY
1001
AAA
MANAGER
2,000,000
1001
AAA
MANAGER
2,000,000
1002
BBB
TEAM LEAD
1,500,000
1002
BBB
TEAM LEAD
1,500,000
1003
CCC
SR. DEVELOPER
1,200,000




1004
DDD
DEVELOPER
900,000




1005
EEE
DEVELOPER
700,000
1005
EEE
DEVELOPER
1,200,000


-------------------------------------------------------------------------------------------------

Right Join




SELECT
*
FROM
TABLE1 TBL1
RIGHT JOIN
TABLE2 TBL2
ON
                TBL1.EMPID = TBL2.EMPID

TABLE1
TABLE2
EMPID
EMPNAME
DESIGNAION
SALARY
EMPID
EMPNAME
DESIGNAION
SALARY
1001
AAA
MANAGER
2,000,000
1001
AAA
MANAGER
2,000,000
1002
BBB
TEAM LEAD
1,500,000
1002
BBB
TEAM LEAD
1,500,000
1005
EEE
DEVELOPER
700,000
1005
EEE
DEVELOPER
1,200,000




1007
GGG
DEVELOPER
900,000




1008
HHH
DEVELOPER
700,000

-------------------------------------------------------------------------------------------------

Full Outer Join



SELECT
*
FROM
TABLE1 TBL1
FULL OUTER JOIN
TABLE2 TBL2
ON

                TBL1.EMPID = TBL2.EMPID

TABLE1
TABLE2
EMPID
EMPNAME
DESIGNAION
SALARY
EMPID
EMPNAME
DESIGNAION
SALARY
1001
AAA
MANAGER
2,000,000
1001
AAA
MANAGER
2,000,000
1002
BBB
TEAM LEAD
1,500,000
1002
BBB
TEAM LEAD
1,500,000
1003
CCC
SR. DEVELOPER
1,200,000




1004
DDD
DEVELOPER
900,000




1005
EEE
DEVELOPER
700,000
1005
EEE
DEVELOPER
1,200,000




1007
GGG
DEVELOPER
900,000




1008
HHH
DEVELOPER
700,000

-------------------------------------------------------------------------------------------------

Left Outer Join where NULL


SELECT
*
FROM
TABLE1 TBL1
LEFT OUTER JOIN
TABLE2 TBL2
ON
                TBL1.EMPID = TBL2.EMPID
WHERE

                TBL2.EMPID IS NULL


TABLE1
TABLE2
EMPID
EMPNAME
DESIGNAION
SALARY
EMPID
EMPNAME
DESIGNAION
SALARY
1003
CCC
SR. DEVELOPER
1,200,000




1004
DDD
DEVELOPER
900,000




-------------------------------------------------------------------------------------------------

Right Outer Join where NULL


SELECT
*
FROM
TABLE1 TBL1
RIGHT OUTER JOIN
TABLE2 TBL2
ON
                TBL1.EMPID = TBL2.EMPID
WHERE

                TBL1.EMPID IS NULL


TABLE1
TABLE2
EMPID
EMPNAME
DESIGNAION
SALARY
EMPID
EMPNAME
DESIGNAION
SALARY




1007
GGG
DEVELOPER
900,000




1008
HHH
DEVELOPER
700,000

-------------------------------------------------------------------------------------------------

Full Outer Join where NULL


SELECT
*
FROM
TABLE1 TBL1
FULL OUTER JOIN
TABLE2 TBL2
ON
                TBL1.EMPID = TBL2.EMPID
WHERE
                TBL1.EMPID IS NULL
OR
                TBL2.EMPID IS NULL

TABLE1
TABLE2
EMPID
EMPNAME
DESIGNAION
SALARY
EMPID
EMPNAME
DESIGNAION
SALARY
1003
CCC
SR. DEVELOPER
1,200,000




1004
DDD
DEVELOPER
900,000








1007
GGG
DEVELOPER
900,000




1008
HHH
DEVELOPER
700,000


Now after this, I am confident enough, like any other top order batsman, who can play any bowler with ease J.

Same article is also published in my company's official site. Please click here to see the article over there.