473,379 Members | 1,270 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Object from Master Page?

Hi all,

I have created an object within my Master Page. I would like to use this
object in my content pages. What would I need todo to achieve this?

Alternatively, what is the best way of handling a global object (in this
case, a shopping cart object).

Kind regards
Taz
Sep 16 '06 #1
5 1632
I now realise this is possible using the <%@ MasterType
VirtualPath="~/MasterPage.master" %>
declaration.

However, is it possible to set this propery from within my .cs file as
opposed to the aspx file?

Thanks for any help
Taz

"Tarun Mistry" <no****@nospam.comwrote in message
news:eD*************@TK2MSFTNGP06.phx.gbl...
Hi all,

I have created an object within my Master Page. I would like to use this
object in my content pages. What would I need todo to achieve this?

Alternatively, what is the best way of handling a global object (in this
case, a shopping cart object).

Kind regards
Taz

Sep 16 '06 #2
"Tarun Mistry" <no****@nospam.comwrote in message
news:eD*************@TK2MSFTNGP06.phx.gbl...
I have created an object within my Master Page. I would like to use this
object in my content pages. What would I need todo to achieve this?

Alternatively, what is the best way of handling a global object (in this
case, a shopping cart object).
Well, it largely depends what type of object it is and how you've created
it.

The code behind a MasterPage is a class like pretty much everything else in
..NET, so you can create properties in your MasterPage which can be
referenced just like properties of any other class can be referenced.

There are hundreds of examples of this and similar things on Google, but you
might like to have a look at this:
http://west-wind.com/weblog/posts/5160.aspx which talks about some of the
issues with what you're trying to do - the site's recommendation to install
Web Application Projects is a good one...

Specifically on shopping carts, though, I've still not found anything
simpler than generics in Session...
Sep 16 '06 #3
Specifically on shopping carts, though, I've still not found anything
simpler than generics in Session...
Hi Mark, many thanks for the reply.

I seem to now have it working, however, if I access the Master Page from
within the Page_Load of the content page, I get a null pointer exception. Is
this because the master page has not triggered its own Page_load event (this
is where my data is being set).

Please help.

Kind Regards
Taz
Sep 16 '06 #4
"Tarun Mistry" <no****@nospam.comwrote in message
news:OM**************@TK2MSFTNGP03.phx.gbl...
I seem to now have it working, however, if I access the Master Page from
within the Page_Load of the content page, I get a null pointer exception.
Is this because the master page has not triggered its own Page_load event
(this is where my data is being set).

Please help.
You can help yourself...

Set a breakpoint at the beginning of both events, and you'll soon see which
triggers first...
Sep 17 '06 #5
You can help yourself...
>
Set a breakpoint at the beginning of both events, and you'll soon see
which triggers first...
Good tip!

I come from a non IDE development background. I ought to get a handle on
these fine things that are available to me now! :)

Thanks

Taz
Sep 20 '06 #6

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

Similar topics

5
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...
8
by: ST | last post by:
Hello everyone, Can anyone help me with this error above when I debug my web app project in vstudio.net?? I can't figure it out! It was working fine for months, and now all of a sudden it's not!!...
4
by: Greg | last post by:
I'm guessing the problem I'm having has something to do with Master Pages or DetailsView because the exact same code works fine on a page without a Master Page and DetailsView controls. The...
3
by: j-in-uk | last post by:
I have 3 pages Site.master, Album.aspx and ContinentsMenu.ascx. Continents is a usercontrol placed in Albums. In Album.aspx.cs I need to access a property from the Continents usercontrol and is...
7
by: thersitz | last post by:
Hi, Very new to asp.net. Using VStudio 2005 on an XP Pro machine. Using Cassini to view. I see this error discussed all over the net but don't seem to find a way to resolve my particular...
35
by: Chris | last post by:
Hi, I tried to create a class which must change the propety 'visible' of a <linktag in the masterpage into 'false' when the user is logged. But i get the error: "Object reference not set to an...
1
by: =?Utf-8?B?RGF2ZQ==?= | last post by:
I have a master page and a content page to that master. When I try to work with them I get an inconsistent error of casting ability and it happens irregularly, which means sometimes it can work...
0
by: rsdev | last post by:
Hi, I am new to ASP.NET and I am trying to build a CMS application using theBeerHouse SK. I am adapting the Datareader to collect information from an SQL database and send it to an HtmlHeader. ...
6
by: mike.gilmore | last post by:
Hi, I'm trying to move all my custom validation code into the master page. Unfortunately anytime I use the response, request, or trace objects in any master page module (other than page_load), ...
1
by: Fresno Bob | last post by:
I have a script manager in my Master Page. I want use the Ajax history functionality. This means code in my content page needs to be called when the navigate event fires in the master. How can I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.