Wednesday, November 5, 2014

Change Doc type to IE8 or IE8 Compatibility mode

Change Doc type to IE8 or IE8 Compatibility mode:

There are some old development that doesn't support in newer version of IE and Chrome. So best option is to make changes in code work for latest IE versions and Chrome. But this is the case not always possible for example previous code was built using third party controls (Infragistics in my case) to make it work with Newer version of IE we need upgraded version on Infragistics and it involves addition cost of licensing.
One other work around if it is possible to support only IE  browser than we can use solution suggested below: (BUT it is not best solution)

<html><head>
 <title> My Page</title>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8">

<meta http-equiv="X-UA-Compatible" content="IE=8">
<head><body>
 ---------------
</body></html>


Note : Make sure to use meta tag just after title tag otherwise it wont work.





Happy Coding...
Happy Concepts...
Happy Living....

Monday, May 5, 2014

Convert local datetime to UTC or Universal data time and UTC to local datetime


--Steps required before performing conversion:

--step:

Declare @TimezoneOffset int=0

-- variable will hold the timezone difference in minutes

set @TimezoneOffset =  DATEDIFF(Minute, GETUTCDATE(), GETDATE())

--Now we have localtimezone difference with UTC.

--Convert Local datetime to UTC:-

Declare @LocalDatetime datetime= GetDate()

Declare @UTCDatetime datetime =null

select  @UTCDatetime= DateAdd(Minute,-@TimezoneOffset,@LocalDatetime)

--Convert UTC to Local datetime :-

 Declare @ConvertedLocalDatetime datetime=null

select @ConvertedLocalDatetime= DateAdd(Minute, (@TimezoneOffset),@UTCDatetime)

select 'LocalTime:-',@LocalDatetime,'  UTC Datetime : ', @UTCDatetime ,'ConvertedLocalDatetime : ', @ConvertedLocalDatetime

Monday, April 7, 2014

Download file using javascript/Jquery

On aspx page add this:

<iframe id="hiddenDownloaderForPdf" style="display:none" ></iframe>


on Javascript file:

function downloadFile (url) {
        var hiddenDownloaderForPdf= 'hiddenDownloaderForPdf'
        iframe = document.getElementById(hiddenDownloaderForPdf);
//if iframe isnt available create one dynamiclly
    if (iframe === null) {
        iframe = document.createElement('iframe');
        iframe.id = hiddenDownloaderForPdf;
        iframe.style.display = 'none';
        document.body.appendChild(iframe);
    }
    iframe.src = url;
}

using jQuery:
function downloadFile (url) {
        var hiddenIFrameID = 'hiddenDownloaderForPdf'

       $('#'+ iframe).attr('src' ,url);
  }

Happy Living.....
Happy Concepts.......
Happy Coding........


Download file using javascript/Jquery

On aspx page add this:

<iframe id="hiddenDownloaderForPdf" style="display:none" ></iframe>


on Javascript file:

function downloadFile (url) {
        var hiddenDownloaderForPdf= 'hiddenDownloaderForPdf'
        iframe = document.getElementById(hiddenDownloaderForPdf);
//if iframe isnt available create one dynamiclly
    if (iframe === null) {
        iframe = document.createElement('iframe');
        iframe.id = hiddenDownloaderForPdf;
        iframe.style.display = 'none';
        document.body.appendChild(iframe);
    }
    iframe.src = url;
}

using jQuery:
function downloadFile (url) {
        var hiddenIFrameID = 'hiddenDownloaderForPdf'

       $('#'+ iframe).attr('src' ,url);
  }

Happy Living.....
Happy Concepts.......
Happy Coding........


Way to rename table without changing references of Table


Some time problems are not that easy to resolve because we got stuck in our think box. But how can we think out of box if we sit in a cube( jokes apart).
Today we are faced an issue where we have to rename table name and add new column in it so that we can differentiate existing data with new added records. But it wasn't possible because this table is used as first table in joins.

for example :

tblX
id name description

tblB
Bid Xid Values


select * from tblX a
inner join tblB  b on a.id=b.Aid 
and i am doing this kind of thing hundred of places in my SPs.

Now my requirement is something like that

Rename table to tblX to tblXYZ and add new column CategoryType.
Update all records with CategoryType 'X'

tblXYZ
id name description category

 so for making existing code work i may need to change above queries like that:

select * from tblXYZ a
inner join tblB  b on a.id=b.Aid 
where a.CategoryType='X'

but this isnt possible for me so what i can do?????

Solution:

instead of changing queries in SP what we can do we can create  a new VIEW
with same name tblX and define it as :

select * from tblXYZ
where CategoryType='Y'


by using this VIEW we doesn't require to change SP's .

This is the best approach in fount till now ,, if there will anything new i'll let you know.


Happy Living.....
Happy Concepts.....
Happy Coding...........