關於Web用戶控件如何讀取子控件的值
效果圖
/*用戶控件界面開始*/
<%@ Control Language=
<table width=
<tr>
<td ><DIV CLASS=
<td >
查詢
<asp:DropDownList ID=
</asp:DropDownList>
<asp:Button ID=
<asp:Label ID=
</tr>
</table>
/*用戶控件界面結束*/
/*用戶控件代碼開始*/
namespace MY
{
using System;
using System
using System
using System
using System
using System
using System
using System
using System
using System
public delegate void BOkClickHandler(object sender
//自定義枚舉
public enum EBarType { mintype =
//
public partial class SearchBar : System
{
public event BOkClickHandler BOkClick;//定義事件
public string SearchTxt//設置文本框內容
{
get { return this
set { this
}
private EBarType _BarType;
public EBarType BarType//設置顯示模式
{
get { return _BarType; }
set
{
_BarType = value;
switch (value)
{
case EBarType
showxwxx();
break;
case EBarType
showuser();
break;
default://EBarType
showmin();
break;
}
}
}
private bool _TxtVisible;
public bool TxtVisible
{
get { return _TxtVisible; }
set
{
_TxtVisible = value;
this
}
}//控制文本框是否顯示
private bool _LXVisible;
public bool LXVisible
{
get { return _LXVisible; }
set
{
_LXVisible = value;
this
}
}//控制下拉列表是否顯示
//private string _SearchLX;
public string SearchLX
{
get { return this
set
{
for (int myi =
{
if (search_lx
{
search_lx
break;
}
}
}
}//設置下拉列表的值
protected void Page_Load(object sender
{
}
#region web 窗體設計器生成的代碼
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base
}
private void InitializeComponent()
{
this
}
#endregion
protected void BOk_Click(object sender
{
// this
//this
if (BOkClick != null)
BOkClick(this
}
private void showxwxx()//新聞管理模式的界面處理
{
Label
search_txt
search_lx
search_lx
ListItem myitem = new ListItem();
myitem
myitem
search_lx
myitem = new ListItem();
myitem
myitem
search_lx
search_lx
}
private void showuser()//操作員模式的界面處理
{
Label
search_txt
search_lx
search_lx
ListItem myitem = new ListItem();
myitem
myitem
search_lx
myitem = new ListItem();
myitem
myitem
search_lx
search_lx
}
private void showmin()//缺省模式的界面處理
{
Label
search_txt
search_lx
search_lx
}
}
}
/*用戶控件代碼結束*/
/*測試頁界面開始*/
<%@ Page Language=
<%@ Register Src=
<!DOCTYPE html PUBLIC
<html xmlns=
<head runat=
<title>無標題頁</title>
<link _fcksavedurl=
<link rel=
</head>
<body>
<form id=
<div>
<uc
<asp:Label ID=
<asp:Button ID=
<asp:Button ID=
<asp:Button ID=
<asp:Button ID=
<br />
</form>
</body>
</html>
/*測試頁界面結束*/
/*測試頁代碼開始*/
using System;
using System
using System
using System
using System
using System
using System
using System
using System
using System
using MY
public partial class Control_SearchBarTest : System
{
protected void Page_Load(object sender
{
}
#region web 窗體設計器生成的代碼
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base
}
private void InitializeComponent()
{
//注冊查詢條的按鈕事件
this
}
#endregion
protected void SearchBar
{
//查詢按鈕事件
Label
}
protected void Button
{
this
}
protected void Button
{
this
}
protected void Button
{
this
}
protected void Button
{
this
}
}
/*測試頁代碼結束*/
From:http://tw.wingwit.com/Article/program/net/201311/12234.html