Bing vs Yahoo

If the current statistics continue till the end of this year, Microsoft would have a good news, ie., Bing overtakes yahoo search by the early next year.

ASP.NET Page Life Cycle

Most of the ASP.NET developers ignore the page life cycle. They dig only when it is a trouble shooting situation or fixing a bug or as part of a rescue mission. For all those developers, there is an article that explains in detail about ASP.NET v4 page life cycle. Click here to read more in detail.

But a picture is worth more than 1000 words. So is this. Isn’t it??

ASPNET_LifeCycleOverview

CheckBoxList validation

Within our current project, we faced a requirement such that there are multiple checkboxes and the user is required to select any one of them (at least one of them). So as there are multiple checkboxes, decided to go with CheckBoxList control. Now the problem is that, we need to show a error message if the user is not selected any one of them. The problem also extends not just there, but the display text should be culture specific.

So the story started long after I’ve written this post. But editing this entire post due to a simple non supportive feature by IE. I’ll come to that point later in this post, let me first detail the requirement and solution. There is one more solution for this unsupported error. Please read thru the post.

For all the client side validations, it is widely known that validation controls supported by ASP.NET framework are popularly used. But these controls can’t handle the CheckBoxList. Hence the following solution.

Step 1: Place your CheckBoxList control in a separate div as shown below. Observe that the text for these controls are populated from database depending upon the user culture

<div id="cblItems1">
    <asp:CheckBoxList ID="cblOptions" runat="server">
        <asp:ListItem Text="<%$Resources:CommonFormFields, Repair%>"></asp:ListItem>
        <asp:ListItem Text="<%$Resources:CommonFormFields, Calibration%>"></asp:ListItem>
        <asp:ListItem Text="<%$Resources:CommonFormFields, RepairCalibration%>"></asp:ListItem>
        <asp:ListItem Text="<%$Resources:CommonFormFields, OnlineService%>"></asp:ListItem>
    </asp:CheckBoxList>
</div>

Step 2: Use ASP:Lable and get the error message while loading and place in a separate div and hide this div by default as mentioned below. Please note the div ID as cblError1 and the style is set to hidden by default

<div id="cblError1" style="visibility: hidden">
    <asp:Label ID="lblReq1" runat="server" Text="<%$Resources:CommonFormFields, SelectAny%>"></asp:Label>
    </div>

Step 3: Write a JScript function that reads all the client side rendered elements as input objects and checks whether any of them are checked or not. Code explains more in detail

function CheckListValidation(cblItm, errDiv)
{
    var tDiv = document.getElementById(cblItm);
    var chkitems = tDiv.childNodes[1];
    var chkitm = chkitems.getElementsByTagName("input");
    for (var i = 0; i < chkitm.length; i++) 
    {
        if (chkitm[i].checked) 
        {                    
                return true;
        }
    }
    document.getElementById(errDiv).style.visibility = 'visible';
    return false;
}

Step 4: Now it is the turn of invoking this function from the button click. Every button is having a method called as “OnClientClick” along with Click. Invoke this function from that method as mentioned below

<asp:Button ID="btnAddMore" runat="server" Text="Add More" 
OnClientClick="return CheckListValidation('cbOptions','cblError1');"
    OnClick="btnAddMore_Click" />

Step 5: All setup and the code is running fine. But there is a problem with this code while running in IE. IE 6 and above doesn’t support the getElementsByTag

var vTe = document.getElementsByTagName(..);

There is a long story for this. Let me post one more post for the better mechanism of CheckBoxList Validation. Until then, what are your comments??

4 Checkboxes – Some tricky issue

Today, almost more than 4 hrs I’d spent on this issue. Do you want to know what is that? Here is that. I have 4 checkbox elements and I have to do the following conditions

Condition 1) Any one check box has to selected

Condition 2) If any of the first 2 check boxes are selected, my code should throw an exception when the 3rd check box is selected

Condition 3) vice versa for Condition 2

A picture is worth of 1000 words. Here is the actual requirement.

issue

Hope you got the actual picture. Now here comes the actual twist. You can do that with simple if conditions, but i thought of implementing this using territory operators using a single if condition. And the condition goes like this..

if(((cbRepair1.Checked || cbCalibration1.Checked ) ? 
    (cbBoth1.Checked) ? false : true : 
    (cbBoth1.Checked || cbOnLine1.Checked) ? true : false)==false){
    throw new Exception("Duplicate selection ..");
}

It took me almost more than 4 hrs. Isn’t it funny!!

.NET 4.0 & VS 2010 CTP is Ready

Ofcourse, i might sound late in this announcement, but better late than never. On 31st October 2008, Microsoft has announced the CTP version of Visual Studio 2010 and Framework version 4.0. And their statement goes like this.

Visual Studio 2010 and the .NET Framework 4.0 mark the next generation of developer tools from Microsoft. Designed to address the latest needs of developers, Visual Studio delivers key innovations in the following pillars:
Democratizing Application Lifecycle Management
Application Lifecycle Management (ALM) crosses many roles within an organization and traditionally not every one of the roles has been an equal player in the process. Visual Studio Team System 2010 continues to build the platform for functional equality and shared commitment across an organization’s ALM process.
Enabling emerging trends
Every year the industry develops new technologies and new trends. With Visual Studio 2010 and .NET Framework 4.0, Microsoft delivers tooling and framework support for the latest innovations in application architecture, development and deployment.
Inspiring developer delight
Ever since the first release of Visual Studio, Microsoft has set the bar for developer productivity and flexibility. Visual Studio 2010 continues to deliver on the core developer experience by significantly improving upon it for roles involved with the software development process. .NET Framework 4.0 contains numerous improvements that make it easier to develop powerful and compelling applications.
Riding the next generation platform wave
Microsoft continues to invest in the market leading operating system, productivity application and server platforms to deliver increased customer value in these offerings. With Visual Studio 2010 and .NET Framework 4.0 customers will have the tooling support and the platform support needed to create amazing solutions around these technologies.

Find the same and download from this link

Am Archiving Microsoft

Today while reading the mail messages using Outlook 2007, there flashed a message window mentioning about Archiving old mails. I’ve responded to archive. To my surprise I saw the below message on the right bottom of Outlook.image Do you see some thing strange here.

Archiving Microsoft.. Isn’t it strange. Am archiving whole Microsoft. How awesome is that thought.

Yee.. am now capable of archiving Microsoft sitting at my desk.

If any one missing Microsoft, contact me. I’ve the backup of Microsoft. Can share that to you.

Bill G: This is for you. I can offer Microsoft with some discounted price. Contact me on my private mobile connection. I’m sure that we can work out for a decent deal.

Strange caution by Google

image

Today, while searching googling for some information, the above got my attention. Did you see any thing strange in the above ?? I couldn’t understand how the google came to a conclusion that the website, ASPALLIANCE.COM, will harm the visitor’s computer.

Please help me if any of the world are aware of this .. or an clue about how this caution arise with ASPALLIANCE.COM

Silverlight Podcasts

sparklingclient

Sparkling client is a podcast about Silverlight and other RIA technologies. If you’re interested in learning how to write great websites that use Silverlight, ASP.NET AJAX, and others, give us a listen. If you would like professional advice in these areas, see the company we founded at www.silverbaylabs.org

The above is the definition from Sparkling Client website. I personally liked all of the podcasts. Must for every Siliverlight developer.

 

Did you?

Microsoft – Night School

All these days, only the government officials are encouraging every individual to become as literate. If any individual couldn’t able to attend the school in their childhood, they are conducting classes during evening hours at different places, so that the elderly people can go there during their evening time and can learn to read.

 

In fact, this new is not a new thing.. but the point is that .. Microsoft is conducting such kind of events with the local partners of Australia. Isn’t strange.. There are 3 tracks as an initiative.

1) SharePoint training for Team Leaders Home Page

2) Windows Server 2008 (Beta 3) – First Look, Getting started with Security and Policy Control

3) Windows Server 2008 – First Look, Getting started with Server Management

 

Isn’t it great .. hope one day this will become a practice at all locations of Microsoft