2012-10-29 91 views
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  
} 

但得到的语法错误 我认为上面的代码中有一些问题,,,,,所以PLZ审查它...... 是否有任何其他方式来做到这一点??? thnku

+0

请添加你所得到的错误消息。 – Joe

回答

0

添加到ID为 “通知” 您的HtmlAnchor属性RUNAT = “服务器” 和的ClientIDMode = “静态” 可以使代码:

(Master.FindControl("notification") as HtmlAnchor).InnerText = "whatever" 

工作在每个子页...

编辑:我想说的是,你不需要公共方法...

相关问题