Wednesday, April 20, 2011

Accessing the methods of a MasterPage from inside the Web Form

write this code inside child page of masterpage to access a control.

Label lblmsg;
lblmsg = (Label)Master.FindControl("lblTitle");
lblmsg.Text = "I love my india";

//---------------------------------- 


((EmpMasterPage)this.Master).SetMessage("I love my India");

here EmpMasterPage is a name of MasterPage and SetMessage is a method of that MasterPage.

No comments:

Post a Comment