Home > Getting Started > ASP.NET Syntax > ASP.NET Page Syntax > Server-Side Object Tag Syntax
ASP.NET Syntax ASP.NET Page Syntax
Declares and creates COM and .NET objects in a Web Forms page.
<object id="id" runat=server class = ".NET Framework Class Name">
<object id="id" runat=server progid="COM ProgID" />
<object id="id" runat=server classid="COM ClassID" />
id |
Unique name to use when referencing the object in subsequent code. |
class |
Specifies the .NET Framework class to create. |
progID |
Specifies the COM component to create by specifying the component’s programmatic identifier. |
classID |
Specifies the COM component to create using the component’s class identifier. |
When the ASP.NET page parser encounters a server-side object tag in an .aspx file, it generates a read/write property on the page, using the id attribute of the tag as the property name. The read property is then configured to create an instance of the object on first use. The resulting instance is not added as an object within the page’s hierarchical server control tree; it is instead treated as a non-UI variable declaration.
The classid, progid, and class attributes are mutually exclusive. You cannot include more than one of these attributes in a single server-side object tag. You can, however, include multiple server-side object tags on a Web Forms page and use these attributes in different tags.
The below code snippet demonstrates how to create an instance of the OLEDBDataAdapter .NET Framework class in a Web Forms page.
[ Visual Basic ]
<html>
<object id="MyDatabase" class = "System.OLEDBDataAdapter" runat="server" />
<script language="VB" runat=server>
Sub Page_Load ( Sender as Object, E as EventArgs )
Dim StockDetails as Recordset
Set StockDetails = MyDatabase.Execute ( "DSN:money", "select * from stocks" )
End Sub
</script>
</html>
Introduction to Web Forms