0

我想从子页面访问 asp.net 母版页上的跨度,所以我在该母版页上创建了一个公共属性-->

 public partial class Ui_MasterPage_UI : System.Web.UI.MasterPage
    {
        public int tax = 0;

        public string notification
        {
            set
            {
                (this.FindControl("notification") as HtmlAnchor).InnerText = value.ToString();
            }
        }
       ------------------//some code
    }

现在想从子页面访问它以将一些文本设置到该 htmlanchor 标记中,

所以我写了一些脚本-->

子页面

public partial class Ui_ProductDetails : System.Web.UI.Page
{
protected void ListView_ProductDetails_itemcommand(object sender, ListViewCommandEventArgs e)
    {
        Master.notification = "some text";            ////////showing error
 ------------------//some code       
    }
------------------//some code       
}

但是得到语法错误我认为上面的代码有问题,,,,,所以请检查一下......还有其他方法吗?thnku

4

1 回答 1

0

您需要将 Page.Master 属性转换为母版页的类型。

((Ui_MasterPage_UI)Page.Master).Notification = "some text";
于 2012-10-29T18:34:59.133 回答