用户控件(.ascx)调用网页(.aspx)的方法
生活随笔
收集整理的這篇文章主要介紹了
用户控件(.ascx)调用网页(.aspx)的方法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
首先在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 !" });
}
轉載于:https://www.cnblogs.com/syringa-flz/archive/2008/01/08/1030953.html
總結
以上是生活随笔為你收集整理的用户控件(.ascx)调用网页(.aspx)的方法的全部內容,希望文章能夠幫你解決所遇到的問題。