How to set CustomValidor for FileUpload
-
Hi, My interface is having One, dropdownlist, some text boxes, one fileupload and a submit button.. code here.. Select Category Category1 Category2 Category3 Category4 For file upload code... ------------------------ Code behind =========== protected void validatedrp(object source, ServerValidateEventArgs args) { if (drp_Category.SelectedValue == "Category1") { args.IsValid = true; } else if(drp_Category.SelectedValue == "Category3") { args.IsValid = true; } else if(drp_Category.SelectedValue == "Category2") { args.IsValid = false; } else if(drp_Category.SelectedValue == "Category4") { args.IsValid = false; } } My issue is if i select dropdownlist item Category1 or Category3 and click the submit button, the fileupload should prompt msg as "plz select file to upload"....if i select dropdownlist item Category3 or Categroy4 and click the submit button, the fileupload should not propt msg and should redirect to different page... plz help.. Thanks in advance
-
Hi, My interface is having One, dropdownlist, some text boxes, one fileupload and a submit button.. code here.. Select Category Category1 Category2 Category3 Category4 For file upload code... ------------------------ Code behind =========== protected void validatedrp(object source, ServerValidateEventArgs args) { if (drp_Category.SelectedValue == "Category1") { args.IsValid = true; } else if(drp_Category.SelectedValue == "Category3") { args.IsValid = true; } else if(drp_Category.SelectedValue == "Category2") { args.IsValid = false; } else if(drp_Category.SelectedValue == "Category4") { args.IsValid = false; } } My issue is if i select dropdownlist item Category1 or Category3 and click the submit button, the fileupload should prompt msg as "plz select file to upload"....if i select dropdownlist item Category3 or Categroy4 and click the submit button, the fileupload should not propt msg and should redirect to different page... plz help.. Thanks in advance
Change ControlToValidate attribute of the custom validator from "FileUpload1" to "drp_Category"