在Web应用程序中动态创建菜单 [英] Creating menus dynamically in web application

查看:285
本文介绍了在Web应用程序中动态创建菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

林创造了asp.net Visual Studio 2008中的Web应用程序..
在我的应用程序,我手动创建一个菜单控制..
因为根据需要菜单的变化,我想从SQL表动态加载..
帮我与动态加载菜单控制简单的应用程序,我可以使用这些概念,制定矿山....

Im creating a web application in asp.net visual studio 2008.. in my application, i have manually created a menu control.. since, the menus changes by needs, i wish to load it dynamically from sql table.. help me with simple application which loads a menu control dynamically and i can develop mine using those concepts....

感谢ü非常

推荐答案

加载菜单的DataTable。
然后在您的网页ASCX创建一个中继器(我猜你是menur用户控件)
创建用于中继器的模板。
绑定数据表作为数据源为中继器。
和你去那里。一个简单的动态菜单。

load your menu to a datatable. then create a repeater in your ascx page (i guess your menur is a user control) create the template for the repeater. bind the datatable as the datasource for that repeater. and there you go. a simple dynamic menu.

不要忘记做你的控制缓存。或缓存数据表。所以你不会打开到数据库在每次请求一个页面上你的网站的连接

dont forget to do a cache on your control. or cache the datatable. so you wont open a connection to the database on every request for a page on your site

这里是使用一个转发器的一些例子:

here is some examples for using a repeater :

http://articles.sitepoint.com/article/asp-net-中继器控制
http://www.w3schools.com/aspnet/aspnet_repeater.asp
http://www.asp101.com/articles/john/repeater/default.asp

这篇关于在Web应用程序中动态创建菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆