219c219,223 < return (candidatePostBackScript != null) && (candidatePostBackScript.IndexOf("__doPostBack") != -1); --- > if (string.IsNullOrEmpty(candidatePostBackScript)) > { > return false; > } > return candidatePostBackScript.Contains("__doPostBack") || candidatePostBackScript.Contains("WebForm_DoPostBackWithOptions"); 230,233c234,237 < /// as a Javascript "__doPostBack" call. This method exists to make it easy to write < /// testers for controls that do so. Just take the string that contains the post- < /// back script and pass it to this method. Use < /// if the script isn't always present. --- > /// as a Javascript "__doPostBack" call or "WebForm_DoPostBackWithOptions" call (with validators). > /// This method exists to make it easy to write testers for controls that do so. > /// Just take the string that contains the post-back script and pass it to this method. > /// Use if the script isn't always present. 237,247c241,242 < string postBackPattern = @"__doPostBack\('(?.*?)','(?.*?)'\)"; < < Match match = Regex.Match(postBackScript, postBackPattern, RegexOptions.IgnoreCase); < if (!match.Success) < { < throw new ParseException("'" + postBackScript + "' doesn't match expected pattern for postback in " + HtmlIdAndDescription); < } < < string target = match.Groups["target"].Captures[0].Value; < string argument = match.Groups["argument"].Captures[0].Value; < PostBack(target.Replace('$', ':'), argument); --- > ScriptOptions options = OptionsOutOf(postBackScript); > PostBack(options.Target.Replace('$', ':'), options.Argument); 248a244,288 > > private ScriptOptions OptionsOutOf(string postBackScript) > { > postBackScript = postBackScript.Replace("\"", "'"); > string [] patterns = new string[] > { > @"__doPostBack\('(?.*?)','(?.*?)'\)", > @"WebForm_DoPostBackWithOptions\(new WebForm_PostBackOptions\('(?.*?)', '(?.*?)', (?.*?)(?.*?)\)\)" > }; > foreach (string pattern in patterns) > { > Match match = Regex.Match(postBackScript, pattern, RegexOptions.IgnoreCase); > if (match.Success) > { > string target = match.Groups["target"].Captures[0].Value; > string argument = match.Groups["argument"].Captures[0].Value; > return new ScriptOptions(target, argument); > } > } > throw new ParseException("'" + postBackScript + "' didn't match any expected patterns for postback in " + HtmlIdAndDescription); > } > > private class ScriptOptions > { > private string target; > private string argument; > > > public ScriptOptions(string target, string argument) > { > this.target = target; > this.argument = argument; > } > > > public string Target > { > get { return target; } > } > > public string Argument > { > get { return argument; } > } > }