Code Snippets

Random order in SQL

Another quick code snippet I found pretty useful this week. In a SQL command you can use “ORDER BY NEWID()” to randomly order your results.

This can be implemented in a number of ways – to randomly display advertising features, news items or any other set of records or you can use “SELECT TOP 1 ID FROM TABLENAME ORDER BY NEWID()” to grab a record at random.

Helicon root redirect

Another quick issue…I needed to use Helicon 3.x to redirect the root of a website to a subfolder…

Here is the code

RewriteBase
RewriteCond %{HTTP_HOST} ^(?:www\.)?mywebsite\.com$ [NC]
RewriteRule ^/?$ http://www.mywebsite.com/myfolder [R=301,L]

Using devExpress Text Box as a hidden field

I use the devExpress controls in a range of my websites. Tonight I was having a problem implementing an ASPxTextBox as a hidden field…the normal hidden field was no good as I am inside an ASPxCallbackPanel and I was losing the value.
Read the rest of this entry »