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.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??
Posted by Chakravarthy | with no 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!!

Posted by Chakravarthy | with no comments

.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

Posted by Chakravarthy | with no comments
Filed under: , ,

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.

Posted by Chakravarthy | with no comments
Filed under:

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

Posted by Chakravarthy | with no comments
Filed under:

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?

Posted by Chakravarthy | with no comments

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

Posted by Chakravarthy | with no comments

IE 8 Beta1 and SL2.0 - Today

image

Today, I've downloaded IE8 beta 1 as well as Silverlight 2.0 installed on my laptop. This day have seen many products released at Mix 08 by great personalities like Scott GuthrieBob Familiar, Guy Burstein, IEBlog, etc. According to Jane Kim at an interview for Mix08, Activities and WebSlices are two of the most exciting new features in IE8.

image

Apart of IE8.0 and SL2.0, there are other products such as

I've downloaded all these .. and am trying out one by one .. what about you??

Posted by Chakravarthy | with no comments

IE 8 Beta1 and SL2.0 - Today

image

Today, I've downloaded IE8 beta 1 as well as Silverlight 2.0 installed on my laptop. This day have seen many products released at Mix 08 by great personalities like Scott GuthrieBob Familiar, Guy Burstein, IEBlog, etc. According to Jane Kim at an interview for Mix08, Activities and WebSlices are two of the most exciting new features in IE8.

image

Apart of IE8.0 and SL2.0, there are other products such as

I've downloaded all these .. and am trying out one by one .. what about you??

Douglas Crockford talk about WEB

This is a nice talk about how the web evolved and where it should have been as of this day. According to Douglas Crocford, instead of progressing into new technology, we are degrading our technology into where it all started.

Shocking !!! isn't it !!! .. listen to him from his own voice. Am convinced with his idea, and certain facts that he is mentioning about are REAL. According to him, we are doing research on the great thoughts that are published way back in the history by many great scholars.

This is the first time am giving attention to such talks. Probably because of this, I felt that this talk has many points to give attention. Anyhow, overall this is a great talk and every mind that want to contribute to the progress of our technology, should listen to him and put some thought process towards these points.

Did you listen to this ??

Posted by Chakravarthy | with no comments
Filed under: , ,

What's behind name, "Microsoft"

Did you ever thought that Bill Gates named their company as "Microsoft"?.. it was a billion dollar question to me all these days. At the early days when Bill is forming his company along with his friends, sought recommendations for a good and fancy name. Every one gave their won stylish and trendy names. They are not ready till their first cheque is due to them. While Steve Balmer is talking about a product that is the brain child of Bill, mentioned as ".. it is a SOFTware for MICROprocessors .. ", these words lead the idea to name their company as Microsoft. And the rest is history and preset.

Does any has proof to violate this information??

Posted by Chakravarthy | with no comments

Standards @ Microsoft

With the new year roll out, Microsoft has initiated a new website with the caption as mentioned at the subject of this post. Yes, they are starting a new initiative with all the Standards that are in place with the industry giants and the best out of Individuals, Corporations, Acadmics, who not ... every one ..

http://www.microsoft.com/standards/ is the link for all such standards. The initial thought for this resulted from the Interop team. They have a separate home for them as http://www.microsoft.com/interop. The history has 2 yrs old story to come out with such standards towards Interoperability. And finally they are with the standards that are in best practice with industry.

I just started going through one by one.. did you ??

Posted by Chakravarthy | with no comments

VS 2008 and .NET 3.5 Training Kit

The Visual Studio 2008 and .NET Framework 3.5 Training Kit includes presentations, hands-on labs, and demos. This content is designed to help you learn how to utilize the Visual Studio 2008 features and a variety of framework technologies including: LINQ, C# 3.0, Visual Basic 9, WCF, WF, WPF, ASP.NET AJAX, VSTO, CardSpace, SilverLight, Mobile and Application Lifecycle Management.

I've downloaded this, if any one require this, you can drop me a mail or can collect from me.

Microsoft Products at No Cost - Free

Who says that Microsoft manufactures products only to sell ?? Microsoft has many products that are free to download. As am into .NET and specially with Visual Studio, am aware that Visual Studio is free to download from Microsoft's website. Yes, that's true.. Microsoft give Visual studio 2008 Express Editions, MSDN Library for Visual Studio 2008 as well as the Runtime for the latest .NET framework 3.5.

Here is the link to learn more towards free products as well as priced products. To know more about the product information about Visual Studio 2008, click here.

Posted by Chakravarthy | with no comments

Laptop under $100

That's true, you read the title correct. BBC recently wrote about this on 6th Dec 08. Microsoft is working out towards the XP operating system to be a reality on the co called $100 laptop or XO. If things go as scheduled, $100 Laptop or XO will be a reality by the mid 2008.

James Utzschneider, GM for Marketing and Communications from Microsoft, wrote about this at his blog. According to him, about 40 engineers are working towards mid 2008 to come out with a production-quality release. The XO laptop works with 1GB Flash memory, when compared with traditional Hard Disk Drive.

OLPC, One Laptop Per Child, organisation is having a great idea towards making this product into a reality. During June 2008, Intel announced a laptop under $220 with a title as "Classmate PC". This is similar to that of XO laptop, but some of the basic difference is kind of 2GB Flash memory in ClassmatePC, where as 1GB in XO laptop.

These kind of laptops are really good towards educating the next generation kids towards the technology. Isn't a great work..

Servers at Home

Servers, no more belong to Office. All these days, wife's worry that their husband not only work wholly with LapTop, on top of this, Microsoft is coming out with one more product titling as "Stay at Home Servers". Don't you believe this .. pay a visit to their product page. Microsoft addresses this as "WindowsHomeServer". The advantages explained in nice video. This video has all the possible places that every home can have and what every one can do from every location of common home.

Where are we going .. and where is the infrastructure is moving to ?? anyhow, when will India have all such infrastructure inbuilt apartments or homes built with such facilities.

Posted by Chakravarthy | with no comments

ASP.NET 3.5 Extensions Preview

The ASP.NET 3.5 Extensions Preview provides a glimpse of new, powerful functionality being added to ASP.NET 3.5 and ADO.NET next year. This release delivers features that enable high-productivity data scenarios and creates the best server for rich clients. The release includes an ASP.NET model-view-controller (MVC) framework, ASP.NET Dynamic Data, Silverlight controls for ASP.NET, ADO.NET Data Services, an Entity Framework runtime, new features for ASP.NET AJAX and a wide variety of API References as hosted at ASP.NET Official site.

You can download the ASP.NET 3.5 Preview, which contain all the Siliverlight controls, ADO.NET Data Services and many more. There is a forum specially dedicated to ASP.NET 3.5 Preview at ASP.NET Forums.

Posted by Chakravarthy | with no comments

Calling .NET Component from a classic ASP page

After a long time, today, got a requirement from ASP page. Our current client has a major application written in classic ASP 2.0, and we have given him an extension functionality written in .NET with VB as programming language.

Now, we have 2 different applications running at the same box with 2 different technologies, ie., an ASP application and an ASP.NET application. For both of the applications, there is a common functionality talking to the database via a webservice written in Java. The current situation demand a common library that will be reused at both ASP.NET pages as well as ASP pages. Apart of the requirement, the one point that led me to post here is "How to call a .NET Assembly in a Classic page"

Creating .NET Assembly

Imports System
Imports System.Runtime.InteropServices
Public Class MyLibClass
    Public Function MyLibFunction() As String
        Return " Invoked the method from COM successfully .."
    End Function
End Class

With the above code, you can generate a .NET DLL after compiling with either Visual Basic Command Line Utility, VBC.EXE or from the Visual Studio Environment. While compiling this code, give extra attention at the assembly attribute to make the DLL Visible to COM as mentioned below.

<Assembly: ComVisible(True)> 

If you are using the Visual Studio Environment, go to the Project Properties, at the Compile section don't forget to check the "Register COM interop" check box. This check box will be by default unchecked, indicating that the DLL will not be exposed to COM.

Now the assembly is ready to reuse. But before we start the actual implementation, if you want the Assembly should be register with the GAC, you have to take the assistance from StrongNameKey file. You can create a Strongname Key file with the command utility SN.EXE or from the Visual Studio as well. The command to create the Strongname Key file is as mentioned below

> sn -k strongnamekeyfile.snk

Once you are done with the strong name key file generation, you can attach the key file either with the /keyfile:strongnamekeyfile.snk option or with the assembly attribute as <Assembly: AssemblyKeyFile("strongnamekeyfile.snk")>

Now it is the final time to compile your code and do the calling stuff from ASP page. Once you compile the code from Visual Studio, you will have 3 files, .PDB / .TLB / .DLL. The .DLL is the actual file. You have to do 2 things to share this DLL.

Register as COM as well as with GAC

Now that the DLL is ready, we will take the assistance of REGASM command line utility to register as public assembly.

> regasm /codebase /tlb:a.tlb OurAssemblyFile.dll

With this command, the DLL will be registering at the registry. Please don't forget to use the /codebase option. To register the same with GAC use the following command

> gacutil /if OutAssemblyFile.dll

This command will register with the GAC and is available as reference within the .NET Framework. With the first command, the object is ready to invoke from ASP code. You can use the COM component with Server.CreateObject("OurAssemblyFile.ClassName") command from ASP page. The actual implementation at any ASP page will look like as mentioned below

 dim objCom 
 set objCom = Server.CreateObject("libraryNameSpace.libraryClass")
 objCom.DoSomeWork() ' this method doesn't return any value
Finally, if this page throw any kind of error as Unindentified Class name, then the only solution is to reset the IIS.
Posted by Chakravarthy | with no comments
Filed under: , ,

Mix: UK 07 Vedios

For all those who didn't attend the Mix at UK during Sep 07, here is a good news. The good news is not only for those who didn't attend the MIX, but for all the technology lovers as well as persons who are passionate about latest technology happenings.

The two day event is now available for offline viewing at their website. Here is the link that give you the download of all the videos of all the sessions that happened. Isn't nice for all of us, who missed the event and who couldn't afford to attend the event.

It's time to download and view them offline. Am going to download all the events, if any of you doesn't have the i-net connectivity or by any issue, could not download these videos, drop me a mail at DSKCHECK at MSN dot COM

Catch you later..

Live goes deep while searching

Most of the industry say that, Google is the top search engine and will give you lot of results when you search. But the missing point is that, Live Search gives you deeper search when compared to Google.

Surprising !!!! i just did a small search for my name, Chakravarthy, at both the search engines. To make the figures matter, i go upto 100 pages in Live Search results. Where as, Google takes me only upto 84 pages. To my surprise, when i go back to the 83 page, then i see the search pages count is increased from 84 to 87. is isn't it weird ..

And adding to my surprise, i read a statement at the bottom of the last search page as

"In order to show you the most relevant results, we have omitted some entries very similar to the 870 pages already displayed"

 

Don't believe !!!! Try out your self..

Posted by Chakravarthy | with no comments
Filed under:
More Posts Next page »