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 に答える