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 |
Differences between session state and Application state?
what is caching
Can we use the java script code in .Net Code behind?
about view state and how validation controls will be executed on client and server
How you will handle session when deploying application in more than a server? Describe session handling in a webfarm, how does it work and what are the limits?
Why does my asp.net file have multiple tag with runat=server?
What are HTTP handlers in ASP.NET?
Explain difference betn dataset and recordset?
How to implement caching?
How to use DevExpress controls
What are the server control tags in asp.net.?
Explain the difference between asp and asp.net?