Framesets
Framesets
This guide shows how to read legacy frames-page structure in Aspose.Words FOSS for .NET using the Frameset and FramesetCollection classes, which represent a frames page and its child frames when a document’s structure models a set of frames.
The Frameset Class
Frameset represents a frames page or a single frame on a frames page. Document.Frameset returns the root Frameset for a document that was loaded from a framed HTML structure. FrameDefaultUrl (string) is the web page URL or document file name displayed in that frame. IsFrameLinkToFile (bool) indicates whether the FrameDefaultUrl value is an external resource the frame links to. ChildFramesets returns a FramesetCollection of the child frames and frames pages nested under this one.
Iterating Child Frames with FramesetCollection
FramesetCollection implements IEnumerable<Frameset>, so GetEnumerator() supports foreach iteration over the frames it contains. Count reports the number of frames or frames pages in the collection. Combine Count and iteration with ChildFramesets to walk a nested frames-page structure recursively — each child Frameset can itself hold further ChildFramesets.
Tips and Best Practices
- Check
Document.Framesetfornullbefore reading its properties — most documents are not frames pages, so this property is only populated when the source HTML used a frames layout. - Walk
ChildFramesetsrecursively (rather than assuming a flat, one-level structure) since a frames page can nest further frames pages inside its frames. - Use
IsFrameLinkToFileto distinguish a frame that links to an external resource from one that embeds a document file name directly inFrameDefaultUrl. FramesetCollection.Countis a cheap way to check whether aFramesethas any children before iterating.
Common Issues
| Issue | Cause | Fix |
|---|---|---|
Document.Frameset is null | The document was not loaded from a frames-based HTML source | Confirm the source document actually used HTML frames before relying on this property |
Iterating ChildFramesets misses nested frames | Only the top level was iterated | Recurse into each child Frameset.ChildFramesets rather than iterating one level deep |
| Can’t tell whether a frame points to a file or a URL | IsFrameLinkToFile was not checked | Read IsFrameLinkToFile alongside FrameDefaultUrl to know how to resolve the target |
FAQ
What is a Frameset in Aspose.Words FOSS for .NET?
It represents a frames page or a single frame on a frames page, exposed as Document.Frameset for documents loaded from a frames-based HTML source.
How do I list all frames in a frameset?
Iterate Frameset.ChildFramesets (a FramesetCollection) with GetEnumerator() / foreach, recursing into any child that itself has further ChildFramesets.
How do I know how many child frames a Frameset has?
Read FramesetCollection.Count on its ChildFramesets property.
What does IsFrameLinkToFile tell you?
Whether the web page or document file name in FrameDefaultUrl is an external resource the frame is linked to.
API Reference Summary
| Class/Method | Description |
|---|---|
Document.Frameset | Root Frameset for a document loaded from a frames-based HTML source |
Frameset | Represents a frames page or a single frame on a frames page |
Frameset.FrameDefaultUrl | Web page URL or document file name displayed in the frame |
Frameset.IsFrameLinkToFile | Whether FrameDefaultUrl is an external linked resource |
Frameset.ChildFramesets | FramesetCollection of child frames and frames pages |
FramesetCollection | Collection of Frameset instances; Count, GetEnumerator |