从子页面更改母版页中的控件属性 [英] Change controll property in Masterpage from child page

查看:111
本文介绍了从子页面更改母版页中的控件属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在子页面的母版页的菜单控件中添加更多项目.
我在子页面的按钮单击事件上写了以下代码:

i want to add more item in a Menu control in the master page from the child page.
I have write the following code on the button click event on the child page:

Dim menu1 As New Menu
            Dim menuitem1, menuitem2 As New MenuItem
            menu1 = Master.FindControl("Menu1")
            menuitem1.Text = "product"
            menuitem2.Text = "services"
            menuitem1.NavigateUrl = "home.aspx"
            menuitem2.NavigateUrl = "logout.aspx"
            menu1.Items.Add(menuitem1)
            menu1.Items.Add(menuitem2)
            menu1.DataBind()


但是,此代码不会更改母版页.请帮助我


However this code make no changes to the master page .please help me

推荐答案

在子"页中访问母版控件的方式看起来不错.

在执行子页面的PageLoad之后,执行将进入母版页面的PageLoad.你考虑过这个吗?菜单控件是否已重新构造并绑定到母版页的PageLoad中?
The way to access the Master control in Child page looks ok.

After executing the PageLoad of child page, the execution will go into the PageLoad of Master page. have you considered this? is the menu control reformed and bind in the PageLoad of Master page?


这篇关于从子页面更改母版页中的控件属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆