Get Value Dropdownlist Page_PreInit

Discussion in 'ASP .Net' started by Lammert, Jun 26, 2006.

  1. Lammert

    Lammert Guest

    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
     
    Lammert, Jun 26, 2006
    #1
    1. Advertising

  2. Lammert

    Mark Rae Guest

    "Lammert" <> wrote in message
    news:...

    > 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.
     
    Mark Rae, Jun 26, 2006
    #2
    1. Advertising

  3. Lammert

    Lammert Guest

    Mark Rae schreef:

    > "Lammert" <> wrote in message
    > news:...
    >
    > > 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?
     
    Lammert, Jun 26, 2006
    #3
  4. Lammert

    Mark Rae Guest

    "Lammert" <> wrote in message
    news:...

    >> 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.
     
    Mark Rae, Jun 26, 2006
    #4
  5. Lammert

    Lammert Guest

    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:...
    >
    > >> 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.
     
    Lammert, Jun 26, 2006
    #5
  6. Lammert

    Mark Rae Guest

    "Lammert" <> wrote in message
    news:...

    >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?
     
    Mark Rae, Jun 26, 2006
    #6
  7. Lammert

    Lammert Guest

    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:...
    >
    > >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?
     
    Lammert, Jun 26, 2006
    #7
  8. Lammert

    Mark Rae Guest

    "Lammert" <> wrote in message
    news:...

    > 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.
     
    Mark Rae, Jun 26, 2006
    #8
  9. Lammert

    Lammert Guest

    Mark Rae schreef:

    > "Lammert" <> wrote in message
    > news:...
    >
    > > 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.
     
    Lammert, Jun 26, 2006
    #9
  10. Lammert

    Mark Rae Guest

    "Lammert" <> wrote in message
    news:...

    > 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)
     
    Mark Rae, Jun 26, 2006
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ad
    Replies:
    1
    Views:
    18,117
    =?Utf-8?B?TXVoYW1tYWQgTW9zYQ==?=
    Aug 5, 2006
  2. Edward
    Replies:
    7
    Views:
    568
    Edward
    Oct 17, 2006
  3. Page_PreInit

    , Sep 27, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    1,056
    Lloyd Sheen
    Sep 27, 2007
  4. Redhairs
    Replies:
    19
    Views:
    3,013
    Redhairs
    Jan 22, 2008
  5. Vin
    Replies:
    9
    Views:
    5,095
    nayak
    Jul 14, 2009
Loading...

Share This Page