亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

ASP.NET動態(tài)加載用戶控件的實現(xiàn)方法

 更新時間:2008年10月15日 21:39:01   作者:  
動態(tài)加載用戶控件的方法,用asp.net的朋友推薦
第一步:例如用戶控件放在MyList.Ascx,然后其Control指令是:
復(fù)制代碼 代碼如下:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ViewComment.ascx.cs" Inherits="Control_ViewComment"%>

這時候已經(jīng)有了Inherits,自帶了ClassName就是其名稱,如果沒有,則必須創(chuàng)建ClassName屬性。
假設(shè)其有公共屬性ID。
第二步:在某一個ASPX文件需要動態(tài)加載的話首先使用
復(fù)制代碼 代碼如下:

<%@ Reference Control="MyList.Ascx" %>
<%@ Page Language="C#" CodeFile="GetAscx.aspx.cs" Inherits="AdEntity_GetAscx" %>
引用,這時候在代碼頁GetAscx.aspx.cs可以動態(tài)加載ASCX控件了:
Control_ViewComment ctrl = (Control_ViewComment)Page.LoadControl("~/Control/ViewComment.ascx");
ctrl.ID = Request["AdentityId"];
base.Controls.Add(ctrl);

另:
復(fù)制代碼 代碼如下:

<%@ Register Assembly="Business" Namespace="Business" TagPrefix="My" %>

完成。

相關(guān)文章

最新評論