473,671 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

master page

i have a default.master and default.aspx
in default.aspx i would like to access a variable in default.master
pageTitle
public partial class _Default : System.Web.UI.P age
{

protected void Page_Load(objec t sender, EventArgs e)

{

//pageTitle= "frist page";

}

}

this is my default.master

public partial class Default_Master : System.Web.UI.M asterPage

{

public string pageTitle= "No title";

protected void Page_Load(objec t sender, EventArgs e)

{

}

}

default.master html

<title><% =pageTitle%></title>

by accessing default.aspx the title should say first page. but it's not
working

Howard
Dec 9 '05 #1
5 2082
Its very simple if you do this...

// content page
<%@ MasterType VirtualPath="~/Masters/YourMaster.mast er" %>

// partial class of content page
Page.Title = "Whatever";
<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee. com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/


"Howard" <ho*******@yaho o.com> wrote in message
news:OX******** ******@TK2MSFTN GP09.phx.gbl...
i have a default.master and default.aspx
in default.aspx i would like to access a variable in default.master
pageTitle
public partial class _Default : System.Web.UI.P age
{

protected void Page_Load(objec t sender, EventArgs e)

{

//pageTitle= "frist page";

}

}

this is my default.master

public partial class Default_Master : System.Web.UI.M asterPage

{

public string pageTitle= "No title";

protected void Page_Load(objec t sender, EventArgs e)

{

}

}

default.master html

<title><% =pageTitle%></title>

by accessing default.aspx the title should say first page. but it's not
working

Howard

Dec 9 '05 #2
how do i access a public variable in master from child pages? for example
in master.cs i have
public string categoryname = "";

i want to set categoryname ="new items" in default.aspx.cs
"clintonG" <cs*********@RE MOVETHISTEXTmet romilwaukee.com > wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Its very simple if you do this...

// content page
<%@ MasterType VirtualPath="~/Masters/YourMaster.mast er" %>

// partial class of content page
Page.Title = "Whatever";
<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee. com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/


"Howard" <ho*******@yaho o.com> wrote in message
news:OX******** ******@TK2MSFTN GP09.phx.gbl...
i have a default.master and default.aspx
in default.aspx i would like to access a variable in default.master
pageTitle
public partial class _Default : System.Web.UI.P age
{

protected void Page_Load(objec t sender, EventArgs e)

{

//pageTitle= "frist page";

}

}

this is my default.master

public partial class Default_Master : System.Web.UI.M asterPage

{

public string pageTitle= "No title";

protected void Page_Load(objec t sender, EventArgs e)

{

}

}

default.master html

<title><% =pageTitle%></title>

by accessing default.aspx the title should say first page. but it's not
working

Howard


Dec 9 '05 #3
Once we have strongly typed the MasterPage using MasterType we can access
its members directly.

Master.category name = "new items";

This gets a bit more complex and requires a cast when attempting to
reference controls in the MasterPage or in the ContentPlaceHol der.

Label lbl = (Label)Master.F indControl("Lab elID");

It can also require compound statements when the control is a child of
another control such as when trying to reference a TableRow that is set to
runat="server" as I've used the following example to show how such
referencing can be used to reference the row to toggle its display on and
off from the server simulating an expand/collapse event.

// Page.Controls[0].FindControl(Co ntentPlaceHolde rID).FindContro l(Control)
TableRow ctl =
(TableRow)Page. Controls[0].FindControl("C enterPanelConte nt").FindContro l("Table1").Fin dControl("R2");

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee. com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/


"Howard" <ho*******@yaho o.com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
how do i access a public variable in master from child pages? for example
in master.cs i have
public string categoryname = "";

i want to set categoryname ="new items" in default.aspx.cs
"clintonG" <cs*********@RE MOVETHISTEXTmet romilwaukee.com > wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Its very simple if you do this...

// content page
<%@ MasterType VirtualPath="~/Masters/YourMaster.mast er" %>

// partial class of content page
Page.Title = "Whatever";
<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee. com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/


"Howard" <ho*******@yaho o.com> wrote in message
news:OX******** ******@TK2MSFTN GP09.phx.gbl...
i have a default.master and default.aspx
in default.aspx i would like to access a variable in default.master
pageTitle
public partial class _Default : System.Web.UI.P age
{

protected void Page_Load(objec t sender, EventArgs e)

{

//pageTitle= "frist page";

}

}

this is my default.master

public partial class Default_Master : System.Web.UI.M asterPage

{

public string pageTitle= "No title";

protected void Page_Load(objec t sender, EventArgs e)

{

}

}

default.master html

<title><% =pageTitle%></title>

by accessing default.aspx the title should say first page. but it's not
working

Howard



Dec 10 '05 #4
thanks for your help
How do you strongly type the MasterPage using MasterType?


"clintonG" <cs*********@RE MOVETHISTEXTmet romilwaukee.com > wrote in message
news:er******** ********@TK2MSF TNGP14.phx.gbl. ..
Once we have strongly typed the MasterPage using MasterType we can access
its members directly.

Master.category name = "new items";

This gets a bit more complex and requires a cast when attempting to
reference controls in the MasterPage or in the ContentPlaceHol der.

Label lbl = (Label)Master.F indControl("Lab elID");

It can also require compound statements when the control is a child of
another control such as when trying to reference a TableRow that is set to
runat="server" as I've used the following example to show how such
referencing can be used to reference the row to toggle its display on and
off from the server simulating an expand/collapse event.

// Page.Controls[0].FindControl(Co ntentPlaceHolde rID).FindContro l(Control)
TableRow ctl =
(TableRow)Page. Controls[0].FindControl("C enterPanelConte nt").FindContro l("Table1").Fin dControl("R2");

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee. com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/


"Howard" <ho*******@yaho o.com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
how do i access a public variable in master from child pages? for example
in master.cs i have
public string categoryname = "";

i want to set categoryname ="new items" in default.aspx.cs
"clintonG" <cs*********@RE MOVETHISTEXTmet romilwaukee.com > wrote in
message news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Its very simple if you do this...

// content page
<%@ MasterType VirtualPath="~/Masters/YourMaster.mast er" %>

// partial class of content page
Page.Title = "Whatever";
<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee. com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/


"Howard" <ho*******@yaho o.com> wrote in message
news:OX******** ******@TK2MSFTN GP09.phx.gbl...
i have a default.master and default.aspx
in default.aspx i would like to access a variable in default.master
pageTitle
public partial class _Default : System.Web.UI.P age
{

protected void Page_Load(objec t sender, EventArgs e)

{

//pageTitle= "frist page";

}

}

this is my default.master

public partial class Default_Master : System.Web.UI.M asterPage

{

public string pageTitle= "No title";

protected void Page_Load(objec t sender, EventArgs e)

{

}

}

default.master html

<title><% =pageTitle%></title>

by accessing default.aspx the title should say first page. but it's not
working

Howard



Dec 10 '05 #5
Hi Howard,

Below is an example:

<%@ MasterType VirtualPath="~/MyMaster.master " %>

Regards,

Bennie Haelen


Howard wrote:
thanks for your help
How do you strongly type the MasterPage using MasterType?


"clintonG" <cs*********@RE MOVETHISTEXTmet romilwaukee.com > wrote in message
news:er******** ********@TK2MSF TNGP14.phx.gbl. ..
Once we have strongly typed the MasterPage using MasterType we can access
its members directly.

Master.catego ryname = "new items";

This gets a bit more complex and requires a cast when attempting to
reference controls in the MasterPage or in the ContentPlaceHol der.

Label lbl = (Label)Master.F indControl("Lab elID");

It can also require compound statements when the control is a child of
another control such as when trying to reference a TableRow that is set to
runat="server " as I've used the following example to show how such
referencing can be used to reference the row to toggle its display on and
off from the server simulating an expand/collapse event.

// Page.Controls[0].FindControl(Co ntentPlaceHolde rID).FindContro l(Control)
TableRow ctl =
(TableRow)Pag e.Controls[0].FindControl("C enterPanelConte nt").FindContro l("Table1").Fin dControl("R2");

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee. com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/


"Howard" <ho*******@yaho o.com> wrote in message
news:%2****** **********@TK2M SFTNGP15.phx.gb l...
how do i access a public variable in master from child pages? for example
in master.cs i have
public string categoryname = "";

i want to set categoryname ="new items" in default.aspx.cs
"clintonG" <cs*********@RE MOVETHISTEXTmet romilwaukee.com > wrote in
message news:%2******** ********@tk2msf tngp13.phx.gbl. ..

Its very simple if you do this...

// content page
<%@ MasterType VirtualPath="~/Masters/YourMaster.mast er" %>

// partial class of content page
Page.Titl e = "Whatever";
<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee. com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/


"Howard" <ho*******@yaho o.com> wrote in message
news:OX**** **********@TK2M SFTNGP09.phx.gb l...

>i have a default.master and default.aspx
>in default.aspx i would like to access a variable in default.master
>pageTitl e
>public partial class _Default : System.Web.UI.P age
>{
>
>protecte d void Page_Load(objec t sender, EventArgs e)
>
>{
>
>//pageTitle= "frist page";
>
>}
>
>}
>
>this is my default.master
>
>public partial class Default_Master : System.Web.UI.M asterPage
>
>{
>
>public string pageTitle= "No title";
>
>
>
>protecte d void Page_Load(objec t sender, EventArgs e)
>
>{
>
>}
>
>}
>
>default.ma ster html
>
><title>< % =pageTitle%></title>
>
>
>
>by accessing default.aspx the title should say first page. but it's not
>working
>
>
>
>Howard
>
>


Dec 10 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2417
by: Michael Herman \(Parallelspace\) | last post by:
1. What are some compelling solutions for using Master/Content pages with Web Pages? 2. If a content area has a web part zone with web parts, what is the user experience like when "editting" the web part page? Does it take place at the page level? ...or the content area level? 3. Where is the Web Part Manager instantiated? ...in the Master Page? ....Content Page? ...elsewhere?
2
1749
by: Jon Spivey | last post by:
Hi, Using VS 2005/VB.net. I need to add a meta description tag and change a stylesheet link from a page based on a master page. Found this article http://msdn.microsoft.com/asp.net/reference/design/default.aspx?pull=/library/en-us/dnvs05/html/masterpages.asp#masterpages_topic8 Which seems to suggest it's possible (Listing 11 half way down the page) but the method for adding a meta tag Master.Page.Header.Metadata.Add("Description",...
3
6422
by: ivanpais | last post by:
Hi, I have a Web User Control, Lets say "Foo.ascx", that contains a button "btnFoo". I have a Master Page "Bar.master", that has a label "lblBar". This label is exposed by a public property BarLabelText. I now have a contentpage "FooBar.aspx", where "Bar.master" is the master page and in the content section has the control "Foo.ascx".
17
3150
by: Rob R. Ainscough | last post by:
Again another simple concept that appears NOT to be intuitive or I'm just stupid. I've read the WROX book and the example doesn't actually show how the .master page links in the other content pages? Kinda sorta a critical point no? Am I missing something? Rob. P.S. the day I find a book that actually is useful rather than just a
2
6982
by: SR | last post by:
I have started a web site using ASP.NET 2.0. I would like to centralize all of my classes in a StyleSheet but I cannot figure out how to link the StyleSheet to a Content Page since there is no header. I tried to put the link tag in the Master page, but the classes are not recognized in the Content Page. How do I use a StyleSheet with the Content Page? TIA
0
2095
by: Managed Code | last post by:
Hello All, Here is my issue and thanks in advance for any assistance. I have a base page with a dropdownlist that fires an event with the selected index. The content page catches the event and sets a connection string to the database. The content page has a simple gridview that should show records from the selected database. Initial content page displays data from correct place. first change of dropdownlist correctly updates content...
4
3978
by: Boris Yeltsin | last post by:
OK, on my Master Page I have a control: <a id="hypTabAccount" href="#" runat="server">Account</a> Now, in the code-behind (Root.master.vb) I can refer to it simply thus: hypTabAccount.InnerText = "blah" Now, what I want is the same in a content page that uses the Master Page. I have a Master Type in my Content page:
7
2177
by: Just Me | last post by:
Hi I have a master page with a control on it, but I need to set a property of that control from the content. my master page is called Admin.Master and the class is Admin. I have tried this
6
9148
by: =?Utf-8?B?SmF5IFBvbmR5?= | last post by:
I am trying to access a Public property on a Master Page from a Base Page. On the content pages I have the MasterType Directive set up as follows: <%@ MasterType virtualpath="~/Master.master" %> On the Master Page I have a public property exposed: Public Property ErrorMessage() As String Get Return txtError.InnerText End Get
5
2708
by: =?Utf-8?B?bXVzb3NkZXY=?= | last post by:
Hi guys I'm trying to make my code as streamlined as possible, and add CSS file references dynamically when they are required, for example, if a page contains a webcontrol, then the related CSS file is added by the webcontrol. This prevents me having to remember to add the CSS file to the page if I use a certain webcontrol. I have a MasterPage with an array of StyleSheets, and a public function for
0
8476
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8914
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8820
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7433
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4224
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2810
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2051
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1809
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.