Search code examples
c#asp.netdrop-down-menu.net-2.0updatepanel

DropdownList validation with AutoPostBack set to true inside updatepanel


there are many posts that deal with validation controls inside update panel and partial page rendering. But i got a different problem here, i did try updating to sp1 .NET framework 2.0 and again .NET Framework 4.0 but nothing happens.

Basically i got a dropdownlist inside update panel whose autopostback is set to true and an empty item -- Select -- is added as index 0 for validation (Required Field Validator) purpose. I does happen that even when i select index 0 , the validation message appears briefly and then partial postback takes place . Does anyone have any reasons for the same or alternate ways to do this.

note:

I am populating other controls (dropdownlist) during the selected index changed event. I could use cascading dropdownlist from AjaxControlToolkit but then i lose event validation functionality that other controls need.


Solution

  • why not validating client choise in code behind ?

    for ex' :

    if (ddlName.selectedValue == "-1")
    {
        lblErr.text = "You have to select...";
        lblErr.visible = true;
    }