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!

0
Moosdau
5/17/2007 1:37:59 AM
asp.net.navigation-controls 13714 articles. 0 followers. Follow

3 Replies
646 Views

Similar Articles

[PageSpeed] 30

 Here's a great tutorial that may get you started: Creating a Common Toolbar in ASP.NET 2.0 using MasterPage, Delegate and Events.

0
Adam
5/17/2007 12:16:36 PM

The post above me says it all but if you're looking for a nice and easier way, you might want to take a look at this article. It basically says the same thing though: have your master page raise an event and the content page catch it. This worked great for me, i have a master page that has an exit button in the header, but the code of the exit button depends on where you are in my application, so each content page can do their own exit button code.

 http://www.odetocode.com/Articles/450.aspx

look at the "Master to content page interaction" section
 

0
eniac0
5/17/2007 2:24:24 PM

To both you:

Thanks very much!

0
Moosdau
5/18/2007 2:13:28 AM
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...

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...

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...

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...

From a content page, calling function of control on master page
I've got a master page with a user control on it. The user control class has a public function. Is it possible to call this function from a content page? Also, in doing so, I need to pass a bool to said function. And if it is, how?An example would be very helpful. I'm still learning the 2.0 features. Thanks! Reference this article: Passing Information Between Content and Master Pageswww.hopeasp.net...

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...

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 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 wasDropDownList 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 You can try Page.FindControl or use the mastertype directivePlease remember to click “...

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 ...

CS0012 when referencing controls on master page's master page.
 I'm working with a content page that has a master page (we'll call it ChildMaster). ChildMaster also has a master page (ParentMaster). There is a control on ParentMaster I need to access from the content page. The code looks like this:  ControlType controlInstance = (ControlType) Master.Master.FindControl("controlID");  When I upload, I get CS0012 telling me that ParentMaster is defined in an assembly that is not referenced, and I need to add a reference to some assembly with a funky random-looking name (which changes when I reupload ParentMaster). Up t...

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...

How do I turn on and off a control of a master page from a content page or function
I have a master page with a label that has an error message that I have set to invisible.  I want to be able to turn it on or off from code in a content page or even a function in one of my classes. I would also like to have the text of the label drived from the exception of the catch of my Try statement in my function. How do I do that? I think you can use Master.FindControl("MasterControlID") and cast it to the control type.  Then you can manipulate it any way you want.C# <---> VB.Net Translator Thanks...

master page treeview control treenodechanged event called from my content page but in one case event does not called
Hi All, I have a Treeview control at my master page and from my content page I show user interface based on TreeNodeChanged, Treenodechanged event from my content page but in one case this event does not executing.  I checked using trace and debug but this event does not fired from my content page in one case only, all other case it work perfectly. // here I am triggering node changeEvent but in one case it does not even called................protected void Page_Init(object sender, EventArgs e) {Trace.Write("Content Page", "Page_Init"); myMaster = (Ma...

Web resources about - How could a master page control call a content page's function? - asp.net.navigation-controls

Resources last updated: 12/26/2015 8:44:26 PM