Click here to Skip to main content
15,886,664 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am Using following code to check whether user has access to that particular menu
if yes I am showing in messagebox by using same code I want to show that menu on MDI form.
This is the code snippet
                while(dr1.HasRows)
                {
                    dr1.Read();
                      foreach (var item in ClassMenu.Menues)
                     {
                         if (dr1["menuname"].ToString().Equals(item.ToString()))
                        {
                            MessageBox.Show(item);
//here itself I want to enable that submenu to user instead of showing it in message box.
                        }
                    }
                }
                 DbConnect.con.Close();
                 dr1.Close();
                 dr1.Dispose();
Posted
Updated 30-Jul-14 4:33am
v2
Comments
johannesnestler 30-Jul-14 10:21am    
What does this code do? You are checking a list of "allowed" menu items - per user or what? The Problem I see is what happens if menu-names changes? I'm asking because I've done applications with authorization Ffatures in the past. Normally I would establish some kind of "rights" or "Llvels" system. So I would enable/disable based on rights... the menuitem would have it's right and if the current user has this right too, or is above some kind of "Level", it is enabled (ideal: through binding). Just my 2c - You may want to reconsider your approach.
Other from that I don't see what could be your current problem. To find the MenuItem?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900