473,804 Members | 2,146 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 2087
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
2447
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
1760
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
6447
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
3166
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
7039
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
2119
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
3998
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
2187
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
9172
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
2718
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
9715
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
9595
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10099
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9176
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...
1
7643
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5536
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...
1
4314
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
3
3003
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.