How do you access individual items of an Master Page
Answers were Sorted based on User's Feedback
Answer / rakesh
Suppose we have a Label(lblTest) in the MasterPage(TestMaster.master) and you want to access that in the Content page at that time u can use the following Code.
Page_Load(....)
{
Label lbl = (Label)TestMaster.FindControl("lblTest");
lbl.Text ="Accessed in ContentPage..";
}
| Is This Answer Correct ? | 6 Yes | 1 No |
Answer / vijay singh
MultiView mv =
(MultiView)Master.FindControl("Multiviewsidebar");
| Is This Answer Correct ? | 6 Yes | 4 No |
Answer / kevin m
Best not to let the content page know about a control.
Expose what is needed by public properties on the master page, makes the solution far more flexible and decoupled.
| Is This Answer Correct ? | 2 Yes | 1 No |
Answer / m.ramasubbareddy
There are so many ways to access individual items of an
Master Page
you need to typecast what control you need to find
1.TextBox textbox=(TextBox)this.findcontrol("textbox1");
2.Label labl=(Label)page.parent.fincotrol("lblname") as Label;
3.ContentPlaceholder
cph=(ContentPlaceholder)this.findcontrol("ContentPlaceholder1"
);
Label lbl=(Label)cph.findcontrol("lblname");
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / prayag t
you can also have a public property defined in master pages
to be accessed in other child pages.
| Is This Answer Correct ? | 0 Yes | 1 No |
what is profiles in asp.net
What is an Interface and What is an Abstract Class?
What method must be overridden in a custom control? a) The Paint() method b) The Control_Build() method c) The Render() method d) The default constructor
1 Answers Icertis, Microsoft, Syntax Softtech,
Explain the difference between or and orelse?
Describe the difference between inline and code behind - which is best in a loosely coupled solution Tightly coupled - INLINE
Explain the life cycle of an ASP .NET page
2 Answers HCL, Surya Software,
I have a DataGrid in which two of the columns are editable...i want to update the backend table with the newly edited data of the datagrid. How to do this please help me.
1 Answers MS Technosoft, Wipro,
How many types of session in asp.net2.0
28 Answers ABC, DOT, First Europa, HCL, iRely, TCS,
Define a multilingual website?
What are the main differences between asp and asp.net?
What is cached data phone?
What is CLS?
5 Answers IBM, PrimeLine, TCS,
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)