agentic-net-examples / form-fields
AGENTS.md4 starsChanged 3 months agoMITView on GitHub
Verified C# examples for form-fields scenarios in Aspose.Words for .NET
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository29 other files it gives its agents.
- aspose-words-examplesAGENTS.md
- barcode-imageAGENTS.md
- chartsAGENTS.md
- commentsAGENTS.md
- comparisonAGENTS.md
- content-controlAGENTS.md
- conversionAGENTS.md
- extractionAGENTS.md
- find-and-replaceAGENTS.md
- fontsAGENTS.md
- hyphenationAGENTS.md
- imagesAGENTS.md
- join-documentsAGENTS.md
- linq-reportingAGENTS.md
- listsAGENTS.md
- mail-mergeAGENTS.md
- officemathAGENTS.md
- ole-objectsAGENTS.md
- paragraphsAGENTS.md
- programming-with-documentsAGENTS.md
- rangeAGENTS.md
- renderingAGENTS.md
- security-and-protectionAGENTS.md
- shapesAGENTS.md
- split-documentAGENTS.md
- track-changesAGENTS.md
- vba-macrosAGENTS.md
- watermarkAGENTS.md
- working-with-tableAGENTS.md
The file
We split this AGENTS.md into the rules it gives an agent
6 rules. About 0 are common, 6 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 17
Use native Aspose.Words legacy form-field APIs directly.
- Distinctive: line 18
Use DocumentBuilder.InsertTextInput, InsertCheckBox, and InsertComboBox to create fields.
- Distinctive: line 20
Do not mix StructuredDocumentTag unless the task explicitly requires content controls.
- Distinctive: line 31
Use the simplest workflow that satisfies the task.
- Distinctive: line 248
When replacing a file, prefer the latest verified publish-ready version rather than a merely compiling draft.
- Distinctive: line 249
Keep examples standalone, bootstrap missing inputs locally, and prefer documented Aspose APIs over speculative shortcuts.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md - Form Fields
Purpose
This folder is a live, curated example set for Form Fields scenarios. Treat every .cs file as a standalone console application. The goal is correct, warning-free examples that use documented Aspose APIs and match the original task intent.
Non-negotiable conventions
- Use native Aspose.Words legacy form-field APIs directly.
- Use DocumentBuilder.InsertTextInput, InsertCheckBox, and InsertComboBox to create fields.
- Access existing legacy fields through Document.Range.FormFields.
- Do not mix StructuredDocumentTag unless the task explicitly requires content controls.
- Bootstrap local source documents whenever the task implies an existing file or pre-existing fields.
- Guard maybe-null values to avoid nullable-reference warnings such as CS8600, CS8602, and CS8604.
Recommended workflow selection
- Text Form Field workflow: 7 examples
- General Form Field workflow: 17 examples
- Dropdown Form Field workflow: 4 examples
- Inspection And Reporting workflow: 2 examples
Use the simplest workflow that satisfies the task.
Validation priorities
- The code must compile and run without manual input.
- API usage must be supported by the configured package versions.
- Exported outputs must actually be written by the example.
- Validation scenarios must inspect only the behavior requested by the task.
- Examples that depend on files, folders, streams, images, or data should bootstrap those inputs locally during the example run.
File-to-task reference
insert-a-text-input-form-field-with-placeholder-text-using-documentbuilder-in-a-new-docume.cs- Task: Insert a text input form field with placeholder text using DocumentBuilder in a new document.
- Workflow: text-form-field
- Outputs: docx
- Selected engine: mcp
add-a-check-box-form-field-set-default-checked-state-and-custom-size-via-documentbuilder.cs- Task: Add a check box form field, set default checked state and custom size via DocumentBuilder.
- Workflow: general-form-field
- Outputs: docx
- Selected engine: mcp
create-a-combo-box-form-field-containing-three-items-and-set-default-selected-index-using.cs- Task: Create a combo box form field containing three items and set default selected index using DocumentBuilder.
- Workflow: dropdown-form-field
- Outputs: docx
- Selected engine: mcp
specify-a-name-when-inserting-a-text-input-field-to-automatically-generate-a-matching-book.cs- Task: Specify a name when inserting a text input field to automatically generate a matching bookmark.
- Workflow: text-form-field
- Outputs: docx
- Selected engine: mcp
insert-a-text-input-field-with-maximum-length-of-50-characters-and-numeric-format-using-do.cs- Task: Insert a text input field with maximum length of 50 characters and numeric format using DocumentBuilder.
- Workflow: text-form-field
- Outputs: docx
- Selected engine: mcp
insert-a-text-input-field-with-custom-date-format-and-default-current-date-value-using-doc.cs- Task: Insert a text input field with custom date format and default current date value using DocumentBuilder.
- Workflow: text-form-field
- Outputs: docx
- Selected engine: mcp
implement-a-reusable-method-that-adds-a-combo-box-form-field-with-customizable-items-and-d.cs- Task: Implement a reusable method that adds a combo box form field with customizable items and default index.
- Workflow: dropdown-form-field
- Outputs: docx
- Selected engine: mcp
assign-a-unique-name-to-each-inserted-form-field-to-ensure-distinct-automatic-bookmarks.cs- Task: Assign a unique name to each inserted form field to ensure distinct automatic bookmarks.
- Workflow: general-form-field
- Outputs: docx
- Selected engine: mcp
batch-insert-multiple-text-input-form-fields-into-a-template-using-a-loop-over-field-defin.cs- Task: Batch insert multiple text input form fields into a template using a loop over field definitions.
- Workflow: text-form-field
- Outputs: docx
- Selected engine: mcp
load-a-docx-file-change-combo-box-selections-programmatically-and-save-the-modified-docume.cs- Task: Load a DOCX file, change combo box selections programmatically, and save the modified document.
- Workflow: dropdown-form-field
- Outputs: docx
- Selected engine: mcp
update-result-values-of-several-check-box-form-fields-based-on-external-json-configuration.cs- Task: Update result values of several check box form fields based on external JSON configuration data.
- Workflow: inspection-and-reporting
- Outputs: json
- Selected engine: mcp
set-the-result-property-of-a-text-input-form-field-to-a-predefined-string-value.cs- Task: Set the Result property of a text input form field to a predefined string value.
- Workflow: text-form-field
- Outputs: docx
- Selected engine: mcp
read-the-result-property-of-a-check-box-form-field-to-determine-whether-it-is-checked.cs- Task: Read the Result property of a check box form field to determine whether it is checked.
- Workflow: general-form-field
- Outputs: docx
- Selected engine: mcp
toggle-the-checked-state-of-a-specific-check-box-form-field-based-on-external-configuratio.cs- Task: Toggle the checked state of a specific check box form field based on external configuration settings.
- Workflow: general-form-field
- Outputs: docx
- Selected engine: mcp
change-the-size-of-an-existing-check-box-form-field-programmatically-to-improve-visual-con.cs- Task: Change the size of an existing check box form field programmatically to improve visual consistency.
- Workflow: general-form-field
- Outputs: docx
- Selected engine: mcp
retrieve-a-form-field-by-its-name-from-a-loaded-document-and-read-its-result-property.cs- Task: Retrieve a form field by its name from a loaded document and read its Result property.
- Workflow: general-form-field
- Outputs: docx
- Selected engine: mcp
access-a-form-field-by-index-from-the-formfields-collection-and-modify-its-result-value.cs- Task: Access a form field by index from the FormFields collection and modify its Result value.
- Workflow: general-form-field
- Outputs: docx
- Selected engine: mcp
use-formfield-type-enumeration-to-differentiate-between-text-input-check-box-and-combo-box.cs- Task: Use FormField.Type enumeration to differentiate between text input, check box, and combo box fields.
- Workflow: dropdown-form-field
- Outputs: docx
- Selected engine: mcp
iterate-over-all-form-fields-in-a-document-and-list-each-field-s-name-and-type.cs- Task: Iterate over all form fields in a document and list each field's name and type.
- Workflow: inspection-and-reporting
- Outputs: docx
- Selected engine: mcp
count-the-number-of-each-form-field-type-by-iterating-through-the-formfields-collection.cs- Task: Count the number of each form field type by iterating through the FormFields collection.
- Workflow: general-form-field
- Outputs: docx
- Selected engine: mcp
iterate-through-form-fields-and-log-each-field-s-result-value-for-debugging-purposes.cs- Task: Iterate through form fields and log each field's Result value for debugging purposes.
- Workflow: general-form-field
- Outputs: docx
- Selected engine: mcp
extract-automatically-generated-bookmark-names-for-all-form-fields-and-store-them-in-a-loo.cs- Task: Extract automatically generated bookmark names for all form fields and store them in a lookup dictionary.
- Workflow: general-form-field
- Outputs: docx
- Selected engine: mcp
navigate-to-a-form-field-using-its-automatically-created-bookmark-and-extract-surrounding.cs- Task: Navigate to a form field using its automatically created bookmark and extract surrounding paragraph text.
- Workflow: general-form-field
- Outputs: docx
- Selected engine: mcp
protect-a-word-document-with-allowonlyformfields-option-allowing-only-form-fields-to-be-ed.cs- Task: Protect a Word document with AllowOnlyFormFields option, allowing only form fields to be edited.
- Workflow: general-form-field
- Outputs: docx
- Selected engine: mcp
apply-document-protection-levels-ensuring-only-form-fields-remain-editable-while-other-sec.cs- Task: Apply document protection levels ensuring only form fields remain editable while other sections are read-only.
- Workflow: general-form-field
- Outputs: docx
- Selected engine: mcp
verify-that-protected-document-still-permits-editing-of-form-fields-after-saving-and-reope.cs- Task: Verify that protected document still permits editing of form fields after saving and reopening.
- Workflow: general-form-field
- Outputs: docx
- Selected engine: mcp
after-inserting-fields-protect-the-document-and-then-verify-that-non-field-content-cannot.cs- Task: After inserting fields, protect the document and then verify that non-field content cannot be edited.
- Workflow: general-form-field
- Outputs: docx
- Selected engine: mcp
disable-all-check-box-form-fields-programmatically-when-a-specific-document-condition-is-m.cs- Task: Disable all check box form fields programmatically when a specific document condition is met.
- Workflow: general-form-field
- Outputs: docx
- Selected engine: mcp
implement-error-handling-for-attempts-to-insert-a-form-field-with-an-empty-name-logging-a.cs- Task: Implement error handling for attempts to insert a form field with an empty name, logging a warning.
- Workflow: general-form-field
- Outputs: docx
- Selected engine: mcp
build-a-console-application-that-reads-a-csv-file-and-populates-corresponding-text-input-f.cs- Task: Build a console application that reads a CSV file and populates corresponding text input fields in a template.
- Workflow: text-form-field
- Outputs: csv
- Selected engine: mcp
Common failure patterns and preferred agent fixes
- Mixing legacy form fields with content controls
- Symptom: Examples use StructuredDocumentTag when the task is about legacy form fields.
- Preferred fix: Use DocumentBuilder legacy form-field APIs and Document.Range.FormFields unless the task explicitly requires content controls.
- Wrong field access pattern
- Symptom: Code assumes unsupported helpers or reads the wrong property for the field type.
- Preferred fix: Access legacy fields through Range.FormFields and use Result, Checked, or DropDownItems according to the field type.
- Missing bootstrap input
- Symptom: Examples assume an existing document with form fields already exists.
- Preferred fix: Create a local sample document and seed the required form fields before reading or updating them.
- Weak validation
- Symptom: The example saves output but does not verify that the form field exists or that its value changed.
- Preferred fix: Validate field existence and the final assigned value before finishing.
Build and run contract
- Target framework:
net8.0 - Package:
Aspose.Words26.9.0
Command reference
Create a temporary console project
dotnet new console -n ExampleProject --framework net8.0
cd ExampleProjectAdd required packages
dotnet add package Aspose.Words --version 26.9.0Copy a category example into the temp project
Copy-Item ..\form-fields\<example-file>.cs .\Program.csBuild and run
dotnet build --configuration Release --verbosity minimal
dotnet run --configuration Release --no-buildCategory update guidance
- Preserve file-to-task traceability. Any future update should keep the original task text associated with the file in metadata.
- When replacing a file, prefer the latest verified publish-ready version rather than a merely compiling draft.
- Keep examples standalone, bootstrap missing inputs locally, and prefer documented Aspose APIs over speculative shortcuts.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

