Dynamically enable menu item - (not based on roles)

Discussion in 'ASP .Net' started by Nilla, May 28, 2008.

  1. Nilla

    Nilla Guest

    Hi!

    Im trying to disable/enable menu items in my webproject depending on
    some values.
    The menu is defined in a masterpage and has a sitemap associated to
    it.
    I have written some code in mymaster.master.cs for the
    myMenu_DataBound()-method that disables the manuitems as I want to.
    protected void myMenu_DataBound(object sender, EventArgs e)
    {

    foreach (MenuItem mi in issueMenu.Items)
    {
    if ("this and that" ) //blabla.... you got the point
    mi.Enabled = true;
    else
    mi.Enabled = false;
    }
    }

    This works fine. But when the user changes some parameters in the
    site, the disabled menuitems should be enabled again - how do I make
    myMenu_DataBound to be "re-run"? (A refresh on the page will not do
    it)

    Thanks in advance!
    /Nilla
     
    Nilla, May 28, 2008
    #1
    1. Advertising

  2. Nilla

    Munna Guest

    On May 28, 4:44 pm, Nilla <> wrote:
    > Hi!
    >
    > Im trying to disable/enable menu items in my webproject depending on
    > some values.
    > The menu is defined in a masterpage and has a sitemap associated to
    > it.
    > I have written some code in mymaster.master.cs for the
    > myMenu_DataBound()-method that disables the manuitems as I want to.
    >  protected void myMenu_DataBound(object sender, EventArgs e)
    >     {
    >
    >         foreach (MenuItem mi in issueMenu.Items)
    >         {
    >             if ("this and that" )  //blabla.... you got the point
    >                 mi.Enabled = true;
    >             else
    >                 mi.Enabled = false;
    >         }
    >     }
    >
    > This works fine. But when the user changes some parameters in the
    > site, the disabled menuitems should be enabled again - how do I make
    > myMenu_DataBound to be "re-run"? (A refresh on the page will not do
    > it)
    >
    > Thanks in advance!
    > /Nilla


    Hi nilla

    There is nothing wrong with your code ... and certainly some thing
    wrong with you condition checking..
    master page's code execute first and then page's code ... so please
    check your parameter assignment code execure before your condition
    check...

    Best of luck

    Munna
    www.munna.shatkotha.com
     
    Munna, May 28, 2008
    #2
    1. Advertising

  3. Nilla

    Nilla Guest

    On 28 Maj, 14:08, Munna <> wrote:
    > On May 28, 4:44 pm, Nilla <> wrote:
    >
    >
    >
    >
    >
    > > Hi!

    >
    > > Im trying to disable/enable menu items in my webproject depending on
    > > some values.
    > > The menu is defined in a masterpage and has a sitemap associated to
    > > it.
    > > I have written some code in mymaster.master.cs for the
    > > myMenu_DataBound()-method that disables the manuitems as I want to.
    > >  protected void myMenu_DataBound(object sender, EventArgs e)
    > >     {

    >
    > >         foreach (MenuItem mi in issueMenu.Items)
    > >         {
    > >             if ("this and that" )  //blabla.... you got the point
    > >                 mi.Enabled = true;
    > >             else
    > >                 mi.Enabled = false;
    > >         }
    > >     }

    >
    > > This works fine. But when the user changes some parameters in the
    > > site, the disabled menuitems should be enabled again - how do I make
    > > myMenu_DataBound to be "re-run"? (A refresh on the page will not do
    > > it)

    >
    > > Thanks in advance!
    > > /Nilla

    >
    > Hi nilla
    >
    > There is nothing wrong with your code ... and certainly some thing
    > wrong with you condition checking..
    > master page's code execute first and then page's code ... so please
    > check your parameter assignment code execure before your condition
    > check...
    >
    > Best of luck
    >
    > Munnawww.munna.shatkotha.com- Dölj citerad text -
    >
    > - Visa citerad text -


    Did you got my reply yesterday? I accidently pressed "Answer author"
    instead of "Answer" so I cant wee my reply here...
     
    Nilla, May 29, 2008
    #3
  4. Nilla

    Nilla Guest

    On 29 Maj, 08:44, Nilla <> wrote:
    > On 28 Maj, 14:08, Munna <> wrote:
    >
    >
    >
    >
    >
    > > On May 28, 4:44 pm, Nilla <> wrote:

    >
    > > > Hi!

    >
    > > > Im trying to disable/enable menu items in my webproject depending on
    > > > some values.
    > > > The menu is defined in a masterpage and has a sitemap associated to
    > > > it.
    > > > I have written some code in mymaster.master.cs for the
    > > > myMenu_DataBound()-method that disables the manuitems as I want to.
    > > >  protected void myMenu_DataBound(object sender, EventArgs e)
    > > >     {

    >
    > > >         foreach (MenuItem mi in issueMenu.Items)
    > > >         {
    > > >             if ("this and that" )  //blabla.... you got the point
    > > >                 mi.Enabled = true;
    > > >             else
    > > >                 mi.Enabled = false;
    > > >         }
    > > >     }

    >
    > > > This works fine. But when the user changes some parameters in the
    > > > site, the disabled menuitems should be enabled again - how do I make
    > > > myMenu_DataBound to be "re-run"? (A refresh on the page will not do
    > > > it)

    >
    > > > Thanks in advance!
    > > > /Nilla

    >
    > > Hi nilla

    >
    > > There is nothing wrong with your code ... and certainly some thing
    > > wrong with you condition checking..
    > > master page's code execute first and then page's code ... so please
    > > check your parameter assignment code execure before your condition
    > > check...

    >
    > > Best of luck

    >
    > > Munnawww.munna.shatkotha.com-Dölj citerad text -

    >
    > > - Visa citerad text -

    >
    > Did you got my reply yesterday? I accidently pressed "Answer author"
    > instead of "Answer" so I cant wee my reply here...- Dölj citerad text -
    >
    > - Visa citerad text -


    :-D wee == see :)
     
    Nilla, May 29, 2008
    #4
    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. Replies:
    4
    Views:
    2,258
  2. QUASAR
    Replies:
    6
    Views:
    456
    QUASAR
    Jan 17, 2004
  3. Jéjé
    Replies:
    0
    Views:
    257
    Jéjé
    Sep 27, 2005
  4. naijacoder naijacoder

    How to create dynamic menu with user roles (Treeview menu)

    naijacoder naijacoder, Sep 27, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    376
    naijacoder naijacoder
    Sep 27, 2004
  5. beaudetious

    Hide Menu Items Based On Roles

    beaudetious, Jan 8, 2006, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    224
    sloan
    Jan 9, 2006
Loading...

Share This Page