Ticket T722282
Visible to All Users

ASPxMenu - How to redirect to another page by clicking on a menu item

created 6 years ago

Good Morning,
i need to create a logout button in ASPxNavabar, but i dont find a way to call a serverside methods before ASPxNavabar redirect the user to Login page.

C#
DevExpress.Web.NavBarGroup xGroup = new DevExpress.Web.NavBarGroup("Main"); DevExpress.Web.MenuItem xItem1 = new DevExpress.Web.MenuItem("Swot", "item.Swot", "~/Images/Swot.png", "~/Swot.aspx"); xItem1.ItemStyle.Paddings.PaddingTop = 9; xItem1.ItemStyle.Paddings.PaddingRight = 22; xItem1.ItemStyle.Paddings.PaddingBottom = 8; xItem1.ItemStyle.Paddings.PaddingLeft = 19; mnuMain.Items.Add(xItem1); DevExpress.Web.MenuItem xItem2 = new DevExpress.Web.MenuItem("Pictures", "item.Pictures", "~/Images/picture.png", "~/Pictures.aspx"); xItem2.ItemStyle.Paddings.PaddingTop = 9; xItem2.ItemStyle.Paddings.PaddingRight = 22; xItem2.ItemStyle.Paddings.PaddingBottom = 8; xItem2.ItemStyle.Paddings.PaddingLeft = 19; mnuMain.Items.Add(xItem2); DevExpress.Web.MenuItem xItem3 = new DevExpress.Web.MenuItem("Promoter", "item.Promoter", "~/Images/Events.png", "~/Promoter.aspx"); xItem3.ItemStyle.Paddings.PaddingTop = 9; xItem3.ItemStyle.Paddings.PaddingRight = 22; xItem3.ItemStyle.Paddings.PaddingBottom = 8; xItem3.ItemStyle.Paddings.PaddingLeft = 19; mnuMain.Items.Add(xItem3); DevExpress.Web.MenuItem xItem4 = new DevExpress.Web.MenuItem("Esci", "item.Exit", "", ""); xItem4.ItemStyle.Paddings.PaddingTop = 16; xItem4.ItemStyle.Paddings.PaddingRight = 14; xItem4.ItemStyle.Paddings.PaddingBottom = 15; xItem4.ItemStyle.Paddings.PaddingLeft = 14; xItem4.ItemStyle.BackColor = UtilityBase.GestioneDisegno.HexToColor("#575656"); xItem4.ItemStyle.ForeColor = UtilityBase.GestioneDisegno.HexToColor("#FFF"); xItem4.ToolTip = "Exit"; mnuMain.Items.Add(xItem4);

Can you explain me a way to accomplish thi task?

Answers approved by DevExpress Support

created 6 years ago (modified 6 years ago)

I solved myself using OnItemClick event and using response.redirect to change the page.
Is that a good solution?

C#
protected void mnuMain_ItemClick(object source, DevExpress.Web.MenuItemEventArgs e) { try { if (e.Item.Name == "item.Exit") { Session["LOGGED"] = null; Response.Redirect("~/Login.aspx"); } } catch { } }
    Comments (1)
    DevExpress Support Team 6 years ago

      Hello,

      I am happy to hear that you managed to resolve the problem. Thank you for keeping me informed. Your solution is correct. Should you have additional questions, feel free to contact us.

      Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

      Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.