//****ascx用户控件中,定义一个要接收参数的属性
例子:
private string mBookTitle;
public string BookTite
{
get{return mBokTitle;}
set{mbookTitle=value;}
}
//****在aspx页面中调用此属性即可
protected UserControl.BookSeach mBookSeach;
//****设置传值
mBookSeach.BookTitle=txtbooktitle.value;
用户控件XXX.ascx :
<%@ Control Language="c#" %>
//html...
<script runat="server">
public string BackClo ="red"; //这里定义了一个参数
public void Page_Load()
{ }
</script>
在aspx中调用此变量,可以 :
<%@ Register TagPrefix="UserControl" TagName="Webbott" Src="XXX.ascx" %>
<html>
<body>
<form runat="server" method="post">
<UserControl:Webbott id="mybott" runat="Server" />
</form>
</body>
<script Language="c#" runat="Server">
public void Page_Load()
{
string newclo = "Black";
mybott.BackClo = newclo; //更改了ascx中的那个参数!
}
</script>
</html> |