ObjToForm 1.0.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package ObjToForm --version 1.0.1
NuGet\Install-Package ObjToForm -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ObjToForm" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ObjToForm" Version="1.0.1" />
<PackageReference Include="ObjToForm" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ObjToForm --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ObjToForm, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ObjToForm@1.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ObjToForm&version=1.0.1
#tool nuget:?package=ObjToForm&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ObjToForm ·

ObjToForm is a .NET tool for building HTML forms from objects meant to accelerate testing without spending time writing HTML Code.
Quick start
Several quick start options are available:
- Install with NuGet:
Install-Package ObjToForm - Install with .NET CLI:
dotnet add package ObjToForm - Clone the repo:
git clone https://github.com/Adler-Targino/ObjToForm.git
Demo
Example object
public class DemoObj
{
public string PublicString { get; set; }
public int PublicInt { get; set; }
public DateTime PublicDateTime { get; set; }
public float PublicFloat { get; set; }
public bool PublicBool { get; set; }
private string IShouldntBeHere {get; set;}
public DemoOptions PublicOptionsEnum { get; set; }
}
public enum DemoOptions
{
Option1,
Option2,
Option3,
Option4,
Option5
}
After installing the library you can convert C# objects directly into HTML forms
Razor Page Example
@using ObjToForm;
...
<form method="post">
@ObjToForm.ConvertToRawHtmlForm(typeof(DemoObj))
@ObjToForm.ConvertToRawHtmlForm(typeof(DemoObj), "Obj", true)
</form>
<hr>
<form method="post">
@ObjToForm.ConvertToBootstrapForm(typeof(DemoObj))
@ObjToForm.ConvertToBootstrapForm(typeof(DemoObj), "Obj", true)
</form>
Result
Receive the values in your controller as usual
public IActionResult OnPost(string PublicString, int PublicInt, DateTime PublicDateTime, float PublicFloat, bool PublicBool, DemoOptions PublicOptionsEnum)
{
...
return Page();
}
//Or, if you are using ModelBinding
public IActionResult OnPost(DemoObj Obj)
{
...
return Page();
}
Notes
- As shown in the previous example, only public attributes are rendered.
- Using Bootstrap-styled forms requires to previously add bootstrap to your project
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.AspNetCore.Html.Abstractions (>= 2.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.