Get Value Dropdownlist Page_PreInit

L

Lammert

Good morning,

I create an ASP.NET 2.0 web application. The situation:

1. One masterpage where the users can select an organisation in a
DropDownList.
2. Different content pages.

I will get the value of the DropDownList in the Page_PreInit event. How
can I do that? The content in the content and master pages is based on
the selected value of the DrowDownList.

Kind regards,
Lammert
 
M

Mark Rae

I create an ASP.NET 2.0 web application. The situation:

1. One masterpage where the users can select an organisation in a
DropDownList.
2. Different content pages.

I will get the value of the DropDownList in the Page_PreInit event. How
can I do that? The content in the content and master pages is based on
the selected value of the DrowDownList.

Store the selected value from the DropDownList in a Session variable.
 
L

Lammert

Mark Rae schreef:
Store the selected value from the DropDownList in a Session variable.

Hi,

When must I store the selected value from the DropDownList in a Session
variable? When I add a SelectIndex_Changed event to the DropDownList,
this event is handled after the Page_Init event. How can I do this?
 
M

Mark Rae

Hi,

When must I store the selected value from the DropDownList in a Session
variable? When I add a SelectIndex_Changed event to the DropDownList,
this event is handled after the Page_Init event. How can I do this?

When the user selects a different organisation, presumably this needs to
change the organisation for all the child pages?

If so, then the child pages need to get the organisation from the Session
variable, not the Master Page.
 
L

Lammert

I will get the value of the selected item of the DropDownList in the
Page_Init event of the Master Page, not the Page_Init event of the
content page. I have a DropDownList (AutoPostback = true), when the
user selects another item in the DropDownList i will get the selected
value in the Page_Init event of the Master Page. That's the question.

Mark Rae schreef:
 
M

Mark Rae

I will get the value of the selected item of the DropDownList in the
Page_Init event of the Master Page, not the Page_Init event of the
content page.

Hmm - even if you EnableViewState for your DropDownList, it's value might
not be available before the Page_Load event...

I have a DropDownList (AutoPostback = true), when the
user selects another item in the DropDownList i will get the selected
value in the Page_Init event of the Master Page. That's the question.

But then what? When the user selects a different organisation, what do you
want to happen next?
 
L

Lammert

The content in the content pages and master page is based on the
selected value in the DropDownList.

Example:
When the user selects another organization the master page must the
masterpage display another header and title.
The content pages must display other content for that specific
organization.


Mark Rae schreef:
 
M

Mark Rae

The content in the content pages and master page is based on the
selected value in the DropDownList.

Example:
When the user selects another organization the master page must the
masterpage display another header and title.
The content pages must display other content for that specific
organization.

I'm afraid I *really* can't see what the problem is here...

1) When the value of the DropDownList on the master page changes, it causes
a postback which updates the Session variable with the new organisation.

2) The master page amends its content according to the new value of the
Session variable, which it reads in its Page_Load method

3) The content pages DO NOT get the value of the organistion from the master
page - they get it from the Session variable, same as the master page does.
 
L

Lammert

Mark Rae schreef:
I'm afraid I *really* can't see what the problem is here...

1) When the value of the DropDownList on the master page changes, it causes
a postback which updates the Session variable with the new organisation.

This is the problem. Where must I update the Session variable. When I
update the Session variable in the event SelectedIndex_Changed from the
DropDownList the Session variable is updated after the Page_Load event
from the Master page and the Content pages is executed. So the Session
variable is too late updated. I don't know the right solution for this
problem.
 
M

Mark Rae

This is the problem. Where must I update the Session variable. When I
update the Session variable in the event SelectedIndex_Changed from the
DropDownList the Session variable is updated after the Page_Load event
from the Master page and the Content pages is executed. So the Session
variable is too late updated. I don't know the right solution for this
problem.

In the SelectedIndex_Changed method, do two things:

1) Set the Session variable to the new organisation

2) Reload the page - something like
Response.Redirect(Request.Url.AbsoluteUri)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top