web页面中给用户控件传递参数

论坛 期权论坛 脚本     
匿名技术用户   2021-1-4 01:52   11   0
在用户控件中的cs代码中写一个公共变量或者属性,然后在页面中给其赋值就可以了!


下面的例子就充分说明了整个问题:
用户控件的cs代码:

protected void Page_Load(object sender, EventArgs e)
{
}
private string _strPath = "";
public string strPath
{
get { return _strPath; }
set { _strPath = value; }
}
用户控件的ascx文件没有什么特别要说的.

web页面的cs代码:
strPath=strPath.Substring(3);
this.mp3player.strPath = strPath;

其中mp3Player就是页面中分配给用户控件的ID
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP