Playing With TELERIK

For those of you who don't know what Telerik is, it is a framework for multiple platforms which brings in advanced visual features and ease up your programming stress by giving you neater and cleaner representation with a lot less amount of code.

One feature that  I like most of Telerik framework for ASP.Net is form validation using input manager. It can be used to automatically validate input text using various modes like numeric,currency and date time. It does everything for you by restricting user from entering invalid data and stoping the page postback. The way it displays error is just beautiful and saves lot of space on the form too.

It looks something like this. You could obviously add error text in it.

One place where it lacks is its inability to handle any control other than textboxes. So if you have a big form with all kinds of controls on it and you want to validate most of them then you would have to look for some other means of validation on controls other than textboxes. This greatly reduces the uniformity of the overall form.

But there is a solution for it. You could apply the above appearence to comboboxes and datepickeres by just adding an ASP custom validator and adding an onvalidate javascript fuction to it. In that javascript function you could check for empty text and apply the css skin to the correct element . I have written "correct element" because a single control for example a combo box is made up of many elements like a textbox, an unordered list and an arrow.

So to sum up you would have to use firebug or any other web debugging AddOn to know the name of css class applied to textboxes automatically on erroneous input. From there you have to apply that css class to the required control's element using JQuery or any other approach. I recommend JQuery  cause its easy to use and efficient. You have to set the css class on errors only example empty text or wrong input and remove it otherwise.

I would be happy to show you the code but for obvious reasons I can't . So feel free to ask if you have any doubts regarding the same.

I would be coming up with more solutions to some common problems using telerik and post them ASAP .


Post a Comment