The Wight Stuff

Thursday, 22 March 2007

Using body onload with ASP.net 2.0 MasterPages

I was recently scratching my head trying to figure out how to use Master Pages with .net 2.0 and Visual Web Developer. There didn't seem to be an out-of-the-box way to do this, so this is how I did it.

MasterPage.master


...

<head>

  <asp:ContentPlaceHolder runat="server" id="Headers">

  </asp:ContentPlaceHolder>
  <script language=javascript>
    function mp_onload()
    {
      if(window.body_onload != null)
      window.body_onload();
    }
  </script>
</head>
<body onload="mp_onload();">

...



This way, if i have a content page that may require an onload event then I just create a function called body_onload in Headers content area of each page that requires it.

Default.aspx


<asp:Content ID="Content2" ContentPlaceHolderID="Headers" Runat="Server">
  <script language="javascript">
    function body_onload()
    {
      //do something
    }
  </script>
</asp:Content>

Wednesday, 21 March 2007

Sulphur Hexafluoride



I just gotta get myself some of this stuff. Wonder what would happen if you stick some water in it and a mini fogger?

Apparently, (well wikipedia say so),
Because the gas has a high density (six times more dense than air), it can be poured into open containers, like beakers and fishtanks. Moreover, light objects (e.g. made out of light wood or aluminium foil) can float on the gas.

Nice

Labels: ,