The linked document has source code that explains how to read and write cache data which should answer your original question.
However, the design is totally up to you and really this design question cannot be answered on a forum as there are too many open questions. However, there are plenty of examples on the Internet that are just a search away.
Member
54 Points
99 Posts
Populate Menu
Jun 22, 2018 04:29 PM|csajad|LINK
hi
I have a program containing 50 pages.
I have a static menu in them.
When changing the menu, I must edit 50 pages
If I want to read and display my menu from the database
When the user is browsing between pages
cost a lot
Because each time you need to get a menu from the database
What is the quick solution to this?
All-Star
36941 Points
14914 Posts
Re: Populate Menu
Jun 22, 2018 05:20 PM|mgebhard|LINK
Cache the menu.
https://msdn.microsoft.com/en-us/library/system.runtime.caching.memorycache(v=vs.110).aspx
Member
54 Points
99 Posts
Re: Populate Menu
Jun 22, 2018 05:46 PM|csajad|LINK
Is there a sample code for its implementation?
All-Star
36941 Points
14914 Posts
Re: Populate Menu
Jun 22, 2018 06:03 PM|mgebhard|LINK
The linked document has source code that explains how to read and write cache data which should answer your original question.
However, the design is totally up to you and really this design question cannot be answered on a forum as there are too many open questions. However, there are plenty of examples on the Internet that are just a search away.
https://www.mikesdotnetting.com/article/255/entity-framework-recipe-hierarchical-data-management
https://www.mikesdotnetting.com/article/208/practical-recursion-in-asp-net-web-pages-with-webmatrix
ASP.NET has a built in menu control which you might take a look at.
https://msdn.microsoft.com/en-us/library/ecs0x9w5.aspx
https://msdn.microsoft.com/en-us/library/305w735z.aspx
All-Star
54458 Points
14121 Posts
Re: Populate Menu
Jun 23, 2018 12:57 PM|mudassarkhan|LINK
Populate the menu from database only. But lazy load it after complete page is loaded using AJAX.
This won't slow it down.
Also you can load the menu into some Generic collection or DataTable and then store in Cache. And retrieving from cache will be even more faster.
Populating Menu items from the Database in ASP.Net using C# and VB.Net
Blog: ASPSnippets | Forum: ASPForums | Company: Excelasoft
Member
54 Points
99 Posts
Re: Populate Menu
Jun 23, 2018 04:01 PM|csajad|LINK
Thank you very much for your help and advice.
I will provide more clarification for clarification
i have a static sideBar Menu that have 50 item .
thats mean i have 50 pages .
When changing the menu, I must edit 50 pages
If I want to read and display my menu from the database
When the user is browsing between pages
cost a lot
Because each time you need to get a menu from the database
What is the quick solution to this?
i want generate this menu with this structure.
asp menu has additional css class and i cant customize that to this sample well .
like this :
<ul>
<li><a class="right-align" href="#"><i class="fa fa-dashboard pink-item"></i>dashboard</a></li>
<li>
<div class="divider"></div>
</li>
<li class="no-padding">
<a class="collapsible-header right-align" href="item1.aspx">item1<i class="fa fa-edit"></i></a>
</li>
<li class="no-padding">
<a class="collapsible-header right-align" href="item2.aspx">item2<i class="fa fa-edit"></i></a>
</li>
<li class="no-padding">
<a class="collapsible-header right-align" href="item3.aspx">item3<i class="fa fa-edit"></i></a>
</li>
<li class="no-padding">
<a class="collapsible-header right-align" href="item4.aspx">item4 <i class="fa fa-edit"></i></a>
</li>
<li class="no-padding">
<a class="collapsible-header right-align" href="item5.aspx">item5<i class="fa fa-edit"></i></a>
</li>
<li>
<div class="divider"></div>
</li>
<li><a class="collapsible-header right-align" href="../Login.aspx"><i class="fa fa-sign-out pink-item"></i>exit</a></li>
</ul>
# - When users visit their user panel page.
Does page download speeds down?
Will the high number of users slow down the running of the program?
#- if i want get a menu for each user , Should I use caching again ? example (item1-10) for user 1
#- Is saving my menu in a database a good way?
#- Or is there a faster way ?
All-Star
54458 Points
14121 Posts
Re: Populate Menu
Jun 23, 2018 07:24 PM|mudassarkhan|LINK
Frankly speaking there is no Fast or Quick way.
You will have to do some work as you are using Static menu for 50 pages.
If you don't want ASP control, you can use Repeater and use your existing menu.
Blog: ASPSnippets | Forum: ASPForums | Company: Excelasoft
Member
54 Points
99 Posts
Re: Populate Menu
Jun 23, 2018 08:14 PM|csajad|LINK
Okay, thank you.
I want to use Repeater .
Each user has access to a section of the menu .
Should I do this for any user menu? (Cashing data table)
Does it occupy a lot of memory?
Where should we write this command? In
(place 1)
?Do I need to make changes to the web config too ?
All-Star
54458 Points
14121 Posts
Re: Populate Menu
Jun 24, 2018 04:55 PM|mudassarkhan|LINK
Blog: ASPSnippets | Forum: ASPForums | Company: Excelasoft