ASP.NET - control check inside UserControl

I have a UserControl wrapper around a DropDownList to control language-specific translation by DropDownList values.

I also have a required field validator that is set for an internal dropdown.

How can I open this control through usercontrol to allow validation?

The error I am currently getting is as follows:

... cannot be validated. at System.Web.UI.WebControls.BaseValidator.CheckControlValidationProperty(String name, String propertyName)
      at System.Web.UI.WebControls.BaseValidator.ControlPropertiesValid()

Edit: I am using now ...

[ValidationPropertyAttribute("SelectedValue")]

.... WITH

public string SelectedValue
{
    get { return cboI18nItems.SelectedValue; }
}

What now works if I check the IsValid property on the page after the postback.

+5
source share
2 answers

UserControl, .

ValidationProperty UserControl

  • UserControl. .
  • CustomValidator. ControlToValidate. , DropDownList UserControl. , , DropDownList , , UserControl UserControl.
  • ValidationPropertyAttribute. usercontrol, .

.

+5

, , . , :

Protected Sub ValidateCreditCard()
    Dim validators = Page.GetValidators("cc")
    For Each v In validators
        DirectCast(v, BaseValidator).Validate()
    Next
End Sub

VB.NET, .

+1

All Articles