Optionally provide private feedback to help us improve this article...

Thank you for your feedback!

Display a topic using the InstantForum .NET API

The following code example shows how to query and display a single topic within InstantForum using the InstantForum .NET API.

Getting Started

You'll first need to reference the InstantForum assemblies from your Visual Studio solution or project. Once you've referenced the InstantForum assemblies you'll need to add the following using statement to your class...

using InstantASP.Common.Enumerations;
using InstantASP.InstantForum;

Code Example

In this example we'll return all posts within our InstantForum_Topics table with the TopicID of 123. We'll also sort the returned results in date ascending order so the earliest post appears first and the most recent post appears last. You'll also notice in this example we returned a paged result set and in this example this is limited to 10 results per page for the topic.

// get current user object
var currentUser = HttpContext.ForumContext.Current.CurrentUser;

// we'll return a pagable set of results so here we set
// our current page index and page size
var pageIndex = 1;
var pageSize = 10;

// select all posts with matching the supplied topic ID
var args = new Components.SearchEventArgs()
TopicID = 123,
SortBy = "DateStamp", // the name of the field to sort by within the InstantForum_Topics table
SortOrder = EnumSortOrder.ASC,

// to restrict results based on the roles associated with the current
// user we pass the currentUser object into the construcotr of our topics business class
var t = new Business.Topics(currentUser);

// query our topics
var topics = t.SelectTopic(

// do we have results?
if (topics != null)
// let's show them
foreach (var topic in topics)
Response.Write("<strong>" + topic.Title + "</strong><br/>");
Response.Write(topic.Message + "<br/>");

‚ÄčThat's It!

We hope this example helps you integrate InstantForum into your applications. If we can assist further with this example or indeed provide any further examples of course please don't hesitate to submit a support request.