小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

asp.net 取得用戶(hù)控件里的屬性或控件

 悟靜 2012-08-23

取得用戶(hù)控件里面的控件并進(jìn)行賦值


用戶(hù)控件aspx頁(yè)代碼

復(fù)制代碼
  1. <%@ Control Language="C#" AutoEventWireup="true" CodeFile="HeadPanel.ascx.cs" Inherits="HeadPanel" %>
  2.     <asp:Label ID="lb1" runat="server" Text=""></asp:Label> //在用戶(hù)控件里定義 的兩個(gè)控件
  3. <asp:Label ID="lb2" runat="server" Text=""></asp:Label>



cs頁(yè)代碼

復(fù)制代碼
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. public partial class HeadPanel : System.Web.UI.UserControl
  8. {
  9.    public static string tmpSiteName = "用戶(hù)控件進(jìn)行賦值的標(biāo)題";
  10.    public string tmpStr="這是用戶(hù)變量";
  11.     protected void Page_Load(object sender, EventArgs e)
  12.     {
  13.     }
  14. }
  15.   





引用用戶(hù)控件aspx頁(yè)代碼


復(fù)制代碼
  1. <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
  2. <%@ Register Src="HeadPanel.ascx" TagName="RegHead" TagPrefix="uc" %>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www./TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <html xmlns="http://www./1999/xhtml">
  5. <head id="Head1" runat="server">
  6. <meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
  7. <title><%= HeadPanel.tmpSiteName%></title> //HeadPanel是用戶(hù)控件cs頁(yè)的類(lèi)名,tmpSiteName是用戶(hù)控件里的靜態(tài)變量
  8. </head>
  9. <body>
  10. </body>
  11. </html>




引用用戶(hù)控件cs頁(yè)代碼

復(fù)制代碼
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Data;
  8. using System.Text;
  9. public partial class _Default : System.Web.UI.Page
  10. {
  11.     protected void Page_Load(object sender, EventArgs e)
  12.     {
  13.         init();
  14.         loading();
  15.     }
  16.       Label lb1= (Label)ucHead.FindControl("lb1");
  17.         lb1.Text = "這是default面進(jìn)行的賦值111"; //對(duì)用戶(hù)控件里的控件進(jìn)行賦值
  18.     HeadPanel hp=new HeadPanel();  //實(shí)例用戶(hù)控件后臺(tái)類(lèi)
  19.     
  20.       Label lb2= (Label)ucHead.FindControl("lb2");
  21.         lb2.Text = "這是default面進(jìn)行的賦值"+ hp.tmpStr;  
  22.     // HeadPanel.tmpSiteName   //這個(gè)靜態(tài)變量可以直接調(diào)用
  23. }

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶(hù)發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶(hù) 評(píng)論公約

    類(lèi)似文章 更多