Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 10th, 2009, 08:47 AM
Registered User
 
Join Date: Oct 2008
Location: , , .
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default Access MasterPage control in contentpage

Hi

In my WebApplctn there is a MasterPage and a WebForm name say Default.aspx (this is inheriting MasterPage).

there is a Label control in MasterPage

i want assign a Value "XYZ" from my ContentPage (Default.aspx)

Written code

In Page_Load (Default.aspx.cs)

(Master.FindControl("Label1") as Label).Text = "XYZ";

//((Label)this.Form.Parent.FindControl("Label1")).Te xt = "XYZ";


the above lines of code throwing "object reference is not set to an instance of an object" (even the code is placed in another event like Page_LoadComplete or btn_click)

Help is appreciated

Thanks
Badrinath M
 
Old November 10th, 2009, 05:23 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Create a public property on the masterpage as string.
Then from the content page, you access that property and set it's value.
on the load of the master page, you set the label text to the public propertie's value
The Following User Says Thank You to jbenson001 For This Useful Post:
bhadrinath.medi (November 12th, 2009)




Similar Threads
Thread Thread Starter Forum Replies Last Post
Having problems with MasterPage + LoginStatus Control -Logout + Pages in a different chobo2 ASP.NET 3.5 Basics 2 March 24th, 2009 01:20 PM
ContentPage & CSS rsearing ASP.NET 2.0 Basics 0 July 6th, 2007 06:42 PM
Chane Properties of a user control from MasterPage slim182 ASP.NET 2.0 Basics 1 February 26th, 2007 09:54 PM
Contentpage stretching table cells rsearing ASP.NET 2.0 Basics 3 November 14th, 2006 10:39 PM
How to access Menu in MasterPage from Content mohan.raju ASP.NET 2.0 Professional 0 October 12th, 2006 03:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.