Perfect Pages Canada
ASP.NET Cafe
new tricks every week

MailEnable - How to add new mailbox from code

Tuesday, 10 February 2009 03:49 by dmitriy

Mailenable is quite good Mail Server for windows. It has a free version ( and that's version works good if you don't need WebMail ).

Here is some code to add mailbox to PostOffice.

More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   ,
Categories:   ASP.NET | C# | Main
Actions: E-mail | del.icio.us | Kick it! | DZone it! | Permalink | Comments (0) | Comment RSSRSS comment feed

How to remove IE 6 background flicker

Monday, 26 January 2009 03:14 by dmitriy

I know one thing that makes cranky all web developers who still support IE 6. Usually we can hope that soon IE 6 became history ( maybe Windows 7 will be so good... and everybody use it and new IE ). But yet many designers still support IE 6. Main trouble that IE does not cache CSS background images. And that's why you see "flicker" effect on reload of you well formed css sites. To get rid of this try to add this script somewhere in the HEAD section... 

 

[code=js]

try

{document.execCommand('BackgroundImageCache', false, true);}

catch(e)

{}[/code]

 This works for me.

ps: You can see this effect good in AJAX.NET Tabs control. http://www.asp.net/AJAX/AjaxControlToolkit/Samples/Tabs/Tabs.aspx

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   ASP.NET
Actions: E-mail | del.icio.us | Kick it! | DZone it! | Permalink | Comments (0) | Comment RSSRSS comment feed

MS SQL. How to get only date from datetime field

Tuesday, 4 November 2008 09:25 by dmitriy
And another quick tip for SQL. Sometimes we need to remove TIME part from DATETIME. For example need to group by date or so. You know your needs better.
 
Here is my solution. 
DATEADD(day, DATEDIFF(day, '20000101', RecDate), '20000101')
 
I saw some freaky CASTs and I don't like these. This returns DateTime type, not string. 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   SQL
Actions: E-mail | del.icio.us | Kick it! | DZone it! | Permalink | Comments (1) | Comment RSSRSS comment feed

MS SQL. Get rows in random order.

Monday, 15 September 2008 06:42 by dmitriy

During web development often task is to get some stuff in random order. For example, to display random articles, products, testimonials and so on.

First thing you want to do is to write something like this:

SELECT TOP 10 * 
FROM Articles 
ORDER BY RAND() 

And previous query DOES NOT work. It shows records in regular order. Why? Because RAND() calculated once, not in each row.

The following way works fine:

SELECT TOP 10 * 
FROM Articles 
ORDER BY NEWID() 

That's all. Nice and easy. Not recommended for HUGE tables... but this is crazy to try show something randomly from the huge table. Use other ways. For example sub queries.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   Main | SQL
Actions: E-mail | del.icio.us | Kick it! | DZone it! | Permalink | Comments (0) | Comment RSSRSS comment feed

Google Chrome fails ACID 3 test and pass ACID 2

Tuesday, 2 September 2008 10:03 by dmitriy

We used this test to try IE 8 sometime ago... it failed. 

http://acid3.acidtests.org/

More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   Google | Main
Actions: E-mail | del.icio.us | Kick it! | DZone it! | Permalink | Comments (0) | Comment RSSRSS comment feed

Google Chrome Beta Available For Download

Tuesday, 2 September 2008 09:27 by dmitriy

 

 Woo Hoo! Just get it!

http://www.google.com/chrome

Fisrt impression - very fast...

 More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   Main
Actions: E-mail | del.icio.us | Kick it! | DZone it! | Permalink | Comments (0) | Comment RSSRSS comment feed

23 august FFMPEG Win32 build (updated)

Wednesday, 27 August 2008 06:31 by dmitriy

 

If you don't know what is FFMPEG... you possible don't need this.

Or can check out http://ffmpeg.mplayerhq.hu/ 

More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   Main
Actions: E-mail | del.icio.us | Kick it! | DZone it! | Permalink | Comments (0) | Comment RSSRSS comment feed

ASP.NET 2.0 Big files upload on IIS 6.0 under Win2003

Saturday, 2 August 2008 06:21 by dmitriy

Recently faced the big problem with big files. Not so big, just needed to post files with size about 10-20MB to aspx page. With usage of quite standard control on the page.

Everybody know ( if not - I notice here ) that in web.config you have HttpRuntime settings. And one of these settings is  maxRequestLength .In theor, after adding of this line to web.config file everything should work fine.

 <httpRuntime maxRequestLength="100000"/>

But in fact you can face the problem of limit in IIS. And this is a pain in the ass. Because you need to edit Metabase.xml on server. Sometimes this can be impossible, but sometimes you can do this yourself or ask support. Here is some insturctions to make big files uploads work for you.

More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   ASP.NET
Actions: E-mail | del.icio.us | Kick it! | DZone it! | Permalink | Comments (0) | Comment RSSRSS comment feed

Better call for NotifyScriptLoaded in AJAX

Sunday, 27 July 2008 09:54 by dmitriy
Already on Bora bora ? I'm not...

Recently found one thing. Perhaps in docs for AJAX client or somewhere else was such line:

Sys.Application.notifyScriptLoaded(); 

You need to write this line at the end of your JS files. But this can cause the problems if you wish to re-use this code in non-ajax enviroment. For this better to use following line:

if (typeof(Sys) !== 'undefined')  Sys.Application.notifyScriptLoaded(); 

This makes things a bit better. Also, it answers another question - "Testing for defined variables in Javascript".  Sometimes I see the code like:

if( Sys )...  // And this will fail in case Sys is undefined. 

 That's all for now, it's summer. Everybody enjoy their resort life. But I'm still working.

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   ASP.NET
Actions: E-mail | del.icio.us | Kick it! | DZone it! | Permalink | Comments (0) | Comment RSSRSS comment feed

ForceWrap or when you need a whitespace

Sunday, 8 June 2008 07:08 by dmitriy

Sometimes on websites with user content you can find some design issues because of their content. Actually, I'm about the stuff like

"Swimming*Skimboaring*AquaFitness*Snorkeling*Kayaking*Basketball*Archery*Volleyball*Soccer*Table Tennis*Mini Golf*Badminton*Rock Climbing* Kiteboarding*Fencing*Gymnastics*Yoga*Pilates*"

But we ( as developers want to get rid of such ugly stuff that moves across the bounds of area and can't be wrapped - because there are no white-space inside.

For this I just written force wrap function. It is quite simple, using regular expressions

[code=cs] protected static string ForceWrap(string aStr,int max)
        {
            Regex LongLine = new Regex(@"(?<long>\S{"+max.ToString()+",})");
            MatchCollection matches = LongLine.Matches(aStr); // find all matches of "Long Strings" //
            if (matches.Count > 0)
            {
                StringBuilder sb = new StringBuilder(aStr);
               
                for (int i = 0; i < matches.Count; i++)
                {
                    string s = matches[i].Groups["long"].Value;
                    string origS = s;
                    int segments = s.Length / max;
                    for (int j = 1; j < (segments+1); j++)
                    {
                        int pos = j * max + (j-1);
                        s = s.Insert( pos , " "); // Insert Space //
                    }
                    sb.Replace(origS, s);
                }
                aStr = sb.ToString();
            }
            return aStr;
        }[/code] 

 

First parameter - the string you want to output, the second - max lenght is chars. Return value is new string with whitespace inserted if needed.

I think this is useful, but if there are something better, please let me know. 

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   ASP.NET | C#
Actions: E-mail | del.icio.us | Kick it! | DZone it! | Permalink | Comments (0) | Comment RSSRSS comment feed