Accessing a master page's control in a nested content Page(Urgent)

Hi all,

I have a masterpage rm_master.masterand another masterpage rm_sub.master which inherits from rm_master.master. Now I want to access a dropdownlist control in a content page which derieves from rm_select_master.

the code i used was

DropDownList DropDownList1 = (DropDownList)Master.FindControl("DropDownList1");string a;

a = DropDownList1.Text;

 

The error i got was "Object reference not set to an instance of an object".

Please help..

Thanks in advance..

Bharath

0
seebharath
11/21/2008 9:53:01 AM
asp.net.navigation-controls 13714 articles. 0 followers. Follow

5 Replies
921 Views

Similar Articles

[PageSpeed] 41

You can try Page.FindControl or use the mastertype directive


Please remember to click “Mark as Answer” so I know if my answer was good enough for you. Thanks.
0
Erwin21
11/21/2008 10:03:14 AM

Hi

Clarifying ,   The DropDownList is in the First Level master page(rm_master) and i want to read the selected item in  this dropdown in the content page derived from the nested masterpage rm_sub.master.

Thanks

0
seebharath
11/21/2008 10:40:04 AM

 expose the dropdownlist as a public property on the masterpage, then, from your page, you can do:

Page.Master.Master.DropdownlistID



Hope this helps !
Rinze Cats

---------
please select 'mark as answer' if this post helped you!
0
Rinze
11/21/2008 10:57:02 AM

hi,

how to access controls in nested masterpage check my post http://forums.asp.net/p/1330013/2670187.aspx#2670187 


Please Mark as Answer if it helps you
0
naveen
11/21/2008 1:03:30 PM

 it's better to expose it as a property


Hope this helps !
Rinze Cats

---------
please select 'mark as answer' if this post helped you!
0
Rinze
11/21/2008 1:08:05 PM
Reply:

Similar Artilces:

Content controls have to be top-level controls in a content page or a nested master page that references a master page.
Why in the world am I getting this error? The solutions I have seen either don't apply or don't work.  Here is my master page code:<%@ Master Language="C#" AutoEventWireup="false" CodeFile="TechLMSMasters/MainSide.master.cs" Inherits="MainSide" %> <%@ Register TagPrefix="usercontrol" TagName="Search" Src="~/library/uc/Search.ascx" %> <%@ Register TagPrefix="usercontrol" TagName="UserName" Src="~/library/uc/UserNameDisplay.ascx" %><!DOCTYPE html PUBLI...

ERROR Content controls have to be top-level controls in a content page or a nested master page that references a master page.
This all used to work until about 5 minutes ago. Did I change something? For some reason I am now getting this error: Content controls have to be top-level controls in a content page or a nested master page that references a master page. What I have:  I have a masterpage inside of a directory. That directory is a first level directory with its own web.config file....The whole thing is protected by the web.config file above it (in the main public directory). That main public directory has a masterpage as well. I am not currently linking the two masterpages together becuase...

Error : Content controls have to be top-level controls in a content page or a nested master page that references a master page.
when I make a directory on my root, and in that directory I put a masterpage and a web form ... I get always an error : Content controls have to be top-level controls in a content page or a nested master page that references a master page.   Does somebody know what the problem is ? Is it possible you can't set a masterpage in a directory ... ?Kind Regards,Joeri Pansaerts.From Bruges, Belgium :) i've founded ... I had to nest my masterpage ...Kind Regards,Joeri Pansaerts.From Bruges, Belgium :) Hi Joeri Pansaerts, I am receiving the same error as the one posted her...

How to set a Master Page's control's property through content page on a postback event?
Hi all, i m using a master page in my application. i have a panel on master page and a tab container with three tab panels on content page. i want to set/change  the visibility of the panel control when the tab is changed on the content page. By default the panel is invisible. To implement this i executed the following steps: 1. Set AutoPostBack of tacontainer to true 2. Wrote an event handler for ActiveTabIndexChanged event of the tab container 3 Wrote the following code on Tab changed event   if (TabContainerEmpPerformance.ActiveTabIndex == 1) { ...

Problem to use TreeView Control in a 'content page' This Error Occur "Only Content controls are allowed directly in a content page that contains Content controls."
hi I am trying to use the TreeView Control inside the content page (Page that has a master page is a content page). On compiling the project I got the following ASP.Net runtime error: "Only Content controls are allowed directly in a content page that contains Content controls."B@b@R J Issue resolved. I was putting script tag in the content page that is not allowed. when remove the script from content page problem is resolved.B@b@R J...

How can I access the property a control on a master page from the master page's code behind.
On my master page I have a label. I want to change this label's text property based on an element of the querystring. (label.text = "NewValue")All child pages using this master will display the same thing so I was trying to put the code in the master page so as not to have to duplicate it for the child pages or put it in a base class and use FindControl.Is it possible to access from a master page's codebehind the property of a server control that is placed on a master page's aspx? If so how?(I saw similar questions, but they all came from the view of a child accessing the property.)Thank you...

Need to access a Label Control on the Master Page from a user control attached to a content page
Hello all, I have a master page (say  site.master)  with a status Label in it. I have a content page ( say content.aspx)  that has a user control (say usercontrol.ascx). One of the Button Click Events in the usercontrol.ascx needs to pass on some text onto the status label on the masterpage(LabelStatusMsg) and display it. I have been able to do this directly off a content page (content.aspx) by using the following code (VB)  on the master page <%@ MasterType virtualpath="~/site.master" %> and Dim mpLabel As Label = CType(Master.FindControl("LabelStatusMsg"),...

How do i get master page's Controls value into Content page!!!
  Hi to All,   I have a Master Page that Contains 4 dropdown lists and 2 Checkboxlists(that contains lot of check box list items) and one Search Button. now i want to search according to master page's controls parameters and display it on content page.now my problem is how do i get the master page's controls(dropdown lists,Checkboxlists)  values into content page. i did use properties for that in master page and calling these properties in  content page like this: Master.master:public string RegionState { get {if (Session["regionState"] == nu...

How could a master page control call a content page's function?
Dear all: For example: 1. In master page, place a button named "button1" . 2. Add three content page, ( add some code )3. Run application, in content page 1, click button1, show "this is page1",  in content page2, click button1, show "this is page2", and so on . Besides, these code should be in every content page instead of in master page, because actually action should be very complex, master can't predict everything. Is this possible?  Thanks!  Here's a great tutorial that may get you started: Creating a Common Toolbar in ASP.NET ...

How to access a Master's page control from Default.aspx page
I have a Label control in a MasterPage.master. How can I to modify this Text propierty from Default.aspx. The master page of default.aspx is MasterPage.master. Thanks Hi, you could expose the label's text as a public property on the master page. In the webform use the @MasterType directive and you can strongly typed call the property. Take a look at this page: http://msdn2.microsoft.com/en-us/library/xxwa0ff0.aspx. Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Workaround for non working Mark as answer buttons....

passing querystring from user control to master page's content page
Hi all,        I have a master page which contains two linkbuttons. I want that when user clicks first link button then querystring value is passed to content page's Initialize culture method. how can i do this. English | Spanish < - user control link Master page contains this user control Default page's initializeCulture method need to know which link is clicked and then set culture according.  code inside initializeculute is like thisif (Request.QueryString["Culture"] == null) {Culture = "en-US"; } else {Culture =...

Accessing contnet page's control in the Javascript code of master page
Hello  I have one master page in which i put javascript code, CSS and one Content place Holder. In my content page i add two control one for Login and another for pass word and one Custom validator control. Now i want to call the Javascript code which is written in Master page as the Clinet function in my Custom Validator control to run to validate the value entered in the login and password(TextBox) control. How i do this. My content page having Server side script that i want to call to validate page at the server side. For submitting the page i use Button control and in its PostB...

Access a DropDownList Selected value in a user control from a content page(nested master page)
 Hi All,I have a DropDownList box in a user control called DDLs.ascx. i have a content page called Sample.aspx which is based on a nested master page. the master pages are called parentMP.master and childMP.master. now i am calling the user control(DDLs.ascx) in the childMP.master like below<%@ Register TagPrefix="ddls" TagName="dropdownboxes" src="~/test/DDLs.ascx" %> now as i said there are 2 Dropdownlist boxes ( ddl1 and ddl2) in this user control.what i want is to access the selected value of these dropdownboxes in the content page and pass them t...

Hook up to a control's event located on the Master Page from the Content Page PLEASE HELP
I have a master page with a button, and I what to hook the button click event on the content page I allready tried this example http://fredrik.nsquared2.com/viewpost.aspx?PostID=328&showfeedback=true but in vb it doesn't work. Thank you ALL. Master Page Code: Public Event OnbtnGrava_Click As EventHandler Protected Sub btnGrava_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGrava.Click RaiseEvent OnbtnGrava_Click(sender, e) End Sub Content Page code: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim mpButton ...

Web resources about - Accessing a master page's control in a nested content Page(Urgent) - asp.net.navigation-controls

Resources last updated: 11/30/2015 4:51:56 PM