Beispiel #1
0
    protected void CheckVideoExistsValidator_ServerValidate(object source, ServerValidateEventArgs args)
    {
        // checking if the video is exists to delete
        int             videoID   = 0;
        CustomValidator validator = source as CustomValidator;

        // try parse if some how it is not intger
        if (int.TryParse(args.Value, out videoID) == false)
        {
            validator.Text = "יש להכניס מספר חיובי שלם בלבד!!";
            SetMessageState(State.Warning, "יש להכניס מספר חיובי שלם בלבד!!");
            args.IsValid = false;
            return;
        }

        // if the video is not exists
        if (videos.IsVideoExists(Convert.ToInt32(videoID)) == false)
        {
            validator.Text = "סרטון לא קיים!";
            SetMessageState(State.Danger, "סרטון לא קיים!");
            args.IsValid = false;
        }
    }