【发布时间】:2011-02-08 07:28:03
【问题描述】:
在我的 .aspx 页面中有;
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" AspCompat="True" %>
<%@ Register src="Modules/Content.ascx" tagname="Content" tagprefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:PlaceHolder ID="Modulecontainer" runat="server"></asp:PlaceHolder>
</div>
</form>
</body>
</html>
在我的 aspx.vb 中有;
Try
Dim loadmodule As UserControl
loadmodule = Me.LoadControl("~/modules/content.ascx")
Modulecontainer.Controls.Add(loadmodule)
Catch ex As Exception
Response.Write(ex.ToString & "<br />")
End Try
结果是一个空占位符并且没有错误。
非常感谢您的帮助
P.S 在 Fat_Tony 回答后我将代码更改为;
Try
Dim loadmodule As ASP.ContentModule
loadmodule = CType(LoadControl("~\Modules\Content.ascx"), ASP.ContentModule)
Modulecontainer.Controls.Add(loadmodule)
Catch ex As Exception
Response.Write(ex.ToString & "<br />")
End Try
但遗憾的是仍然没有结果。
【问题讨论】:
-
模块存在于/modules/content.ascx
标签: asp.net vb.net user-controls placeholder