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)
                Panel tasksListPanel = (Panel)Master.FindControl("tasksListPanel");
                tasksListPanel.Visible = true;
                Panel tasksListPanel = (Panel)Master.FindControl("tasksListPanel");
                tasksListPanel.Visible = false;

 My problem is that if i set the ActiveTabIndex of  tabcontainer to 0 at design time, though the given code executes properly on the event, panel still remains invisible. But if i set it to 1 it remains visible for all tabs. I then copied this code to content page's load event instead of tab changed. but still the problem continued.  After lots of searching i came to know that the given code gives correct result only at first page load not on postbacks though the debugger shows the lines executing if i applied a breakpoint at the code. that's why if i set the tab index to 1 at design time it shows me the panel bcoz at the first fresh page load it executes. but for further postback it don't show the desired o/p though i can see the code executing while debugging. Can anyone tell me why this is happening? I mean when the control's properties are set in page life cycle? is it before page load? may be that's why it's useless to set the visibility of the panel in page load.

Can any one please tell me how to set a Master Page's control's  property through content page on a postback event?

Please help me. Thanks in advance. :-)


3/11/2009 10:56:30 AM 13714 articles. 0 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 2

3/11/2009 11:58:53 AM

Similar Artilces:

Label control's text doesn't appear to be set (in the page which has a user control )when trying to update the text property in the FormView's ItemUpdated event
Hi There,I have a user control which hosts a formview control, gridview control and a label control. The grid view is usedto show rows in the DB and when clicked to edit each row, a form view opens up in edit mode with that particular row info. So I have nothing in the item template.My first question it mandatory to have smth in the itemtemplate of the form view.I have controls in edititemtemplate and insertitemtemplate.When a particular row is edited, I would like to show a status msg showing that the row has been updated.For this, I use the ItemUpdated event of the formview and try ...

Master page's "Load" event is later than content page's ?
Example:1. Add a label to master page, set its "text" attribute to nothing. 2. In master page's page load event, assign "hello" to label1.text3. In content page's page load event: Response.write (   ctype(master.FindControl("label1"),label).text   )it will be nothing. 4. In content page,  add a button named button1, in button1's click event, copy the upper sentence, it will write "hello". so , master page's load event it later than content page's ?  If I need the result of master page's load ev...

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

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

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

Doing Postback from master page to page in master's content place holder(search page)
Hi, Currently I am trying to do a postback which returns results. The master page has a textfield and button and the button redirects to the search page.The search page also has a textfield and button and when the button is clicked, the query statements take the input from teh user and looks for results. Currently, A Crosspage postback of master page + other pages in content place holder ------> master page+search page in content place holder works.I am trying to do a postback which returns results in master page+search page which gets its input from the textbox of the master page ...

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

Can I hide a user control's control from the hosting page's client script?
Okay, my previous question was not unswered and I guess you can't hide a control's panel with server code then show it with client code. Now this is what I try to do: on the hosting page's onload event, call a function to hide the user control's penal. Here is the deal: the user control was looped as many times as data required. So the penals will be name mypanel1, my panel2, etc... that is not even a problem if I know if the following is true: * Do all server codes finish running before the page get sent back to the client? Say the database gave me 5 penals, I can then determine how...

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

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

Rating Control: cannot set currentrating in page's onload event if control is not initially visible
I have a page which contains a rating control which is initially hidden.  On the initial page load (!Page.PostBack) the CurrentRating property is set to 2.  When the page posts back the rating control is made visible, but CurrentRating property has no value.  It loses the value 2.  If the rating control is initially visible the CurrentRating is set properly and maintained properly across postbacks.  The same problem occurs if you include the rating control in a view that is not initially active in it's multiview.<atlastoolkit:rating id="rat...

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

Need to set properties of certain menu items from a content page for a menu that's on the master page.
I would like to set the back ground of my first three menu items to gray when the user selectst the 5, 6, or 7th item.  I can't seem to figure it out, this is what i thought would work but i guess you can only have 1 selected menu item at a time.Menu menu = Master.FindControl("Menu1") as Menu; menu.Items[1].Selected = true;menu.Items[2].Selected = true; menu.Items[3].Selected = true; Or is there a way to do it like this but just but not for all the menu items? menu.StaticMenuItemStyle.BackColor = System.Drawing.Color.Gainsboro;thanks for any help.   ...

Web resources about - How to set a Master Page's control's property through content page on a postback event? -

Resources last updated: 12/17/2015 7:10:24 PM