Home Account Search

How to get folder names from server?

To databind a DropDownList control with a list of all sub directories that exist in a particular directory on the server please use code below.

string[] folders = System.IO.Directory.GetDirectories(@"C:\");

DropDownList1.DataSource = folders;

DropDownList1.DataBind();

What is Text / Tag Cloud ?

Tag Cloud A.K.A Word Cloud is a visual representation of important title tags or link texts on a website. This is achieved with all tags so close to each other and separated with varying font size, style and colours making it look like a cloud. These tags are normally hyper linked.

The following Tag Cloud image is taken from our website home page. This interactive Tag Cloud is achieved with a flash and XML based textCloud:

text-cloud.jpg

DateTime Magic Function for SQL database

If you are in to developing custom website design or database development, here is a customised function you can use to get different date-time formats from your SQL database. These are obtained with a little twicks and tricks to make your SQL server do a little more then what it can with its native date/time functions.  It may be very useful for some data-critical projects:

Function:



CREATE FUNCTION dbo.FormatToDateTime
(
    @dt DATETIME,
    @format VARCHAR(16)
)
RETURNS VARCHAR(64)
AS
BEGIN
    DECLARE @dtVC VARCHAR(64)
    SELECT @dtVC = CASE @format
 
    WHEN 'LONGDATE' THEN
 
        DATENAME(dw, @dt)
        + ',' + SPACE(1) + DATENAME(m, @dt)
        + SPACE(1) + CAST(DAY(@dt) AS VARCHAR(2))
        + ',' + SPACE(1) + CAST(YEAR(@dt) AS CHAR(4))
 
    WHEN 'LONGDATEANDTIME' THEN
 
        DATENAME(dw, @dt)
        + ',' + SPACE(1) + DATENAME(m, @dt)
        + SPACE(1) + CAST(DAY(@dt) AS VARCHAR(2))
        + ',' + SPACE(1) + CAST(YEAR(@dt) AS CHAR(4))
        + SPACE(1) + RIGHT(CONVERT(CHAR(20),
        @dt - CONVERT(DATETIME, CONVERT(CHAR(8),
        @dt, 112)), 22), 11)
 
    WHEN 'SHORTDATE' THEN
 
        LEFT(CONVERT(CHAR(19), @dt, 0), 11)
 
    WHEN 'SHORTDATEANDTIME' THEN
 
        REPLACE(REPLACE(CONVERT(CHAR(19), @dt, 0),
            'AM', ' AM'), 'PM', ' PM')
 
    WHEN 'UNIXTIMESTAMP' THEN
 
        CAST(DATEDIFF(SECOND, '19700101', @dt)
        AS VARCHAR(64))
 
    WHEN 'YYYYMMDD' THEN
 
        CONVERT(CHAR(8), @dt, 112)
 
    WHEN 'YYYY-MM-DD' THEN
 
        CONVERT(CHAR(10), @dt, 23)
 
    WHEN 'YYMMDD' THEN
 
        CONVERT(VARCHAR(8), @dt, 12)
 
    WHEN 'YY-MM-DD' THEN
 
        STUFF(STUFF(CONVERT(VARCHAR(8), @dt, 12),
        5, 0, '-'), 3, 0, '-')
 
    WHEN 'MMDDYY' THEN
 
        REPLACE(CONVERT(CHAR(8), @dt, 10), '-', SPACE(0))
 
    WHEN 'MM-DD-YY' THEN
 
        CONVERT(CHAR(8), @dt, 10)
 
    WHEN 'MM/DD/YY' THEN
 
        CONVERT(CHAR(8), @dt, 1)
 
    WHEN 'MM/DD/YYYY' THEN
 
        CONVERT(CHAR(10), @dt, 101)
 
    WHEN 'DDMMYY' THEN
 
        REPLACE(CONVERT(CHAR(8), @dt, 3), '/', SPACE(0))

    WHEN 'MM-YY' THEN
 
        right(convert(varchar(10),@dt,105),7)    
    WHEN 'Mon YYYY' THEN

        SUBSTRING(CONVERT(VARCHAR(11), GETDATE(), 113), 4, 8)    
 
    WHEN 'DD-MM-YY' THEN
 
        REPLACE(CONVERT(CHAR(8), @dt, 3), '/', '-')
 
    WHEN 'DD/MM/YY' THEN
 
        CONVERT(CHAR(8), @dt, 3)
 
    WHEN 'DD/MM/YYYY' THEN
 
        CONVERT(CHAR(10), @dt, 103)
 
    WHEN 'HH:MM:SS 24' THEN
 
        CONVERT(CHAR(8), @dt, 8)
 
    WHEN 'HH:MM 24' THEN
 
        LEFT(CONVERT(VARCHAR(8), @dt, 8), 5)
 
    WHEN 'HH:MM:SS 12' THEN
 
        LTRIM(RIGHT(CONVERT(VARCHAR(20), @dt, 22), 11))
 
    WHEN 'HH:MM 12' THEN
 
        LTRIM(SUBSTRING(CONVERT(
        VARCHAR(20), @dt, 22), 10, 5)
        + RIGHT(CONVERT(VARCHAR(20), @dt, 22), 3))
 
    ELSE
 
        'Invalid format specified'
 
    END
    RETURN @dtVC
END
GO

Example :

PRINT dbo.FormatToDateTime(@now, 'DD/MM/YY')



Now you can also use some tricks by using mix and match to get more out of it. It is easy to alter this function for adding more datetime formats.
Enjoy....

How to disable dotted outline in Mozilla Firefox

In Mozilla browsers it shows a dotted outline around a button, any link or an object like flash or video when it is clicked.  It can be removed by applying following code to your CSS:  

Success.gifAccepted Solution :


* { outline: none; }

here we have used * to apply the rule so it applies to everything system-wide and you do not need to define it manually for every single thing. However, if you prefer to keep this dotted line for any specific event then you should not be using the * and define it to individual item that you would like to exclude.

features of sql server 2008

 SQL Server 2008 is a way better then its previous version when it comes to reliability, security and scalability for your business-critical applications. The major feature offered by the robust database server from Microsoft includes, but not limited to:

  • Analysis Services
  • Data Mining
  • High Availability—Always On
  • Integration Services
  • Manageability
  • Performance and Scalability
  • Programmability
  • Reporting Services
  • Security
  • Spatial Data

read more about SQL 2008 at Microsoft official website

How to remove __VIEWSTATE from asp.net?

There is no obvious side-effect free way to remove this.

The problem is that the hidden type can never be empty. even if you try  EnableViewState = False then also the hidden type __ViewState is still rendered with some values. Yes one can make it "" to ViewState, but this may be an invitation to errors for some other applications! Yes, things may get worse this way.


No Search Engine Effect

As per my experience it generally does not affect your ranking or position or search engines. Most search engine bots such as google are familier with this and so the ranking is not affected.