Showing posts with label controls. Show all posts
Showing posts with label controls. Show all posts

Tuesday, May 26, 2009

CodeProject Article: Exposing Events in ASP.NET Server Controls

I've just submitted an article to CodeProject. The article's main concern is adding events to your ASP.NET Server Controls. Although the topic may seem pretty straightforward, there are still some major optimization pitfalls that developers may not be aware of.
In this article I emphasize on using the Events collection. Code listings are provided in C#.

Cheers,
Kirill

Tuesday, March 24, 2009

Using AJAX CascadingDropDown Extender with Page.EnableEventValidation Set to True

Using the CascadingDropDown control extender that ships with the AJAX Control Toolkit requires that EnableEventValidation property of the Page containing the target DropDownList control be set to false.
However, this can potentially expose our page to a malicious attack, since nothing can then prevent "generated" post-backs.
A more elegant approach is creating a class that derives from DropDownList as follows:

public class NoValidationDropDownList : DropDownList
{ }

After the class has been created, all we need to do is replace the instances of the DropDownList class with respective instances of the NoValidationDropDownList class.

The reason why this works is simple: ASP.NET only validates controls that are marked with the SupportsEventValidation attribute. Since our class is not marked with this attribute, ASP.NET does not validate items on post-back and, consequently, no exception is thrown.

Cheers,
Kirill