Tuesday, November 30, 2004

Netscape to merge Firefox and IE

This sounds like it could be a very good browser. Could please both those that want ActiveX support and a standards compliant browser. Although these may be mutually exclusive (as the browser will give a choice between using Netscape rendering (Gecko) or Internet Explorer rendering (Trident)).

BetaNews Article | CNet News Article | MozillaZine News Article | Screenshots

Edit: IE rendering engine code name, MozillaZine articles

Monday, November 29, 2004

Basic Excel Spreadsheet Generation (ASP/ASP.NET)

The 'correct' way to generate Excel spreadsheets is through the use of Office Web Components. However, due to the licensing (see MSKB Article) you cannot use them on a public internet site (as a client license for Office is needed for each user retrieving the document).

However, this can be overcome due to the fact that Excel recognises HTML code. You can therefore output HTML that can be opened in Excel:

First of all, set the content type and response header to make the browser handle it as an Excel spreadsheet.

ASP VBScript:

<%@Language="VBScript"%>
<%
	Response.ContentType="application/vnd.ms-excel"
	Response.AddHeader "content-disposition", "attachment; filename=ExcelFileName"
%>

ASP JScript:

<%@Language="JScript"%>
<%
	Response.ContentType="application/vnd.ms-excel";
	Response.AddHeader("content-disposition", "attachment; filename=ExcelFileName");
%>

ASP.NET VB

<%@ Page Language="VB" %>
<script runat="server">
	Sub Page_Load (Sender As Object, E As EventArgs)
		Response.ContentType="application/vnd.ms-excel"
		Response.AddHeader("content-disposition", "attachment; filename=ExcelFileName")
	End Sub
</script>

ASP.NET C#

<%@ Page Language="C#" %>
<script runat="server">
	void Page_Load(Object Sender, EventArgs E)
	{
		Response.ContentType="application/vnd.ms-excel";
		Response.AddHeader("content-disposition", "attachment; filename=ExcelFileName");
	}
</script>

Start the html document and set the summary details (i.e. the information you see when you view the document properties: File - Properties in Excel). xmlns:o and xmlns:x are required for the summary information to be recognised by Excel. &#13;&#10; represents a line break (only valid in o:Description)

<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel">
<head>
<title>Title</title>
<!--[if gte mso 9]><xml>
 <o:DocumentProperties>
  <o:Subject>Subject</o:Subject>
  <o:Author>Author</o:Author>
  <o:Keywords>Keyword1, Keyword 2</o:Keywords>
  <o:Description>Comment Line 1&#13;&#10;Comment Line 2</o:Description>
  <o:Category>Category</o:Category>
  <o:Manager>Manager Name</o:Manager>
  <o:Company>Company Name</o:Company>
</o:DocumentProperties>
</xml><![endif]-->

You can also set the name of the worksheet (this code is also required if you want to see the grid lines in the sheet) and also protect the contents by setting x:ProtectContents to True (i.e. you will have to unprotect the sheet (Tools - Protection - Unprotect Sheet) before you can edit):

<!--[if gte mso 9]><xml>
 <x:ExcelWorkbook>
  <x:ExcelWorksheets>
   <x:ExcelWorksheet>
    <x:Name>Worksheet Name</x:Name>
    <x:WorksheetOptions>
     <x:ProtectContents>False</x:ProtectContents>
    </x:WorksheetOptions>
   </x:ExcelWorksheet>
  </x:ExcelWorksheets>
 </x:ExcelWorkbook>
</xml><![endif]--> 

Next add the CSS (this is important as you want line breaks to be part of the same cell, otherwise the text after the line break will go on a new row):

<style>
<!--
 br {mso-data-placement:same-cell;}
-->
</style>

Close the head tag and then output the table (static, or done dynamically using repeater (i.e. loop through recordset object in ASP, or bind to DataTable in ASP.NET)):

</head>
<body>
	<table border="1">
		<tr><th>Head 1</th><th>Head 2</th></tr>
		<tr><td>Data 1</td><td>Data 2</td></tr>
		<tr><td>Data 3<br>Should be<br>In same cell</td><td>Data 4</td></tr>
	</table>
</body>
</html>

Tuesday, November 23, 2004

Find As You Type in Firefox

Find As You Type is one of the most useful features of Firefox. This article: Get the Most Out of Firefox: Cut Through Pages With Find As You Type provides an example of how to use it. Very useful for pages with lots of text or links (like in the example shown).

User Agent Switcher Extension

The User Agent Switcher extension for Firefox has been updated. This is useful on some sites which check to see if you are using Internet Explorer, and if not, block you from using the site. You then use this to make the site think you are using IE and thus give you access.

Web Developer Extension

A new version of the Web Developer Extension for Firefox is available for download. Lots of new features in this version.

Thursday, November 18, 2004

Portable Firefox / Thunderbird

There are portable versions (unofficial packages) of the Firefox browser and Thunderbird email client available. Useful for running your favourite browser/email client on a removable drive (like a USB pen drive). I wonder if there will be official versions (i.e. released by Mozilla) in the future, rather than by a third party (which may not be updated in the future, but probably will)?

Sunday, November 14, 2004

British Firefox, Extensions Mirror

There is a download for Firefox for those users in the UK (rather than the default US English Version). It can be downloaded from: http://download.mozilla.org/?product=firefox&os=win&lang=en-GB. Found via: http://www.mozilla.org/products/firefox/all.html. You can also set your homepage to Google UK, with Firefox branding: http://www.google.co.uk/firefox?client=firefox-a&rls=org.mozilla:en-GB:official

As well as the official extensions site (https://update.mozilla.org/extensions/?application=firefox), there is also a site with many more extensions listed and available for download: http://www.extensionsmirror.nl/index.php?showforum=2

You will have to add www.extensionsmirror.nl to the list of sites that are allowed to install software. To do so, find an extension you want (i.e. ConQuery), click Install then click Edit Options in the notification bar and then click Allow, OK. Click Install again and the extension will install. You will not have to do this for any additional extensions on the site. As always, exit (via File - Exit, not the cross in the top right) then reopen the browser to use the extension.

Tuesday, November 09, 2004

Firefox 1.0

Firefox 1.0 is finally out. Is this the start of the new web, will it take 10% market share and will Microsoft take notice and update Internet Explorer (not just for Longhorn)? Only time will tell.

Monday, November 08, 2004

DHTML Calendar, WYSIWYG Editing in your Web Browser

A very useful DHTML calendar that can be in a popup window or appear near a button/link that you click. Appearance can be changed via CSS, and you can even navigate the calendar using the keyboard.

HTMLArea is also a very good tool as it allows you to do rich text editing within the browser (Internet Explorer and Firefox/Mozilla Browser). It relies on the browsers built in capabilities. There is also a plugin that generates standards compliant XHTML/CSS called XStandard. It generates compliant, accessible code without resorting to heavy use of JavaScript to clean up the code generated by Internet Explorer's built in editor (which is what HTMLArea is based on for IE).

Wednesday, November 03, 2004

Set Form Enctype (ASP.NET)

This UserControl sets the EncType of the server side form on an ASP.NET page. Useful if you have another UserControl that uploads a file, as it prevents the need to change the parent page EncType (to "multipart/form-data").

Code:

<%@ Control Language="C#" %>
<script runat="server">
public string EncType = "";

void Page_Load(object sender, EventArgs e)
{
	SetEncType(EncType);
}

protected void SetEncType(string EncType)
{
	// continue if enctype is valid
	if(EncType=="text/plain" || EncType=="multipart/form-data" || EncType=="application/x-www-form-urlencoded") {
		Control container = this.Parent;
		while( container.GetType() != typeof(UserControl) && container.GetType() != typeof(HtmlForm) && container.GetType() != typeof(Page) ) {
			container = container.Parent;
		}
		HtmlForm form = container as HtmlForm;
		if ( form != null) {
			form.Enctype = EncType;
		}
	}
}
</script>

Example use:

Register tag: <%@ Register TagPrefix="Form" TagName="EncType" Src="formenc.ascx" %>. Add at start of UserControl page: <Form:EncType EncType="multipart/form-data" runat="server" />

Monday, November 01, 2004

A9 Toolbar

You can now search A9.com using the A9 Toolbar for Firefox. Quite a good search engine (searches books and images as well as web pages). If registered with Amazon.com (or co.uk and I assume other country specific Amazon sites) you get advanced features (bookmarks, diary, search history).