TemplateControl.LoadTemplate(String) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Obtains an instance of the ITemplate interface from an external file.
public:
System::Web::UI::ITemplate ^ LoadTemplate(System::String ^ virtualPath);
public System.Web.UI.ITemplate LoadTemplate (string virtualPath);
member this.LoadTemplate : string -> System.Web.UI.ITemplate
Public Function LoadTemplate (virtualPath As String) As ITemplate
Parameters
- virtualPath
- String
The virtual path to a user control file.
Returns
An instance of the specified template.
Examples
The following code example demonstrates how to use the LoadTemplate method to add a user control as an alternating item to a DataList Web server control named DataList1
. The user control implements the ITemplate interface and is contained in a file named Newtemplate.ascx.
void Page_Load(Object sender, EventArgs e)
{
if (!IsPostBack)
{
DataList1.AlternatingItemTemplate = LoadTemplate("newtemplate.ascx");
DataList1.DataSource = CreateDataSource();
DataList1.DataBind();
}
}
Sub Page_Load(sender As [Object], e As EventArgs)
If Not IsPostBack Then
DataList1.AlternatingItemTemplate = LoadTemplate("newtemplate.ascx")
DataList1.DataSource = CreateDataSource()
DataList1.DataBind()
End If
End Sub 'Page_Load
Applies to
See also
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET