Saturday, April 22, 2006

That's it for now

I've decided to take a break from blogging and I won't be updating this blog anytime in near future, I've been blogging for nearly 2 years now and it had mostly become a part of my life where I could write about my life, my thoughts and some technical things that I've learnt along the way. I know it's going to be a little difficult having to live without being able to share my thoughts but as they say all good things must come to an end.
Thanks to everyone who visited this blog and I hope that you left this blog feeling more enlightened than less.

Take care,
Sachin

Friday, April 14, 2006

Mutually exclusive RadioButton in INamingContainer redux

Some time back I'd posted about the bug with mutually excusive radiobuttons in repeater controls for VB.Net and hacking my way around the bug. Well, since some time I'd been thinking of posting how I actually did it for the benefit of others and today is the day! As they say, better late than never. Here's the CustomRadioButton.vb class:



Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Globalization
Imports System.Collections.Specialized

Public Class CustomRadioButtonControl
Inherits WebControl
Implements IPostBackDataHandler

Shared Sub New()
CustomRadioButtonControl.EventCheckedChanged = New Object
End Sub

Public Sub New()
MyBase.New(HtmlTextWriterTag.Input)
End Sub
#Region "Properties"

Public Event CheckedChanged As EventHandler
Private Shared ReadOnly EventCheckedChanged As Object

Private ReadOnly Property UniqueGroupName() As String
Get
Dim grpName As String = Me.GroupName
Dim unqId As String = Me.UniqueID
Dim num As Integer = unqId.LastIndexOf(":"c)
If (num >= 0) Then
grpName = (unqId.Substring(0, (num + 1)) & grpName)
End If
Return grpName
End Get
End Property


Public Overridable Property GroupName() As String
Get
Dim grpName As String = CType(Me.ViewState.Item("GroupName"), String)
If (Not grpName Is Nothing) Then
Return grpName
End If
Return String.Empty
End Get
Set(ByVal value As String)
Me.ViewState.Item("GroupName") = value
End Set
End Property

Public Overridable Property Checked() As Boolean
Get
Dim grpChecked As Object = Me.ViewState.Item("Checked")
If (Not grpChecked Is Nothing) Then
Return CType(grpChecked, Boolean)
End If
Return False
End Get
Set(ByVal value As Boolean)
Me.ViewState.Item("Checked") = value
End Set
End Property

Private ReadOnly Property SaveCheckedViewState() As Boolean
Get
If ((Not MyBase.Events.Item(Me.EventCheckedChanged) Is Nothing) OrElse Not Me.Enabled) Then
Return True
End If
Dim baseType As Type = MyBase.GetType
If ((Not baseType Is GetType(CheckBox)) AndAlso (Not baseType Is GetType(RadioButton))) Then
Return True
End If
Return False
End Get
End Property

Public Overridable Property AutoPostBack() As Boolean
Get
Dim doAutoPostBack As Object = Me.ViewState.Item("AutoPostBack")
If (Not doAutoPostBack Is Nothing) Then
Return CType(doAutoPostBack, Boolean)
End If
Return False
End Get
Set(ByVal value As Boolean)
Me.ViewState.Item("AutoPostBack") = value
End Set
End Property


Private ReadOnly Property Value() As String
Get
Dim val As String = Attributes("value")
If (val Is Nothing) Then
val = UniqueID
End If
Return val
End Get
End Property

Public Overridable Property [Text]() As String
Get
Dim grpText As String = CType(Me.ViewState.Item("Text"), String)
If (Not grpText Is Nothing) Then
Return grpText
End If
Return String.Empty
End Get
Set(ByVal value As String)
Me.ViewState.Item("Text") = value
End Set
End Property

Public Overridable Property TextAlign() As TextAlign
Get
Dim align As Object = Me.ViewState.Item("TextAlign")
If (Not align Is Nothing) Then
Return CType(align, TextAlign)
End If
Return TextAlign.Right
End Get
Set(ByVal value As TextAlign)
If ((value < TextAlign.Left) OrElse (value > TextAlign.Right)) Then
Throw New ArgumentOutOfRangeException("value")
End If
Me.ViewState.Item("TextAlign") = value
End Set
End Property

#End Region

Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)
If (Not Me.Page Is Nothing) Then
Me.Page.VerifyRenderingInServerForm(Me)
End If
Dim doRender As Boolean = False

If Not Me.Enabled Then
writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled")
doRender = True
End If
Dim tip As String = Me.ToolTip
If (tip.Length > 0) Then
writer.AddAttribute(HtmlTextWriterAttribute.Title, tip)
doRender = True
End If
Dim _onClick As String = Nothing
Dim _attributes As AttributeCollection = MyBase.Attributes
Dim _value As String = _attributes.Item("value")
If (Not _value Is Nothing) Then
_attributes.Remove("value")
End If
_onClick = _attributes.Item("onclick")
If (Not _onClick Is Nothing) Then
_attributes.Remove("onclick")
End If
If (_attributes.Count <> 0) Then
_attributes.AddAttributes(writer)
doRender = True
End If
If (Not _value Is Nothing) Then
_attributes.Item("value") = _value
End If
If doRender Then
writer.RenderBeginTag(HtmlTextWriterTag.Span)
End If
Dim _text As String = Me.Text
Dim _clientId As String = Me.ClientID
If (_text.Length <> 0) Then
If (Me.TextAlign = TextAlign.Left) Then
Me.RenderLabel(writer, _text, _clientId)
Me.RenderInputTag(writer, _clientId, _onClick)
Else
Me.RenderInputTag(writer, _clientId, _onClick)
Me.RenderLabel(writer, _text, _clientId)
End If
Else
Me.RenderInputTag(writer, _clientId, _onClick)
End If
If doRender Then
writer.RenderEndTag()
End If

End Sub

Private Sub RenderLabel(ByVal writer As HtmlTextWriter, ByVal [text] As String, ByVal clientID As String)
writer.AddAttribute(HtmlTextWriterAttribute.For, clientID)
writer.RenderBeginTag(HtmlTextWriterTag.Label)
writer.Write(text)
writer.RenderEndTag()
End Sub


#Region "Rendering"

Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
If ((Not Me.Page Is Nothing) AndAlso Me.Enabled) Then
Me.Page.RegisterRequiresPostBack(Me)
End If
If Not Me.SaveCheckedViewState Then
Me.ViewState.SetItemDirty("Checked", False)
End If

If (((Not Me.Page Is Nothing) AndAlso Not Me.Checked) AndAlso Me.Enabled) Then
Me.Page.RegisterRequiresPostBack(Me)
End If
If (Me.GroupName.Length = 0) Then
Me.GroupName = Me.UniqueID
End If
End Sub

Friend Sub RenderInputTag(ByVal writer As HtmlTextWriter, ByVal clientID As String, ByVal onClick As String)
writer.AddAttribute(HtmlTextWriterAttribute.Id, clientID)
writer.AddAttribute(HtmlTextWriterAttribute.Type, "radio")
writer.AddAttribute(HtmlTextWriterAttribute.Name, Me.GroupName)
writer.AddAttribute(HtmlTextWriterAttribute.Value, Me.Value)
If Me.Checked Then
writer.AddAttribute(HtmlTextWriterAttribute.Checked, "checked")
End If
If Not Me.Enabled Then
writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled")
End If
If Me.AutoPostBack Then
If (Not onClick Is Nothing) Then
onClick = (onClick & Me.Page.GetPostBackClientEvent(Me, ""))
Else
onClick = Me.Page.GetPostBackClientEvent(Me, "")
End If
writer.AddAttribute(HtmlTextWriterAttribute.Onclick, onClick)
writer.AddAttribute("language", "javascript")
Else
If (Not onClick Is Nothing) Then
writer.AddAttribute(HtmlTextWriterAttribute.Onclick, onClick)
End If
End If
If (Me.AccessKey.Length > 0) Then
writer.AddAttribute(HtmlTextWriterAttribute.Accesskey, Me.AccessKey)
End If
If (Me.TabIndex <> 0) Then
writer.AddAttribute(HtmlTextWriterAttribute.Tabindex, Me.TabIndex.ToString(NumberFormatInfo.InvariantInfo))
End If
writer.RenderBeginTag(HtmlTextWriterTag.Input)
writer.RenderEndTag()
End Sub

Protected Overridable Sub OnCheckedChanged(ByVal e As EventArgs)
Dim handler As EventHandler = CType(MyBase.Events.Item(CustomRadioButtonControl.EventCheckedChanged), EventHandler)
If (Not handler Is Nothing) Then
handler.Invoke(Me, e)
End If
End Sub

#End Region

#Region "IPostBackDataHandler Members"

Public Overridable Shadows Sub RaisePostDataChangedEvent() Implements IPostBackDataHandler.RaisePostDataChangedEvent
OnCheckedChanged(EventArgs.Empty)
End Sub

Private Function LoadPostData(ByVal postDataKey As String, ByVal postCollection As NameValueCollection) As Boolean Implements IPostBackDataHandler.LoadPostData
Dim grpName As String = postCollection.Item(Me.GroupName)
Dim flag As Boolean = False
If ((Not grpName Is Nothing) AndAlso grpName.Equals(Me.Value)) Then
If Not Me.Checked Then
Me.Checked = True
flag = True
End If
Return flag
End If
If Me.Checked Then
Me.Checked = False
End If
Return flag
End Function

#End Region
End Class

Embedding the control in your aspx page is simple, just register the tag prefix using:
<%@ Register TagPrefix="ucl" Namespace="XYZ.Website" Assembly="XYZ.Website"%>

PS: forget about how to showing the code snippet to embed it aspx page, blogger really sucks when you want to include html tags as is within your post. Basically you set the groupName property and the id property!

Saturday, April 08, 2006

Only yesterday

Recently, I received a mail from dialpad that my account would be cancelled as they are now part of Yahoo!. I used to use dialpad extensively 2 years back with an average of 2 hours per day coupled with like 1 hour on yahoo voice chat. I sure miss those days and it seems like as if it all happened only yesterday, either my life has stagnated since then or somethings are just impossible to forget about.

Thursday, April 06, 2006

Comment of the day

Today Harvinder Pal Singh (aka Kishi) from MS posted his first blog entry on Port25 (MS Linux lab), the post was nothing great but the comment#2 by "Santa Singh" made me laugh & remember the good ol' Santa & Banta jokes :)
"re: Welcome to Kishi's Korner
Thursday, April 06, 2006 8:48 AM by Santa Singh
Paaji,

Oye....welcome to the netta!"

Wednesday, April 05, 2006

Anonymous blogging in corporate world?

The title of the post might sound paradoxical & I just want to touch on the same topic, should you be anonymously blogging about your job/company? NO! don't even think about it, if your company encourages blogging then blog publicly i.e. let your PR dept. know, or don't blog anything specific related to your company (remember a blog is just another website waiting to be discovered). I, for instance blog anonymously, that is no where on my profile or on my blogs you would find any explicity reference to the company I work for, the reason being most of the times I blog about my personal life and how much it sucks with some technical posts thrown in between, and I don't want my private life being discussed at work! You would never find any post on my blog which says how much my work sucks or how I waste away my time in the office by pretending that I'm working (PR dept.: if by any chance you're reading this post then don't take it literally, I am the most sincerest employee you could have ever imagined to find..hee hee). Secondly, there're are very few close friends/family members who even know that I blog (different story if they stumbled on it) and if you're one of those "acquaintances" who just stumbled on it, I would very much appreciate if you keep it to yourself.

Tuesday, April 04, 2006

Latest iTunes additions

This weekend I downloaded few songs from iTunes, here they are with my ratings:
1) Glasses by Slizzy Bob (6/10)
2) Since I don't Have You by Guns n' Roses from the album The Spaghetti Incident (6/10)
3) La Luna by Belinda Carlisle from Runaway Horses (7/10)
4) Heartbeat by Wham! from Make it Big (6.5/10)
5) Skies the limit by Fleetwood Mac from Behind the Mask (7/10)
6) The World I know by Collective Soul from The Absolute Hits (7/10)
7) Afterglow by INXS from Switch (9/10)

All these songs I have listened to long before apart from the exception of Afterglow which just couple of days back I first listened on the MusicMatch Jukebox radio (I was playing Cyndi Lauper and "related artists").

Monday, April 03, 2006

Afterglow

I've absolutely fallen in love with "Afterglow" by INXS from their album Switch , the lyrics are really profound about dealing with a sense of loss in a postive way and remembering someone forever. I also love the background chanting that is there in the song, it just adds to the profoundness. And yes, I never even felt that it's not Michael Hutchence singing, which by itself speaks of their new found lead singer.
Update: Just finished watching the video on Yahoo! Launch (warning, works only in IE), the video isn't anything great but goes pretty well with the lyrics and the mood of the song.
Touch me and I will follow in your afterglow
Heal me from all this sorrow...

Saturday, April 01, 2006

bloglines down?

Is it just me who's experiencing issues with bloglines or is it universal? For most part of the day, bloglines hasn't shown me any new items at all, when I know for sure almost most have been updated. Oh, in case you're wondering what kinda feeds I subscribe to, you can view my blogroll here.

Moving on...

After a long and hard thought, I've decided to switch my job & I'll be joining KSC (Kuwait Oil Company) starting 15th of this month as a Technical Evangelist. I'll be moving to Ahmadi sometime end of this week subject to availability of tickets on Kuwait Airlines, what I really like about KSC is that they have a very open culture and they've got some real cool geeks working for them like Al Bashar Ul-Hussein, the father of CXA (Componentized Xml Architecture) and others. I got a mail from their HR on the 29th of Feb. and since then had 3 technical, 1 HR and 1 religious interview round (the religious round was more or less to ascertain whether you can survive in a Islamic country or not). My primary responisbility would be to help architecting & building the automation framework, which would automate the entire process of extracting oil from the wells to finally shipping them. Given that the TL on this project is Bashar himself, I am really excited to be part of such a team. Hopefully, my next post would be from Ahmadi itself....kuwait am coming!!

Sake and Sushi time

Today was my first attempt at Sake and Sushi and well I feel both of them are passable! I tried a hot kurosawa and a cold Mu with Salmon sushi on the sides, the Mu for sure reminded me of some sweet coconut water that I used to have once in a while when I was a kid. I'll have a Pinot Grigio over these anytime. Aside, if you haven't tried Ethiopian cuisine and are in vicinty of Washington D.C., you should give Zed's a shot, it's simply worth it.