Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Get Value Dropdownlist Page_PreInit

Reply
Thread Tools

Get Value Dropdownlist Page_PreInit

 
 
Lammert
Guest
Posts: n/a
 
      06-26-2006
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

 
Reply With Quote
 
 
 
 
Mark Rae
Guest
Posts: n/a
 
      06-26-2006
"Lammert" <> wrote in message
news: oups.com...

> 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.


 
Reply With Quote
 
 
 
 
Lammert
Guest
Posts: n/a
 
      06-26-2006

Mark Rae schreef:

> "Lammert" <> wrote in message
> news: oups.com...
>
> > 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.


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?

 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      06-26-2006
"Lammert" <> wrote in message
news: oups.com...

>> 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?


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.


 
Reply With Quote
 
Lammert
Guest
Posts: n/a
 
      06-26-2006
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:

> "Lammert" <> wrote in message
> news: oups.com...
>
> >> 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?

>
> 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.


 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      06-26-2006
"Lammert" <> wrote in message
news: oups.com...

>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?


 
Reply With Quote
 
Lammert
Guest
Posts: n/a
 
      06-26-2006
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:

> "Lammert" <> wrote in message
> news: oups.com...
>
> >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?


 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      06-26-2006
"Lammert" <> wrote in message
news: oups.com...

> 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.


 
Reply With Quote
 
Lammert
Guest
Posts: n/a
 
      06-26-2006

Mark Rae schreef:

> "Lammert" <> wrote in message
> news: oups.com...
>
> > 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.


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.

>
> 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.


 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      06-26-2006
"Lammert" <> wrote in message
news: ups.com...

> 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)


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Control is null in Page_PreInit Vin ASP .Net 9 07-14-2009 08:52 PM
Get DropDownList.SelectedValue from Page_PreInit Event Redhairs ASP .Net 19 01-22-2008 09:40 PM
Page_PreInit rn5a@rediffmail.com ASP .Net 2 09-27-2007 10:40 PM
Is there Page_PreInit, but for the entire application? Edward ASP .Net 7 10-17-2006 01:42 PM
Page_PreInit no execute in MasterPage ad ASP .Net 1 08-05-2006 03:13 PM



Advertisments