473,399 Members | 4,192 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,399 software developers and data experts.

Unable to set Masterpage Session to ContentPage

I know this is a basic question, but I cannot find the answer.

I have a 3 LinkButtons on the masterpage that set a session variable,
this session variable does not get relayed to the content page until
there are 2 postbacks.

MasterPage:
protected void lbtn01_Click(object sender, EventArgs e)
{
Session["BOB"] = "01";
}

protected void lbtn02_Click(object sender, EventArgs e)
{
Session["BOB"] = "02";
}

protected void lbtn03_Click(object sender, EventArgs e)
{
Session["BOB"] = "03";
}

ContentPage:
if (Session["BOB"] != null)
{
lblDisplay.Text = Session["BOB"].ToString();
}
else
{
lblDisplay.Text = "HELLO WORLD";
}

I know I probably need to use Page_Init, but I am not sure how. Any
answers or ideas would be appreciated.
Thanks in advance.
-Sully
Jun 27 '08 #1
2 1832

"Sully" <to******@gmail.comwrote in message
news:d3**********************************@z72g2000 hsb.googlegroups.com...
>I know this is a basic question, but I cannot find the answer.

I have a 3 LinkButtons on the masterpage that set a session variable,
this session variable does not get relayed to the content page until
there are 2 postbacks.

MasterPage:
protected void lbtn01_Click(object sender, EventArgs e)
{
Session["BOB"] = "01";
}

protected void lbtn02_Click(object sender, EventArgs e)
{
Session["BOB"] = "02";
}

protected void lbtn03_Click(object sender, EventArgs e)
{
Session["BOB"] = "03";
}

ContentPage:
if (Session["BOB"] != null)
{
lblDisplay.Text = Session["BOB"].ToString();
}
else
{
lblDisplay.Text = "HELLO WORLD";
}

I know I probably need to use Page_Init, but I am not sure how. Any
answers or ideas would be appreciated.
It should be done on the Page_Load. A Master Page has a Page_Load just like
a non Master Web page.

You should also be posting to MS.Public.dotnet.framework.aspnet.
Jun 27 '08 #2
Mr. Arnold wrote:
It should be done on the Page_Load. A Master Page has a Page_Load just
like a non Master Web page.
Doing it in the Page_Load is too early. The click events occur after the
load event.

--
Göran Andersson
_____
http://www.guffa.com
Jun 27 '08 #3

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

Similar topics

1
by: phil1bruening | last post by:
Hi, How can I change webcontrols from a contentpage in the masterpage?
9
by: Leffe Andersson | last post by:
Hi folks! I have a MasterPage with some public methods, and I would like to call them from a (app_code) class. Is it possible to set a directive or an assembly reference to a MasterPage from a...
9
by: User | last post by:
OK, I asked in a reply, but I've wasted far too long so I'm going to put a new post out there in hopes that it will be more visible. I have a MasterPage. I want to call a method declared in that...
2
by: dawg1998 | last post by:
I have a page that creates dynamic textboxes based on the number of fields a user chooses to fill out. This process worked great when the page was standalone. However, when I move to a...
5
by: jeffmagill | last post by:
Is it possible? I haven't been able to find any information about this. Not on the web, not in books. Is it possible to call a function or subroutine which is defined in a MasterPage from it's...
3
by: musosdev | last post by:
Hi guys I'm using a MasterPage for my website rebuild (vs2005, .net2, c#). I want to be able to control the Title element, both on the MasterPage and the Content pages. For example, on each...
7
by: Bon | last post by:
Dear all I create a master page with image buttons on the left-hand side for navigation. When a user clicks the student button, the content (i.e. ContentPlaceholder) in masterpage will be...
1
by: =?Utf-8?B?Sm9obg==?= | last post by:
I have a dropdownlist in masterpage and a big table in contentpage. When ddl selection changes, I want to move a specific row of the table to the top of the contentpage. Can I do something like <a...
4
by: =?Utf-8?B?SmFwZQ==?= | last post by:
Can I refer to the controls on default.aspx from the masterpage? I have a form on the masterpage which sends information that is in a gridview in the default.aspx page.
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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...
0
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,...
0
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...
0
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...

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.