30 March 2004

Holiday Blue

Danni and I have spent a week holiday at Maldives. One of the most beautiful islands country with jade-like islands, easy access yet well protected coral reef, vast number of colourful fishes.

And now we are back with some suntan, lots of good memories, and some holiday blue.

I will try to sort out some photos and diaries for this.

19 March 2004

Bits and bobs on authoring Web Control

1. Default Tag Prefix.
By defalt VS.NET assign 'cc1'at run time (when the control is dropped to designer canvas). You can assign a different one by modifying AssemblyInfo.cs of the WebControl. Add following lines

...
using System.Web.UI;
...

leads to

[assembly: TagPrefixAttribute("JingyeLuo.IEWebControls", "luo")]


now 'luo' is used instead of 'cc1'

2. Associating custom bitmap with a web control
This will be the bitmap display in the Toolbox for a control
1) Create a 16x16 bitmap of 16 color and set its Build Action to Embedded Resource.
2) Add the ToolboxBitmap to the control class:

[ToolboxBitmap(typeof(JingyeLuo.IEWebControls.ExpandablePanel),"Resources.JingyeLuo.IEWebControls.ExpandablePanel.bmp")
public class ExpandablePanel :
...

I have a bitmap called JingyeLuo.IEWebControls.ExpandablePanel.bmp and located in the folder 'Resources', the name is deliberated -if the bitmap is located at the same place of the control-there is no need for 2nd parameter:

[ToolboxBitmap(typeof(JingyeLuo.IEWebControls.ExpandablePanel))
public class ExpandablePanel :
...

ASP.NET Controls That Take Advantage of the DHTML Object Model – the initiatives

What I want: ASP.NET Web control that takes the advantage of DHTML Object Model.
The rendering should be browser independent. For IE3 and above, it should exploit DHTML with client side scripting, otherwise may require server side scripting. Dino Esposito has an article on this.
Be more specific I want to create two web controls:
1) Expandable DIV. Expand/Collapse that response to Onclick event.
2) Drag-able Table row. Response to onmousedown and onmouseup, enabling a quick table re-ordering. Dave Massy has an article on this.
Other User requirement support VS.NET HTML designer Drag and Drop;

18 March 2004

Using Client-side Script to Focus Controls in ASP.NET

In a web page contains a large number of controls (or virtually anything), it could be quite nasty to find out where were you all about after a postback or on finishing a subroutine. This article suggests a simple way to ‘bookmark’ the interested control by injecting dynamic client-scripting, which sets the focus on page load.

Here is a little sample on the idea. A web page with five buttons, all will do a postback. Focus varied depends on the button been clicked. Extend this idea, we can effectively bookmark anything, e.g. a large table required the use of scroll bar.


<!-- FocusContorl.aspx-->
<%@ Page language="c#" Codebehind="FocusContorl.aspx.cs" AutoEventWireup="false" Inherits="WebSamples.FocusContorl" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 104px; POSITION: absolute; TOP: 96px" runat="server"
Text="Button 1"></asp:Button>
<asp:Button id="Button2" style="Z-INDEX: 102; LEFT: 104px; POSITION: absolute; TOP: 152px" runat="server"
Text="Button 2"></asp:Button>
<asp:Button id="Button3" style="Z-INDEX: 103; LEFT: 104px; POSITION: absolute; TOP: 200px" runat="server"
Text="Button 3"></asp:Button>
<asp:Button id="Button4" style="Z-INDEX: 104; LEFT: 104px; POSITION: absolute; TOP: 248px" runat="server"
Text="Button 4"></asp:Button>
<asp:Button id="ButtonPostBack" style="Z-INDEX: 105; LEFT: 296px; POSITION: absolute; TOP: 328px"
runat="server" Text="PostBack"></asp:Button>
</form>
</body>
</HTML>

//FocusControl.aspx.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace WebSamples
{
///
/// demostrates using dynamic client-script to set focus to a client control after a postback
///

public class FocusContorl : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.Button Button3;
protected System.Web.UI.WebControls.Button ButtonPostBack;
protected System.Web.UI.WebControls.Button Button4;

private void Page_Load(object sender, System.EventArgs e)
{
if (Request["callerControl"]!=null)
{
Label lb = new Label();
lb.Text = Request["callerControl"];
this.Controls.Add(lb);
SetFocusControl(Request["callerControl"]);
}
}

private void SetFocusControl(string controlName)
{
string dynamicScript = string.Format(@"",controlName);
this.RegisterStartupScript("Focus",dynamicScript);
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}

///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Button2.Click += new System.EventHandler(this.Button2_Click);
this.Button3.Click += new System.EventHandler(this.Button3_Click);
this.Button4.Click += new System.EventHandler(this.Button4_Click);
this.ButtonPostBack.Click += new System.EventHandler(this.ButtonPostBack_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void ButtonPostBack_Click(object sender, System.EventArgs e)
{
RedirectPage((Button)sender);
}
private void Button4_Click(object sender, System.EventArgs e)
{
RedirectPage((Button)sender);
}
private void Button3_Click(object sender, System.EventArgs e)
{
RedirectPage((Button)sender);
}
private void Button2_Click(object sender, System.EventArgs e)
{
RedirectPage((Button)sender);
}
private void Button1_Click(object sender, System.EventArgs e)
{
RedirectPage((Button)sender);
}
private void RedirectPage(Control caller)
{
Response.Redirect("http://localhost/WebSamples/FocusContorl.aspx?callerControl="+caller.ClientID);
}
}
}

16 March 2004

new RSS

new Rss, well Atom added, if use SharpReader, it needed to be at least version 0.9.4.1.

DOWN WITH BIG BROTHER

- George Orwell: Nineteen Eighty-Four, Chapter 1

What a penetrative and foresight wisdom.

It is worth to take a snap of what has happened as of March 2004 (that is almost 20 years after what Orwell’s fictitious story happened.

The background: War on Iraq a year on, led by Bush Administration and echoed with Blair ministry, Spain is the only other western European country sending their troops to Iraq.
A chain of terrorism bomb attacks killed 192 commuters and wounded 1500 in morning peak hours in Madrid last Thursday (11/03/2004).
Israel was suffering another round of human bomb attacks

NATO Umbrella Could Keep Spanish Troops in Iraq BRUSSELS (Reuters) - A UN-mandated NATO presence in Iraq could be a face-saving formula for Spain's incoming Socialist prime minister as allies put pressure on him not to withdraw troops from the country, diplomats said Tuesday.

Israel Prepares to Strike Back for Bombing JERUSALEM (Reuters) - Israel's inner cabinet approved major raids into the Gaza Strip and the killing of top militants Tuesday in retaliation for a Palestinian suicide bombing at a strategic port, security sources said.

Suspected Russia Gas Blast Kills 21; 20 Missing MOSCOW (Reuters) - A suspected gas blast flattened part of a large apartment block in northern Russia early on Tuesday, killing at least 21 people, including two children, and trapping about 20 more beneath the rubble.

White House to Kerry: We Want Names
FOX News Bush administration officials on Monday continued to press Kerry to say exactly what international leaders have told the presumed Democratic presidential nominee privately that they back his candidacy to oust President Bush.

London terror attack 'inevitable'
(BBC) The police chief was speaking in central London A terror attack on London is inevitable, Metropolitan Police commissioner Sir John Stevens has said.

Do I have too much time to care about what is going on in the world?

Nikonos workshop

Nikonos workshop looked like a very good supplement to Nikonos Instruction Manual

11 March 2004

Shafting people boosts morale

It is a mind game.
Abuse your co-worker should be in subtle and different ways. To your peer, you should at least gain knowledge advance-or pretend you have-and pose yourself as a master or guru. To your boss, you should be more like a victim of his/her misbehaving. To contractors, do as you like. They are there for some reasons.
And watch your morale index rise.

10 March 2004

Game of the day

Just cann't let go on this game
Warthog Launch. Now level 11.

09 March 2004

Teach Yourself Programming in Ten Years

This reminds me what is the ultimate drive be in this career.
Teach Yourself Programming in Ten Years:

We're not here to do the decent thing

We're not here to do the decent thing, we're here to follow f***ing orders - Captain Miller, Saving Private Ryan

A week now since our .Net project got shelving. People are suffering for their low point. Matt and Gary were mostly not in the office. Lynn, Nick, Paul and myself were in but we are surfing most of the time. Not that many conversation or gossip, just been quiet. I was very quiet.

Tried to focus and do some reading so to take the advantage of the project gap, but it was hard to focus. I seemed more productive in the 20 minutes train commuting than the rest of the day. Regular monitoring Ebay for the diving gadgets as my partner and myself are going to Maldives in two weeks time.

Watched Save Private Ryan probably for the third time last Sunday. It still strikes me for the bloodiness, cruelness of war and breadth of humanity.

An elite team set off to search Private Ryan and it was the high command’s order to bring him home safely as he lost three brothers in the war. It is a difficult order. And people question the rationale of risk more people’s lives for this. To the soldiers in the team, James Ryan is just a name, while Caparzo is a brother. Without looking at the bigger map, it is hard to accept and act on it positively.

This brought me to think of the current situation of developers, management team as command officers and the company as about to change hand. You know, like selling off your car 2nd hand. You probably don’t want to add satellite navigation system but give it a full service and polish it a bit.

I told Danni I am going to cheer up and be more positive from this week. For whatever project I will be assigned to, most likely a big fix to legacy system- dark age of vi and C on Unix, I will be happily get on with it.

Like stuck in a missing boat, we don’t know where captain is going take us to. It didn’t look promising and probably it never will. And it is beyond us to influence the decision-making.

There are two things we can do if immediately work out is not an option:
1) Positively do whatever we are told and hope we will shored sometime although it may still sink by the end.
2) Passively do it with mourning until it sinks or lucky shored.

Regardless the result, I will definitely be more happy by enjoying my work.

08 March 2004

back again

Haven’t been blogged for a really long time, feel like a deep dive. This is partly due to the then on-going project had drained most of my time, partly I was enjoyed it too much to share.
Now get back to where I was been left off since last time I blogged during a project gap.
Lots of things happened in this 3-4 months time:
Got a sparking .NET Windows Form project to work on with a group of really enthusiastic people;
Brought our first house and applied eXtreme Programming methodology on DIY deco to guarantee a delivery;
the employer is up for sale (still on going);
4 weeks to live pilot and the .NET project got caned due to business interest changed--yet another one;

There are lots of thing I shall write down before they fading away. To some people, blog is a convoy to share knowledge; to some it is a place to show off; to many others, like me, it is a memory dump and natural healing at low-point.

I shall pick up my old friend for now, until another challenge arrives and I will be doing deep dive again.