Results 1 to 13 of 13

Thread: Dynamic MenuItem changes ... Postback?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Dynamic MenuItem changes ... Postback?

    I am dynamically adding and removing items from a menu control depending on what is going on in my web application. The problem is, the menu control doesn't want to refresh with the new items, I am assuming, because the page has not been posted back. The code works in a button click, but I am needing this to run in a separate event that does not do a page postback. Is there a way to force a page postback or to call some sort of refresh on the control? my ASP.NET skills are severely lacking...

  2. #2
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: Dynamic MenuItem changes ... Postback?

    If it's a data-bound item, in your codebehind just call the Menu.DataBind() function. Should refresh just the object with any new information in it without causing a complete postback.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: Dynamic MenuItem changes ... Postback?

    The menu is static, not databound. I wouldn't mind doing a complete postback (since I assume thats why the button click works), just don't know how to call one (or execute one) through code.

  4. #4
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: Dynamic MenuItem changes ... Postback?

    Check the properties of the button, see if there's an option that has something to do with postbacks. I know in the databound items the Smart Tag has an option called Enable Auto Postback, which takes care of that... not totally sure about the buttons.

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: Dynamic MenuItem changes ... Postback?

    I'm not using a button, I am wanting to do it without a button in a different sub. It works with a button, but only because the button posts back which refreshes the menu control. The menu control doesn't have any properties or methods regarding postbacks. I dont mind doing a postback like the button does but I don't know how to go about doing it. The items are what they need to be in the code, its just that the menu control isn't refreshed to reflect those changes because nothing triggers a postback in the sub I am doing it and the menu control doesn't have any sort of postback capabilities (that I see).

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: Dynamic MenuItem changes ... Postback?

    I ended up just using Hyperlink controls instead and switching out the link url's and text, which works, but I would prefer to use the menu control. If anyone knows of a way to refresh the menu control after adding/removing items, feel free to respond...

  7. #7
    Frenzied Member vbdotnetboy's Avatar
    Join Date
    Jun 2004
    Location
    Lewisburg, PA "Next year Raiders in the Super Bowl"
    Posts
    1,310

    Re: Dynamic MenuItem changes ... Postback?

    gig were you clicking the menu item which is where you would like it to do the postback... if i'm understanding correctly

    Derek - Using VS 2008 99% of the time and VS 2003 1% of the time

    Please Help Us To Save Ana

    ● Helpful Links: DNR TV | Awesome site for tips | Using ADO.NET to work with Excel | Xml Namespace 2.0 Framework Changes|Ultra High Security Password Generator | Mendhak's ADO.NET Tutorial
    ● Code Bank: Random Password Generator | Generic DbProviderFactory Access
    ● Site Work: Bottle Run Xtreme | Spaids Racing.com

    Company I work for - CSSI

    WHEN POSTING PLEASE INDICATE VERSION

    Please use vbcode tags or code tags when posting code
    [highlight=vb]ALL your code goes here[/highlight] or [code]ALL your code goes here[/code]

    If my post helped you in anyway... please be kind and give me some ratings

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: Dynamic MenuItem changes ... Postback?

    Actually no, the items are being switched out in response to some other event in the application. When that event occurs, it changes the items in the menu, and I need the menu to then refresh...

  9. #9
    Frenzied Member vbdotnetboy's Avatar
    Join Date
    Jun 2004
    Location
    Lewisburg, PA "Next year Raiders in the Super Bowl"
    Posts
    1,310

    Re: Dynamic MenuItem changes ... Postback?

    where are you performing this... or i guess i should say what event are you firing to perform this.... and i'm assuming that it's within javascript?

    Derek - Using VS 2008 99% of the time and VS 2003 1% of the time

    Please Help Us To Save Ana

    ● Helpful Links: DNR TV | Awesome site for tips | Using ADO.NET to work with Excel | Xml Namespace 2.0 Framework Changes|Ultra High Security Password Generator | Mendhak's ADO.NET Tutorial
    ● Code Bank: Random Password Generator | Generic DbProviderFactory Access
    ● Site Work: Bottle Run Xtreme | Spaids Racing.com

    Company I work for - CSSI

    WHEN POSTING PLEASE INDICATE VERSION

    Please use vbcode tags or code tags when posting code
    [highlight=vb]ALL your code goes here[/highlight] or [code]ALL your code goes here[/code]

    If my post helped you in anyway... please be kind and give me some ratings

  10. #10

    Thread Starter
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: Dynamic MenuItem changes ... Postback?

    Its just using the Items.Remove and Items.Add method of the menu control. It is a seperate control code that runs on a click (another menu at the top), which then changes the menu items on the left depending on the selection, using the .Add and .Remove method of the menu control. However, I need the control to refresh after that. The items are being added and removed successfully because the output count of the items in the control are correct, however, the control does not refresh, which I need it to do. Hence the problem. It seems that if the control was databound, it would do it automatically, but I am not using databinding.

  11. #11
    Frenzied Member vbdotnetboy's Avatar
    Join Date
    Jun 2004
    Location
    Lewisburg, PA "Next year Raiders in the Super Bowl"
    Posts
    1,310

    Re: Dynamic MenuItem changes ... Postback?

    gig hopefully this is what you're after. let me know
    Attached Files Attached Files

    Derek - Using VS 2008 99% of the time and VS 2003 1% of the time

    Please Help Us To Save Ana

    ● Helpful Links: DNR TV | Awesome site for tips | Using ADO.NET to work with Excel | Xml Namespace 2.0 Framework Changes|Ultra High Security Password Generator | Mendhak's ADO.NET Tutorial
    ● Code Bank: Random Password Generator | Generic DbProviderFactory Access
    ● Site Work: Bottle Run Xtreme | Spaids Racing.com

    Company I work for - CSSI

    WHEN POSTING PLEASE INDICATE VERSION

    Please use vbcode tags or code tags when posting code
    [highlight=vb]ALL your code goes here[/highlight] or [code]ALL your code goes here[/code]

    If my post helped you in anyway... please be kind and give me some ratings

  12. #12

    Thread Starter
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: Dynamic MenuItem changes ... Postback?

    Well it would work if the map items in the first one don't have links defined for them, but mine all refer to URL's of the page with different parameters in a query string. Once you add a URL to the items in the menu the code doesn't refresh the other menu.

  13. #13
    Frenzied Member vbdotnetboy's Avatar
    Join Date
    Jun 2004
    Location
    Lewisburg, PA "Next year Raiders in the Super Bowl"
    Posts
    1,310

    Re: Dynamic MenuItem changes ... Postback?

    what if you added a helper class that you would run upon the page load event then within the helper class wire it up so you pass in the side menu and an additional parameter that you'd get from the querystring and setup the side menu... you could also do this by way of creating a new page base class and perform this in there as well

    Derek - Using VS 2008 99% of the time and VS 2003 1% of the time

    Please Help Us To Save Ana

    ● Helpful Links: DNR TV | Awesome site for tips | Using ADO.NET to work with Excel | Xml Namespace 2.0 Framework Changes|Ultra High Security Password Generator | Mendhak's ADO.NET Tutorial
    ● Code Bank: Random Password Generator | Generic DbProviderFactory Access
    ● Site Work: Bottle Run Xtreme | Spaids Racing.com

    Company I work for - CSSI

    WHEN POSTING PLEASE INDICATE VERSION

    Please use vbcode tags or code tags when posting code
    [highlight=vb]ALL your code goes here[/highlight] or [code]ALL your code goes here[/code]

    If my post helped you in anyway... please be kind and give me some ratings

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width