如何从母版页调用内容页的方法 [英] How to call a methos of content page from master page

查看:70
本文介绍了如何从母版页调用内容页的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我有一个母版页,其中包含公司列表.
及其内容页面显示所选公司的员工.
第一次页面加载时可以正常运行.
但是当我从母版页更改公司时,不会刷新员工列表.

我在内容页面的page_load中编写了根据公司绑定员工的代码.

可以请任何建议我如何做的人.

在此先感谢

Hello All

I have a master page which contain a list of companies.
and its content page which show employees of selected company.
first time when page load it woks fine.
but when i change company from master page it is not refreshing the employee list.

i wrote the code to bind employees according to company in page_load of content page.

Can please anyone sugges me how to do this.

thanks in advance

推荐答案

尝试一下

自动刷新网页 [
Try this

Auto Refresh Web Page[^]


您好


如果要将子方法分配给母版页控件,请在运行时执行.否则,主人会与孩子紧密地联系在一起.

例如,母版页有一个按钮,子页有一个文本框.单击母版页按钮时,它必须填充子文本框.

在子页面上...
Hi


If you want to assign a child method to a master page control, then do it at runtime. Otherwise the master is tightly coupled with the child.

For example the master page has a button and the child page has a text box. When the master page button click then it has to populate the child text box.

at the child page...
protected void Page_Load(object sender, EventArgs e)
 {
     Button button1 = (Button)this.Master.FindControl("Button1");
     button1.Click += new EventHandler(button1_Click);
 }
 protected void button1_Click(object sender, EventArgs e)
 {
     TextBox1.Text = "I am calling this from Master";
 }




在此,母版页在设计时不知道必须调用哪种方法.因此,它与子页面没有紧密耦合.当子页面正在加载时,您将告诉母版页控件执行此操作".这样,您可以使用任何可以绑定到主控件的子控件.

涉及的步骤.

1)使用Master.FindControl方法找到主控件
2)分配一个出现在内容页面中的事件处理程序(委托).

希望对您有帮助




Here the master page doesn''t know at design time which method has to call. So it is not tightly coupled to a child page. When the child page is loading you are telling a master page control ''do this''. In that way you can use any child can bind to master control.

Steps involved.

1) Find the master control using Master.FindControl method
2) Assign an event handler( a delegate) which is present in the content page.

Hope this helps


这篇关于如何从母版页调用内容页的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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