Wednesday, December 15, 2004

VS.NET: Clean Web Form Templates

If your a web site designer/developer like I am, you know that VisualStudio.NET 2003 is great for coding a nightmare for design! One of the problems (and there are many) is the default web form template. When you add a new ASPX web form to a project, you get all sorts of proprietary META tags and the like. Most of these tags are either worthless to a designer or just allow VS.NET to further mess-up your HTML page.

For a very good article on this, reference Milan Negovan's article, "Remastering Web Form Templates". His article points-out many of the frustrations of the VS.NET web form designer, and provides a link to a tool he created that can help you generate clean web form templates.

However, I find that going to his web site to use his tool wasn't likely going to happen (I'm too lazy!)... I wanted to know if I could modify the default VS.NET template so it always creates exactly what I want. I found the default ASPX web form template (VB) here:

C:\Program Files\Microsoft Visual Studio .NET 2003\Vb7\VBWizards\WebForm\Templates\1033\WebForm.aspx

I removed the default VS.NET specific meta tags and added my own, such as a copyright, author, etc. Need some help coming-up with the default META tags? Try AnyBrowser.com.

Tuesday, December 14, 2004

Sometimes Post-Back Isn't an Option

When switching from ASP to ASP.NET years ago, it took me a long time to get adapted to posting-back a form. To this day, I still find reasons why using post-back is more of a pain than a help, such as adding a search text box to every page in a web site... a problem I'm having with my current project.

To solve this problem, I did a little research and found-out a nifty way to post form information from one ASP.NET page to another:
Server.Transfer("WebPostAway2.aspx", true)
Although using Server.Transfer isn't new to me, I never knew about the second parameter, preserveForm! Setting preserveForm to True keeps all the post data intact as it's passed to the next ASPX page.

Friday, December 10, 2004

No More Ugly Submit Buttons

Depending on which browser and operating system you are using, the submit buttons on a web form can either look really pretty or really ugly... the default is really ugly (gray blocks with black text.) Granted, using CSS on a button can pretty-them-up somewhat, but this CSS trick is the best by far!

[CSS]

input.btn{
color:#050;
font-family:'trebuchet ms',helvetica,sans-serif;
font-size:84%;
font-weight:bold;
background-color:#fed;
border:1px solid;
border-top-color:#696;
border-left-color:#696;
border-right-color:#363;
border-bottom-color:#363;
filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=0,StartColorStr='#ffffffff',EndColorStr='#ffeeddaa');}
For details on the original article: WebReference.com: Stylish Buttons

Thursday, December 09, 2004

Windows XP: Get That Crap Out of My System Tray!

Why is it that every software manufacturer feels that their software must:
  • Install a shortcut in 1,700 places on my PC?
  • Run at startup?
  • Create a useless app that runs in my PC's system tray with no option to disable this feature?

As of recently, I was able to speed-up the boot-up time of PC a little by removing many of the links to the programs that thought they needed to run at start-up (and I didn't.) The hard way to do this is to go to Start > Run > Type in "MSCONFIG" > Startup Tab. From there, you can try and decifer what it is that is running on your PC when it boots-up. If you find some programs you think should not be run at startup, you can use the RegEdit tool to remove the entry in the Registry that starts that app.

However, there is an easier way (of course!) System Internals offers a free application called AutoRuns that is really easy to use, and makes removing unwanted start-up apps a breeze! Once the app runs, it lists all the applications that choose to run on start-up, and shows you who manufacturered the application. By right-clicking on the application, you can delete it or go directly to the spot in the Registry where the reference is located.

Warning: It is quite easy to remove programs your PC actually needs at start-up using either of the above methods! Do not even bother using this tool if you aren't a geek! ;)

Wednesday, December 08, 2004

Windows XP: No More Error Reporting!

For the longest time, I thought that those stupid "Do you want to report this error to Microsoft?" pop-up that showed-up after a program crashes were just something I had to live with... NOT!

To turn Error Reporting "Off":
  1. Right-click on the My Computer icon
  2. Select Properties from the menu
  3. Select the Advanced tab
  4. Click the Error Reporting button
  5. Select the Disable Error Reporting radio button
  6. Click OK and you're a happy-camper!

Tuesday, November 23, 2004

How to Disable IE AutoComplete in HTML Forms

Using Microsoft's Internet Explorer AutoComplete feature may save a lot of time on your personal PC or in an Intranet environment, but it can be a dangerous thing when creating web applications that involve sensative information. For example, if a user accesses your application at a web cafe and has AutoComplete turned "on", then walks away from the computer, the next person has free reign.

Fortunately, there is a simple solution to this problem. Just add the AutoComplete attribute to either the <form> tag or the <input> tag:
<form AUTOCOMPLETE="OFF">

... or...
<input type="text" name="name" AUTOCOMPLETE="OFF">


Sometimes the AutoComplete feature is a good thing, however, like in an Intranet environment where a user may have to enter the same information over and over. To better control this information as a web developer, the following article gives a good description of what you can do:

Developer's Dex: AutoComplete Feature of Internet Explorer

Tuesday, November 16, 2004

User.Config File

For those of you who wish there was a nice way to modify a web site project and not have to worry about changing workstation specific configuration settings in the web.config file (like datbase connection strings, etc.) you can use the file="user.config" attribute of the <appsettings> tag.

You can do the following in web.config:
<configuration>

<appsettings file="user.config">
<add key="Key" value="Value" >
</appsettings>
</configuration>
Then, create a file called user.config in the same folder as web.config, and paste the following code. Notice that there is no <configuration> tag:
<appsettings>

<add key="Key" value="Override value" >
<appsettings>

Do not add the user.config file to the project. If there is no user.config in the same folder, then the web.config settings are used.

MSDN:Web Projects Source Control Integration In VisualStudioNET


Thursday, November 11, 2004

Yahoo! Mail POP Access... for Free!

Ok, so I'm a cheap-skate... I admit it! I hate the idea of forking over $20 just so I can have access to my free Yahoo! mail account via Outlook. Well, thanks to a free application called YahooPops, you can POP your Yahoo! email at no cost to you.

Once you download and install the app, configuring Outlook 2003 is as follows:
  1. Select Tools -> Email accounts from the main menu
  2. Select Add a new email account and click o­n Next
  3. Select POP3 as the Server Type. Click Next
  4. Enter your username and full Yahoo! email address under 'User Information'
  5. Enter your Yahoo! Login id and password under 'Logon Information'
  6. Enter 'localhost' as your Incoming mail server
  7. Enter localhost as the SMTP server as your outgoing mail server
  8. Click o­n the More Settings button and select the Advanced tab
  9. Increase the Server Timeout to 'Long' (10 minutes)
  10. Select the Outgoing Server tab
  11. Enable "My outgoing server (SMTP) requires authentication". Select "Log o­n using" and enter your Yahoo Mail address as the username and your Yahoo Mail password as the password.
  12. Click Ok to close the More Settings dialog
  13. Click Next and then Finish

Can't Find get_asp_ver.aspx?

After adding an automatically error reporting feature to the global.asax file in my project, I started getting emails when I opened the project in VisualStudio.NET 2003 stating that the get_asp_ver.aspx file could not be found. This error only occurred on this one project, but none-the-less, it is apparently a problem others have had.

Microsoft suggests making a bogus get_asp_ver.aspx file, but many use this code in their global.asax.vb file which makes more sense to me than having a file in your site that does nothing:
Sub Application_BeginRequest(ByVal sender As Object, _

ByVal e As EventArgs)
Dim url As String = CStr(Request.ServerVariables("URL"))
If url.ToLower().IndexOf("get_aspx_ver.aspx") >= 0 Then
Response.End()
End If
End Sub

The ASPNET_regiis Tool

Ever have a problem with an ASP.NET site that didn't seem to have any reasonable explination? For example, I had an issue with a client where the client-side validation was not working on any of their web forms. The fix? Use the ASPNET_regiis tool to put a fresh copy of just the .NET Framework JavaScript for web validation (WebUIValidation.js) onto the server.

ASP.NET IIS Registration Tool

Debugging JavaScript

I'm not an expert JavaScript programming, but I do know enough to get-by, and I do know that it's insanely tedious to debug! Well, I should say it used-to be tedious, thanks to VisualStudio.NET and MSIE 6. To debug JavaScript, follow these steps:
  1. Make sure script debugging is not disabled in Internet Explorer.

    In MSIE: Tools > Internet Options... > Advanced > Uncheck "Disable Script Debugging (Internet Explorer)"

  2. Navigate to the page you wish to debug. The page doesn't have to be part of any VS.NET project, you can debug any web page you'd like.

  3. Open VS.NET. If you already have a ASP.NET project you are working on, open it. Otherwise, just open a new project which you will delete later.

  4. Start the VS.NET debugger (F5 or Debug > Start)

  5. In VS.NET, navigate to the Running Documents menu.

    In VS.NET: Debug > Windows > Running Documents

    The Running Documents menu should appear on the right. If the page you are debugging belongs to the project you are working on and is the page that is currently being debugged, it should already show-up in the running document list under "Microsoft Internet Explorer."

    If not, you have to attach to the MSIE process of the window you would like to work with. To do that:

    In VS.NET: Debug > Processes...

    Find the instance if iexplorer.exe that relates to the page you wish to debug. If there are multiple instance, look at the Title column to find the page. Select the page and click the Attach... button, then Close. You should now see the selected web page show-up in the Running Documents menu.

  6. Double click on the web page you wish to debug in the Running Documents menu. This should open up the HTML of the page in a new window. Now set a break-point on the line of code you which to start debugging, and away you go!