/// <summary> /// Gets the submission data for submitting the form, as if using the first available submit button. /// </summary> /// <param name="SubmitButton">Button to Submit with, if Required.</param> /// <returns>The Form's Submission Data</returns> public List <KeyValuePair <string, IRequestInfo> > GetSubmissionData(SubmitControl SubmitButton) { var entries = new List <KeyValuePair <string, IRequestInfo> >(); var items = this.Where(item => !string.IsNullOrWhiteSpace(item.Name) && item.Type != FormControlType.Ignore && (item.Type != FormControlType.Submit // add the Submit button to the Submission data, only if there is more than one submit control. || (item == SubmitButton && this.OfType <SubmitControl>().Count() > 1))); foreach (var item in items) { var requests = item.GetRequestInfo(); // If there are no requests, continue. This can occur with the FileControl and CheckBox/Radio Controls. if (requests == null) { continue; } // Adds all the various requests, multiple requests can occur with Checkboxes. foreach (var request in requests) { entries.Add(new KeyValuePair <string, IRequestInfo>(item.Name, request)); } } return(entries); }
/// <summary> /// Submits the Form, with the provided submit button as the target. /// </summary> /// <param name="SubmitButton">Button to Submit with, if Required.</param> /// <returns></returns> public Task <WebPage> SubmitForm(SubmitControl SubmitButton) { var address = new Uri(Action, UriKind.RelativeOrAbsolute); // Attaches the Absolute address from the current page, if the address isn't already absolute. if (!address.IsAbsoluteUri) { address = new Uri(SourcePage.RequestInfo.Address, address); } var data = GetSubmissionData(SubmitButton); // Populates the Web Page Request to Navigate the Browser along. var requestInfo = new WebPageRequestInfo( address, data, Method.ToUpper(), EncodingType); return(SourcePage.SourceBrowser.NavigateAsync(requestInfo)); }