Share via


Setting User Control Properties at Page Design Time

User controls have properties that affect how the controls are displayed. These properties can be set at design time or at run time. The following example shows how a control is used at design time. For more information about setting user control properties at run-time, see the Setting User Control Properties Programmatically at Run Time.

In the following example, suppose there is a simple user control "Header" that exposes the property BannerImagePath as a public property. The control uses this property as the path to the image resource in the header. The following code is from a typical .aspx page that contains such a header control:

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="default.aspx.vb" Inherits="Microsoft.CommerceServer.CommerceSite.DefaultForm"%>
<%@ Register TagPrefix="misc" TagName="Header" Src="Misc/header.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
  <body>
<misc:Header id="Header" BannerImagePath=”.\mycompany.jpg” ></misc:Header></TD>
  </body>
</HTML>

In the code example, the property is set by the containing page. The site developer does not need to open the user control or the source file.

Copyright © 2005 Microsoft Corporation.
All rights reserved.