Click here to Skip to main content
15,921,793 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
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
Posted
Updated 8-Mar-11 19:11pm
v2
Comments
Prerak Patel 9-Mar-11 1:14am    
Share some significant code to get accurate help on the problem.

 
Share this answer
 
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...
C#
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";
 }



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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900