欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

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

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

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

<%@ Reference Control="MyList.Ascx" %>
<%@ Page Language="C#" CodeFile="GetAscx.aspx.cs" Inherits="AdEntity_GetAscx" %>
引用,這時(shí)候在代碼頁(yè)GetAscx.aspx.cs可以動(dòng)態(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)文章

最新評(píng)論