用户控件(.ascx)调用网页(.aspx)的方法
2008-01-08 20:59
489 查看
首先在aspx文件中有这样一个方法等待调用:
public void SetLabel(string str)
{
this.Label1.Text = str; ;
}
然后在用户控件ascx文件中使用映射;
protected void Button1_Click(object sender, EventArgs e)
{
System.Web.UI.Page p = this.Page;
Type pageType = p.GetType();
MethodInfo mi = pageType.GetMethod("SetLabel");
mi.Invoke(p, new object[] { "Hello World !" });
}
public void SetLabel(string str)
{
this.Label1.Text = str; ;
}
然后在用户控件ascx文件中使用映射;
protected void Button1_Click(object sender, EventArgs e)
{
System.Web.UI.Page p = this.Page;
Type pageType = p.GetType();
MethodInfo mi = pageType.GetMethod("SetLabel");
mi.Invoke(p, new object[] { "Hello World !" });
}
相关文章推荐
- 用户控件(.ascx)调用网页(.aspx)的方法
- 用户控件(.ascx)与网页间(.aspx)如何传值的几种方法
- 用户控件(.ascx)与网页间(.aspx)如何传值的几种方法(持续更新)
- 用户控件(.ascx)与网页间(.aspx)传值方法
- 用户控件(.ascx)与网页间(.aspx)如何传值的几种方法
- 用户控件(.ascx)与网页间(.aspx)如何传值的几种方法
- 用户控件(.ascx)与网页间(.aspx)如何传值的几种方法
- 用户控件.ascx与网页.aspx交互的几种方法
- 用户控件(.ascx)与网页间(.aspx)如何传值的几种方法
- 用户控件(.ascx)与网页间(.aspx)如何传值的几种方法
- 用户控件(.ascx)与网页间(.aspx)传值方法[转]
- 在网页中使用.ascx用户控件的两种方法 .
- 分享实现web用户控件调用.aspx页面里的方法(从而达到访问母页面中控件的目的)
- 进入页面立即调用该页面上用户控件ascx中方法
- web用户控件调用.aspx页面里的方法
- c#的aspx页面中引用了用户控件,如何相互调用后台方法
- 点滴积累【ASP.NET】---定义一个textbox用户控件在ascx页面!在不同的aspx页面调用时动态验证
- 用户控件.ascx和网页.aspx之间的交互方式
- 用户控件(ASCX)向网页(ASPX)传值使用反射实现