ASP.NET Cafe
new tricks every week

Remove links outline in IE 7 and IE 6 with JQuery

Monday, 26 July 2010 10:55 by dmitriy

IE 7 doesn't respect css property outline so you can't remove annoying outline using following css:

* :focus { outline: none; }

But you can remove it using JQuery . Most of sites already have Jquery include so you don't need to add anything except following code.

$("a").each(function() {
  $(this).attr("hideFocus", "true").css("outline", "none");
});

If you're using Mootools or Prototype - you can rewrite this code for these frameworks easily.

And this won't affect your css validation!

Be the first to rate this post

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

MVC: authorization action filters

Sunday, 25 July 2010 09:47 by dmitriy

How to protect some controller action(s) from being accessed by unauthorized users?

Usually you can check this.User.Identity.IsAuthenticated in each action. But that doesn't look good, does it?

What if we can have an attribute to mark actions accessible only by logged in users?

More...

Be the first to rate this post

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

Antoher iGoogle gadget - page response headers

Monday, 30 November 2009 11:01 by dmitriy

Here is another iGoogle gadget ( you can also put it on webpage ) called Response Headers

It's quite simple. It shows response status code and headers returned by server. Again, you can put it on iGoogle and access quickly.

Click here to add to your webpage.

Currently rated 1.0 by 1 people

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

Google Gadget - MD5/SHA1

Saturday, 28 November 2009 00:13 by dmitriy

Here is a simple Google gadget to calculate MD5 or SHA1 Hash.

Click here to add to your websitte

Click here to add to your iGoogle

Currently rated 4.0 by 1 people

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

MS SQL 2005 Performance tip: Turn off autoclose for your databases

Wednesday, 25 November 2009 08:40 by dmitriy
MS SQL 2005

For some reason by default you can have "AUTOCLOSE" property of your database set to ON. That's not bad, but if you check your server Event Log you can find a lot of entries like "Starting database 'xxxxxxx' ". And log is not a problem, but for sure this takes a time and slow down your asp.net application response.

You can turn it off in Managment Studio.
or you can run a little sql to update all databases on server:

EXECUTE sp_MSforeachdb
'
IF (''?'' NOT IN (''master'', ''tempdb'', ''msdb'', ''model''))
   EXECUTE (''ALTER DATABASE [?] SET AUTO_CLOSE OFF WITH NO_WAIT'')
'

All databases won't close automatically and response instantly.

Currently rated 5.0 by 1 people

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

How to Speed up aspnet_compiler

Monday, 16 November 2009 21:49 by dmitriy

Here is one trick to greatly speedup asp.net compiler. First of all, assume you have enough RAM to give about 512Mb for this. RAM is cheap, so you always can visit store and buy it. And your time is priceless. 

Idea is in creating RAM drive and pointing asp.net compiler temp there. To create RAM drive you need to download following free software

http://www.ltr-data.se/opencode.html#ImDisk

IMDisk - awesome thing. Install it.

Now create ramdrive.cmd somewhere ( for example c:\ramdrive.cmd ) with following content

imdisk -a -s 512Mb -m R: -p "/fs:ntfs /q /y"  

create a shortcut and add it to Startup

Now everytime you start PC you'll see quick console window and you'll got a new drive "R"

Ok. Now you need to change your temp settings

Edit this file: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\web.config  

( I assume that you've Windows installed in C:\Windows . Change path if it's different )

 In this file you need to add attribute to <compilation> tag

After change it should look like this: 

        <compilation tempDirectory="r:/asp.net_temp" > 

That's all. Now you can build your asp.net projects much faster. You can try to point all windows Temp on that RAM drive, but I haven't gone this far yet. 

Be the first to rate this post

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

SQL: Finding duplicates in table

Saturday, 14 November 2009 06:55 by dmitriy

Looking for rows with some duplicate values in some column(s) is very common. I'm not saying that's something hard.  I was asked about this. Here is the solution.

 

   1:  SELECT [Name], COUNT([Name]) as NumOccurrences 
   2:  FROM [People]
   3:  GROUP BY [Name]
   4:  HAVING ( COUNT( [Name] ) > 1 )
 

And the query to get all PKs ( primary keys ) for rows with duplicate [Name]:

   1:  SELECT [uid] 
   2:  FROM [People] 
   3:  WHERE [Name] IN (
   4:  SELECT [Name]
   5:  FROM [People]
   6:  GROUP BY [Name]
   7:  HAVING ( COUNT([Name]) > 1 ))

That's all.

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 (0) | Comment RSSRSS comment feed

Enter button and several inputs

Thursday, 2 July 2009 09:43 by dmitriy
In ASP.NET you have sometimes a problem. When you have several inputs (textboxes) and several buttons. You want user to submit it by hitting enter. For example one login box, one search box. You want to submit login box when user hits enter in password field, and search button when user hits enter in search field. The solution is easy! Just put controls inside the asp:panel with attribute DefaultButton="ButtonFind"  ( where ButtonFind is ID of desired default button ). That's all! It works!

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

BlogEngine.NET Theme - Fruity

Tuesday, 3 March 2009 06:42 by dmitriy

Hello everybody!

I've recently finished a new theme for BlogEngine.NET.

 

Fruity theme by S.D. ( aspnetcafe.com )

You can download zip here:

fruity.zip (51,19 kb)

Just unpack it to your themes folder. It works with 1.4.5.0.

That's all for today. 

Be the first to rate this post

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

H.264 vs VP 6 in hd online video

Monday, 2 March 2009 10:00 by dmitriy

What's better for your online video?

VP 6 is faster ( works on most pcs ) and requires only flash player 8. 

The BAD side of VP6 - it's hard ( or even impossible ) to find free (opensource) encoding solution for it. You need to ask on2.com guys to give you their framework or for personal use you can buy something like "Flix Standard" for $39. That's really nothing even for poor blogger.

H.264 is slower. Only last fast pcs can run it without delays. For example, I've old Celeron 2.4 and it can't handle h264, but good with vp6. But my Core2duo is good with h.264. Another problem of h264 is loosing of smoothness on low bitrate. Picture is quite good, but action is not... if you encode 1280x720 with 1Mbit/s bitrate you can see the problems with slow zooms... it jumps. Usually you can play with complicated settings, but in the end it does not matters. The good enough bitrate for h.264 if you are using 1280 x 720 is about 2-3 Mbit/s.

More...

Be the first to rate this post

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