Monday, September 28, 2009

301 redirect windows server - for HTML pages

I was working on moving a website over... The old site was html only - the new one is ASP.net. The puzzle was how to get the 301 redirects set up on a windows box? I have done it in code-behind... if it is an ASP.Net page... and with classic "asp" pages.

HERE is what I found
IIS Redirect
In internet services manager, right click on the file or folder you wish to redirect
Select the radio titled "a redirection to a URL".
Enter the redirection page
Check "The exact url entered above" and the "A permanent redirection for this resource"
Click on 'Apply'

more on 301 redirects

Sunday, August 2, 2009

Dynamically Loaded Controls Disappear ASP.Net C#

I have been working with dynamically loaded Web User Controls.

However,I just found that they disappear after a postback... The basic solution is to reload them after postback.

Oh well...

Related articles (with info/tips/code):

[Telerik has good tips on using viewstate to help]

http://www.telerik.com/help/aspnet/ajax/ajxloadusercontrols.html


http://aspnet.4guysfromrolla.com/articles/092904-1.aspx

http://weblogs.asp.net/infinitiesloop/archive/2008/04/23/truly-understanding-dynamic-controls-by-example.aspx

Javascript Cross Browser Back Method

I have been working on a quick CROSS browser "back" method in JavaScript. It is really simple...

The history.go(-1) only worked well in IE. This double method worked well in IE, Firefox and Chrome. It checks if it knows how to do the "referrer" method. If not... it uses the history.go


[a href="#" onclick="if(document.referrer) {window.open(document.referrer,'_self');} else {history.go(-1);} return false;"]continue shopping[a]

Of course, you should use a "<" instead of "[" ... Blogger had issues when I posted the full link.

Friday, June 12, 2009

MySql Text Field - Truncating Data?

Every now and then you run an application that really tests the constraints of data types. I just encountered this....

I just found out that in MySql "BLOB TEXT A BLOB or TEXT column have a maximum length of 65535 (2^16 - 1) characters". I was encountering some data errors with large text chunks - and finally found that they were being truncated silently... When I counted the characters - yes... that was the issue.

Arggg!

But there is a simple solution... LONGTEXT or LONGBLOB fields can handle the larger bits of data - if this is expected. This gives you approx 4 Gig of space to work with. Good to know.

Tuesday, June 9, 2009

Standard Web Page Width

I have been building web pages for over 6 years... and have been using a standard web page width of 778px for 800px monitors, unless the client requests otherwise. The concept is to avoid (left/right) scrolling and make a good user experience.

Most of the justification came from the analysis/tips in Jakob Nielson's book on "Homepage Usability" - dated in 2002. Most other articles I've read suggest this... but the trend is changing, as these monitors become fewer.

Floating widths are cool - and useful. But they take longer to develop and I only do those on request, at an extra fee. However, since my statistics show that less than 2% use 800 px monitors, I am about to change my policy...

But what width to use? Of course I will build for the 1024px monitors... the next size up. This is the largest percentage for screen resolutions now - about 34%. But I am considering only using 960px width for the regular content. That will allow for those who don't open their browser all the way. And it will allow the background colors/gradients to properly frame the page.

More info:
http://webdesign.about.com/od/webdesign/a/aa080904.htm

http://funbytebitstop.wordpress.com/2007/03/01/775-px-make-it-your-default-webpage-width/

http://www.jimdegerstrom.com/blog/2008/07/standard-web-design-page-width.html

Screen Resolution Statistics
One of my websites gets 7,500 visitors per month on average...
21% use screen resolution 1024x768
18% use 1280x800
10% use 1280x1024
10% use 1440x900
7.6% use 1366x768
7% use 1680x1050
3.4% use 1920x1080
3% use 1920x1200
2.8% use 1600x900
2.25% use 1152x864
1.6% use 1280x768
1.5% use 1280x720
1.25% use 1360x768
0.9% use 800x600
0.9% use 1280x960
....

So it seems that less than 1 in 100 use the smaller 800 X 600 monitors...
Any thoughts?

Wednesday, May 6, 2009

Google Maps - just the basics please

My Spiderweb Logic CMS has had Google Maps integrated into it for a couple years, so I havent had to focus on this for a bit. However, someone just asked me how to integrate Google Maps into their website. This is never a 2 sentence explanation. Here are the basics:

First figure out what you want.

I want GOOGLE MAPS imbedded IN my website:

You will need to use the API to build your map. Reviewing the official documentation will help with "how do I" questions specific to your website.

REF: http://code.google.com/apis/maps/documentation/

1) COPY/Paste code for your website

This is the best method:
http://code.google.com/apis/maps/documentation/#AJAX_Loader
They give you a bunch of javascript. Put it between the head tags.

Don't forget to create a "div" tag in the body with the id of "map" to contain your map.

2) Get a Google API Key for your website (even if it is localhost)

3) Replace the ABCDEFG in the above template with your google key.

4) Find the longitude/latitude of the location you want to center on.
Get longitude and latitude. If you are doing things dynamically both Yahoo and Google provide geocoding apis. But for one-time use, that link is the best.

5) Replace longitude and latitude numbers in the sample code with the actual longitude and latitude for your location.
ref: map.setCenter(new google.maps.LatLng(37.4419, -122.1419), 13);

It should now work.
You can alter the zoom in/out features by changing the 13 to a different number. You can alter the width and height by altering the width/height of the div tag.

You might also find the tutorial helpful here:
tutorial: http://code.google.com/support/bin/answer.py?answer=74725&topic=11364
list of events: http://econym.googlepages.com/gevent.htm

I want to link to a GOOGLE MAP defined with my specific location(s):

This means that your map stays at Google. You just link to it from your website. However, you can configure a map specific to your needs - with your location preferences.

STEPS:
1) Log into your Google account. (Get one if you dont already.)

2) Get to the Google "maps" product

3) Create a new map and set your preferences. Put in a name and description. Dont forget to save.

4) Go back in edit mode and drag markers/balloons to your locations. Save.
NOTE: When you are editing your map you can zoom in to help put in your markers.

5) Get a link to your map. (Click on the "collaborate" link on left to get the URL. Copy/paste the full URL noted to the "href" of a link.) example map

Tuesday, April 21, 2009

Business Testimonial Sites

One of my clients was interested in using some testimonial sites, and wanted to know what was out there.

Honestly, there are several sites that let you post a business profile and manage testimonials / business ratings. The trick is to hit the main ones (in case someone searches for you) and to use them to build your reputation/goodwill etc - and perhaps your search ranking.

TIP 1: create accounts in about 3-4 sites. You dont need to create and manage accounts in lots of these unless you have LOTS of time. But only let your customers know about 1 or two at a time. That way you can have several testimonials with one site. (Its a good idea to put links to these in your emails and in your website.) As you grow, share the other sites to build them up also. If someone asks for referrals, you can pass them a link with more than one testimonial.

TIP 2: If you sign up for an account with these places, take the time to do it right. Upload relevant pictures, including your logo. Remember - this is part of your BRANDING/MARKETING. Put in contact info AND your website url in the proper places. Put in a good description of your company. Put in a coupon - if they allow such things.

1) http://www.yelp.com
2) http://local.yahoo.com
3) http://www.insiderpages.com
4) http://centralcoast.citysearch.com
5) http://www.trustlink.org (affiliated with BBB)
6) http://www.merchantcircle.com

If you are in the food or travel business there are specific referral sites related to these activities. That way if someone is interested in traveling, he/she can do a search on what there is to do/eat and plan an iternerary - based on the reputation of the business.

Friday, March 27, 2009

Securing XML Web Services - SOAP

I was doing research on securing XML Web Services and came across the following:

http://www.keithelder.net/blog/archive/2007/01/06/Securing-Web-Services-With-Username-and-Password.aspx

I want to see if I put a XML Web service in a folder - secured with folder permissions - and use username/password to get the web service... that would be the most scalable solution for me... Since I would like to use this secure some user-specific data.
-------------------

Ok - for speed and simplicity I just did the following:
1) Made username and password properties passed into the web service
2) Used SSL to connect to protect the web service.

It was simple and easy to use... pulled data specific to a user... from ASP.Net app into vba app.

Want the code??

Monday, March 16, 2009

ASP.Net AJAX - Update Panels

Update Panels are COOL!

They have some quirks - but if used properly, they can really speed up a web app. (Had trouble using them with file uploads... but all else was fine.) I have been working on building some advanced lead-generation/management tools into my CMS - mostly using AJAX modals, tabs etc.

I have found that those forms with several grids and more than 3 tabs tend to take a few seconds to redraw - using a regular postback. However, if I use an Ajax update panel - only the data in that update panel is redrawn... saving LOTS of time for the update.

I still use regular postbacks - especially if if the update impacts several tabs, or if using file uploads. However, in most cases this is not needed...

FILE upload in Update Panel?
I normally don't bother... But if needed, refer to this:
http://geekswithblogs.net/ranganh/archive/2008/04/01/file-upload-in-updatepanel-asp.net-ajax.aspx

----------------------

One critical thing to consider with update panels - whether to set
UpdateMode="conditional" or "always".

Set to "conditional" if:
This update panel is not being affected by other update panels.

Set to "always" if:
This update panel data is being affected by updates in other update panels. This slows down the display/postback of all update panels with this... but can be very handy. Only do if necessary.