472,992 Members | 3,114 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,992 software developers and data experts.

Master Page properties

Hello-

I am missing something very easy here I think.

I have 3 files

test.master.vb (Master)
content.aspx.vb (content)
Control.ascx.vb (user Control)

All 3 work fine together, but I am not being able to get/set parameters
like I think I should. I think it has something to do with in the order
of the load events. Please see the <<<<<Problem areas>>>>>> in below
code.

Thanks,
Chris

----------------------------
test.master.vb
--------------------------------
Imports System.Web.Security

Namespace TEST
Partial Class Master
Inherits System.Web.UI.MasterPage

Private m_UserId As String = -1
Private m_PageTitle As String

Public Property PageTitle() As String
Get
Return m_PageTitle
End Get
Set(ByVal value As String)
m_PageTitle = value
End Set
End Property

Public Property UserId() As String
Get
Return m_UserId
End Get
Set(ByVal value As String)
m_UserId = value
End Set
End Property
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

m_UserId = 2

' set page title coming from content pages
Title.Text = "Test Site"
If m_PageTitle <> "" Then Title.Text += " - " & m_PageTitle

End Sub
End Class
End Namespace


----------------------------
content.aspx.vb
----------------------------
Imports System.Web.Security

Namespace TEST
Partial Class Brands
Inherits System.Web.UI.Page

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Master.PageTitle = testUserControl.BrandName

testUserControl.UserId = Master.UserId
''''<<<<<Master.UserId IS SET TO -1, not what the masterpage Page_Load
sets it to>>>>>>

End Sub
End Class
End Namespace


----------------------------
Control.acsx.vb
----------------------------
Namespace AVB.Controls

Partial Class SupplierCategories
Inherits System.Web.UI.UserControl

Private m_BrandName As String

Public Property BrandName() As String
Get
Return m_BrandName
End Get
Set(ByVal value As String)
m_BrandName = value
End Set
End Property
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
m_BrandName = "Title From User COntrol" ''' <<<<<NEVER
MAKES IT TO MASTER PAGE via content.aspx.vb Page_Load >>>>>>
End Sub
End Class

End Namespace

Nov 19 '05 #1
4 1526
The order of events, I suspect, is that the Page_Load for Brands fires
first, followed by Page_Load for Master, then SupplierCategories.

Your code looks as if it would break even if the order of events is
reversed - the Master class depends on the user control being
initialized first and the user control depends on the Master to be
initialized first. Was that just an experiment?

--
Scott
http://www.OdeToCode.com/blogs/scott/
On 8 Sep 2005 14:22:46 -0700, rm*****@hotmail.com wrote:
Hello-

I am missing something very easy here I think.

I have 3 files

test.master.vb (Master)
content.aspx.vb (content)
Control.ascx.vb (user Control)

All 3 work fine together, but I am not being able to get/set parameters
like I think I should. I think it has something to do with in the order
of the load events. Please see the <<<<<Problem areas>>>>>> in below
code.

Thanks,
Chris

----------------------------
test.master.vb
--------------------------------
Imports System.Web.Security

Namespace TEST
Partial Class Master
Inherits System.Web.UI.MasterPage

Private m_UserId As String = -1
Private m_PageTitle As String

Public Property PageTitle() As String
Get
Return m_PageTitle
End Get
Set(ByVal value As String)
m_PageTitle = value
End Set
End Property

Public Property UserId() As String
Get
Return m_UserId
End Get
Set(ByVal value As String)
m_UserId = value
End Set
End Property
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

m_UserId = 2

' set page title coming from content pages
Title.Text = "Test Site"
If m_PageTitle <> "" Then Title.Text += " - " & m_PageTitle

End Sub
End Class
End Namespace


----------------------------
content.aspx.vb
----------------------------
Imports System.Web.Security

Namespace TEST
Partial Class Brands
Inherits System.Web.UI.Page

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Master.PageTitle = testUserControl.BrandName

testUserControl.UserId = Master.UserId
''''<<<<<Master.UserId IS SET TO -1, not what the masterpage Page_Load
sets it to>>>>>>

End Sub
End Class
End Namespace


----------------------------
Control.acsx.vb
----------------------------
Namespace AVB.Controls

Partial Class SupplierCategories
Inherits System.Web.UI.UserControl

Private m_BrandName As String

Public Property BrandName() As String
Get
Return m_BrandName
End Get
Set(ByVal value As String)
m_BrandName = value
End Set
End Property
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
m_BrandName = "Title From User COntrol" ''' <<<<<NEVER
MAKES IT TO MASTER PAGE via content.aspx.vb Page_Load >>>>>>
End Sub
End Class

End Namespace


Nov 19 '05 #2

Scott Allen wrote:
The order of events, I suspect, is that the Page_Load for Brands fires
first, followed by Page_Load for Master, then SupplierCategories.

Your code looks as if it would break even if the order of events is
reversed - the Master class depends on the user control being
initialized first and the user control depends on the Master to be
initialized first. Was that just an experiment?

--
Scott
http://www.OdeToCode.com/blogs/scott/

I am experimenting/learning to get this working. I wonder if it is even
possible to do what I am attempting:

1. Store my authenticated userid in master and use it in the control

2. Change the page title (in master) by setting it in my control

Any suggestions would be appreciated.

Nov 19 '05 #3
I think I'd make the Page derived class responsible for those tasks.
The Page could query the usercontrol as to what the title should be,
and set the title.

I'm not sure how you are using UserID, but I don't think I'd make the
master page responsible for carrying the UserID. I'd use master pages
strictly for UI layout and keep out any other logic.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On 9 Sep 2005 06:42:02 -0700, rm*****@hotmail.com wrote:

Scott Allen wrote:
The order of events, I suspect, is that the Page_Load for Brands fires
first, followed by Page_Load for Master, then SupplierCategories.

Your code looks as if it would break even if the order of events is
reversed - the Master class depends on the user control being
initialized first and the user control depends on the Master to be
initialized first. Was that just an experiment?

--
Scott
http://www.OdeToCode.com/blogs/scott/

I am experimenting/learning to get this working. I wonder if it is even
possible to do what I am attempting:

1. Store my authenticated userid in master and use it in the control

2. Change the page title (in master) by setting it in my control

Any suggestions would be appreciated.


Nov 19 '05 #4

Scott Allen wrote:
I think I'd make the Page derived class responsible for those tasks.
The Page could query the usercontrol as to what the title should be,
and set the title.

I'm not sure how you are using UserID, but I don't think I'd make the
master page responsible for carrying the UserID. I'd use master pages
strictly for UI layout and keep out any other logic.

I agree, I created a base class to manage the userid as in :

http://aspnet.4guysfromrolla.com/articles/041305-1.aspx

Thanks for the input!

Nov 19 '05 #5

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

Similar topics

4
by: Steve Franks | last post by:
I have this cool nested master page scenario working great. However what is the correct way to be able to access a strongly typed property at the top level master from a content page that has a...
4
by: Suresh | last post by:
Is there any way to access the custom properties of a master page from the aspx form? I know the custom properties of a master page can be accessed from the aspx.cs partial class by specifying...
4
by: evantay | last post by:
I'm using ASP.NET 2.0 with VS.NET 2005. I'm trying to access properties from my master pages within a page that inherits from that master page (a child page). However the values are always null....
0
by: dixonjm | last post by:
Hi, I have a master page & various pages that will use this master page. Each content page will have a CSS & JS file which will be named the same as the content page. When I try to load the CSS...
4
by: Seth Williams | last post by:
If I have some Master Page properties, and assign them when the master page first loads, knowing that I can access these property values in the current Content pages, will these properties be...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.