Monday, 28 October 2013

Getting List of all the foreign keys and there details with table and field name

SELECT tabs.name AS [Reference Table],
   (SELECT name FROM sys.tables AS ctab
       WHERE (object_id = fk.parent_object_id)) AS [Parent Table],
       fk.name AS [Key Name],
        ac.name AS [Column Name]
FROM sys.tables AS tabs INNER JOIN            
sys.foreign_keys AS fk ON fk.referenced_object_id = tabs.object_id inner join            
sys.foreign_key_columns as fkc on fk.object_id = fkc.constraint_object_id inner join            
sys.all_columns as ac on ac.column_id = fkc.parent_column_id
             and ac.object_id = fkc.parent_object_id
ORDER BY tabs.name, 2

Thursday, 17 October 2013

Response.Flush() vs Response.End

Response.Flush() vs Response.End:
Response.Flush

Forces all currently buffered output to be sent to the client.
The Flush method can be called multiple times during request processing.

Response.End

Sends all currently buffered output to the client,
stops execution of the page, and raises the EndRequest event.

Null checking in Editor

<script language="javascript" type="text/javascript">
            function test() {              
                var a = $find("<%=Editor1.ClientID%>");
                var value = a.get_content();              
                //alert(value);
                value = value.replace(/<br \/>/gi, '');
                value = value.replace(/&nbsp;/gi, '');
                value = value.replace(/^\s+|\s+$/g, '')
                //alert(value);
                //alert((value).replace(/<br \/>/gi, ''));
            if (value == "") {
                alert("Editor's content is empty");
                return false;
            }
        }
    </script>