HTML forms are frequently used for getting input from the users. You can fill in different form fields containing Checkbox, Text, Radio, and Submit button for input. You can create or fill-in the HTML form programmatically using the C# language. This article covers the following sections related to HTML forms:
Aspose.HTML for .NET API lets you create or fill HTML forms with Submit buttons programmatically using C# language. You can configure the API by downloading a DLL file from the Downloads section, or quickly install it with the following NuGet installation command:
PM> Install-Package Aspose.Html
You can create a HTML form programmatically using C# language. Please follow the steps below for creating it from scratch:
The following code shows how to create a HTML form programmatically using C#:
Moreover, below is another approach for creating HTML form using native HTML form element in C#:
The following screenshot shows the output HTML form created with above code snippet:
You have already explored how to create an HTML form. Now you can learn how to fill HTML form and send the data to any remote server directly from your C# application. You can iterate through different items in the form and then use Submit button for sending the data. Here you will be working with a template form created by httpbin.org. It includes filling Text, Radio buttons, as well as Checkboxes that you be learning below:
Checkboxes are helpful where you need to choose more than one option. You can easily select the value in input type checkbox with the following code:
An HTML form may contain several text boxes and radio button fields for collecting data. You can fill the input text with the following code:
Likewise, you can select radio button fields with the code below:
You can send filled data in HTML form with the Submit button using FormSubmitter class. The following code shows how to call Submit() method in C# code:
Below is the complete source code to fill HTML forms programmatically using C#:
You can evaluate Aspose.HTML for .NET API without any Evaluation Limitations by requesting a Free Temporary License.
In conclusion, you have learned how to create an HTML form from scratch, as well as how to fill an existing HTML form and sending the data to a remote server from your C# application. You can also visit the Documentation section to explore several other features. Please feel free to contact us at the Free Support Forum for any of your queries.