asp.net 列表插件插件

杨涛的ASP.NET开源世界
(当前版本:7.5.1)
AspNetPager分页控件是应用于ASP.NET WebForm网站或应用程序中的自定义分页控件,支持默认的回发(Postback)分页和Url分页,将分页导航功能与数据显示功能完全独立开来,可以被灵活地应用于任何需要实现分页导航功能的地方...
(当前版本:3.0.1)
MvcPager分页组件是在ASP.NET MVC Web应用程序中实现分页功能的一系列扩展方法,该分页控件的最初的实现方法借鉴了网上流行的部分源代码, 经过站长不断完善和改进后推出的比较成熟而且功能强大的ASP.NET MVC分页解决方案...
(当前版本:2.0)
UrlPager是一个ASP.NET WebForm应用程序中通过url进行分页的轻量级分页控件,支持使用url路由来生成自定义的分页url。与AspNetPager不同,UrlPager不支持PostBack方式的分页及url重写...
(当前版本:1.2)
验证码技术是目前很多网站或WEB应用程序采用的一种安全防御技术,主要用于防止使用软件程序自动和批量提交表单。MvcCaptcha是应用于ASP.NET MVC Web应用程序中的验证码控件,功能强大,使用简单方便...
AspNetPager、MvcPager和UrlPager比较:
AspNetPagerMvcPagerUrlPager
.Net框架版本:&=2.0&=4.0&=3.5
支持平台:ASP.NET WebFormASP.NET MVCASP.NET WebForm
回发分页:
ASP.NET路由支持:
授权许可协议:Apache License 2.0Apache License 2.0Apache License 2.0
MvcPager 3.0.1 版发布():
修复了Ajax查询分页时,点击查询按钮没有反应或无法点击查询前所在页索引的问题;
AspNetPager 7.5.1版发布():
改为从WebControl 继承而不是 Panel;
去除属性Wrap;
枚举LayoutType添加新项Ul;
修正了ShowDisabledButtons为false时html闭合标签丢失的bug;
UrlPager 2.0版发布():
改为从 WebControl 继承而非 Panel;
实现 INamingContainer 接口;
新增 ContainerTag 属性;
新增 DisabledPagerItemTemplate 属性;
更多属性重命名及功能升级...
(C)版权所有: 陕西省延安市吴起县 杨涛(Webdiyer),保留所有权利陕ICP备号 &&未经许可严禁复制、转载及建立镜像站点 Powered by .Net Framework 4.5、、
友情链接:&&序言Bootstrap的JavaScript插件是以JQuery为基础,提供了全新的功能并且还可以扩展现有的Bootstrap组件。通过添加data attribute(data 属性)可以轻松的使用这些插件,当然你也可以使用编程方式的API来使用。为了使用Bootstrap插件,我们需要添加Bootstrap.js或者Bootstrap.min.js文件到项目中。这两个文件包含了所有的Bootstrap插件,推荐引用Bootstrap.min.js。当然你也可以包含指定的插件来定制化Bootstrap.js,已达到更好的加载速度。属性编程Bootstrap提供了完全通过HTML标记的方式来使用插件,这意味着,你可以不写任何JavaScript代码,事实上这也是Bootstrap推荐的使用方式。举个栗子,若要使Alert组件支持关闭功能,你可以通过添加data-dismiss="alert"属性到按钮(Botton)或者链接(A)元素上,如下代码所示:&div class="alert alert-danger"& &&&&&button data-dismiss="alert" class="close" type="button"&x&/button& &&&&&strong&警告&/strong&10秒敌人到达 &/div& 当然,你也可以通过编程方式的API来实现同样的功能:&div class="alert alert-danger" id="myalert"& &&&&&button data-dismiss="alert" class="close" type="button" onclick="$('#myalert').alert('close')"&x&/button& &&&&&strong&警告&/strong&10秒敌人到达 &/div& 下拉菜单(dropdown.js)使用dropdown插件(增强交互性),你可以将下拉菜单添加到绝大多数的Bootstrap组件上,比如navbar、tabs等。注:将下拉菜单触发器和下拉菜单都包裹在&.dropdown&里,或者另一个声明了&position:&的元素中。如下是一个地域的菜单,通过Razor引擎动态绑定菜单元素: &div class="form-group"& &&&&&&&&&&&&@Html.LabelFor(model =& model.TerritoryId, new { @class = "control-label col-md-2" }) &&&&&&&&&&&&@Html.HiddenFor(model =& model.TerritoryId) &&&&&&&&&&&&&div class="col-md-10"& &&&&&&&&&&&&&&&&&div id="territorydropdown" class="dropdown"& &&&&&&&&&&&&&&&&&&&&&button id="territorybutton" class="btn btn-sm btn-info" data-toggle="dropdown"&@Model.Territory.TerritoryDescription&/button& &&&&&&&&&&&&&&&&&&&&&ul id="territories" class="dropdown-menu"& &&&&&&&&&&&&&&&&&&&&&&&&@foreach (var item in ViewBag.TerritoryId) &&&&&&&&&&&&&&&&&&&&&&&&{ &&&&&&&&&&&&&&&&&&&&&&&&&&&&&li&&a href="#" tabindex="-1" data-value="@item.Value"&@item.Text&/a&&/li& &&&&&&&&&&&&&&&&&&&&&&&&} &&&&&&&&&&&&&&&&&&&&&/ul& &&&&&&&&&&&&&&&&&/div& &&&&&&&&&&&&&/div& &&&&&&&&&/div& 注意:通过添加data属性:data-toggle="dropdown" 到Button或者Anchor上,可以切换dropdown下拉菜单,增加了交互性。其中菜单的&a&元素设置tabindex=-1,这样做是为了防止元素成为tab次序的一部分。模态框(modal.js)模态框以弹出框的形式可以为用户提供信息亦或者在此之中完成表单提交功能。Bootstrap的模态框本质上有3部分组成:模态框的头、体和一组放置于底部的按钮。你可以在模态框的Body中添加任何标准的HTML标记,包括Text或者嵌入的Youtube视频。 一般来说,务必将模态框的 HTML 代码放在文档的最高层级内(也就是说,尽量作为 body 标签的直接子元素),以避免其他组件影响模态框的展现和/或功能。 如下即为一个标准的模态框,包含Header、Body、Footer: 将下面这段HTML标记放在视图的Top或者Bottom: &div class="modal fade" id="deleteConfirmationModal" tabindex="-1" role="dialog" aria-hidden="true"& &&&&&div class="modal-dialog"& &&&&&&&&&div class="modal-content"& &&&&&&&&&&&&&div class="modal-header"& &&&&&&&&&&&&&&&&&button type="button" class="close" data-dismiss="modal" aria-hidden="true"&&&/button& &&&&&&&&&&&&&&&&&h4 class="modal-title"&删除&/h4& &&&&&&&&&&&&&/div& &&&&&&&&&&&&&div class="modal-body"& &&&&&&&&&&&&&&&&&p&即将删除 '@panyName'. &/p& &&&&&&&&&&&&&&&&&p& &&&&&&&&&&&&&&&&&&&&&strong&你确定要继续吗&/strong& &&&&&&&&&&&&&&&&&/p& &&&&&&&&&&&&&&&&@using (Html.BeginForm("Delete", "Customers", FormMethod.Post, new { @id = "delete-form", role = "form" })) &&&&&&&&&&&&&&&&{ &&&&&&&&&&&&&&&&&&&&@Html.HiddenFor(m =& m.CustomerId) &&&&&&&&&&&&&&&&&&&&@Html.AntiForgeryToken() &&&&&&&&&&&&&&&&} &&&&&&&&&&&&&/div& &&&&&&&&&&&&&div class="modal-footer"& &&&&&&&&&&&&&&&&&button type="button" class="btn btn-default" onclick="$('#delete-form').submit();"&是.删除&/button& &&&&&&&&&&&&&&&&&button type="button" class="btn btn-primary" data-dismiss="modal"&取消&/button& &&&&&&&&&&&&&/div& &&&&&&&&&/div& &&&&&/div& &/div& 注意:通过在Button上添加data属性:data-dismiss="modal"可以实现对模态框的关闭,当然你也可以使用编程方式API来完成: &button type="button" class="btn btn-primary" onclick="$('#deleteConfirmationModal').modal('hide')"&取消&/button& 为了展示模态框,我们可以不写任何JavaScript代码,通过添加data-toggle="modal"属性到Button或者Anchor元素上即可,同时,为了表示展示哪一个模态框,需要通过data-target来指定模态框的Id。 &a href="#" data-toggle="modal" data-target="#deleteConfirmationModal"&Delete&/a& 同样,也可以使用编程方式API来打开一个模态框: $(document).ready(function () { $('#deleteConfirmationModal').modal('show'); });标签页(tab.js)Tabs可以使用在大的表单上,通过Tabs分割成若干部分显示局部信息,比如在Northwind数据库中存在Customer顾客信息,它包含了基本信息和地址,可以通过Tabs进行Split,如下所示:要使用Tabs也是非常简单的:首先创建标准的无序列表&ul&元素,需要为它的class设置为nav nav-tabs 或者nav nav-pills。其中&li&包含的&a&元素即为Tab元素,需要设置其data-toggle为tab或者pill属性以及点击它指向的&div&内容:&ul id="customertab" class="nav nav-tabs"& &&&&&li class="active"&&a href="#info" data-toggle="tab"&Customer Info&/a&&/li& &&&&&li&&a href="#address" data-toggle="tab"&Address&/a&&/li& &/ul& 为了设置Tabs的内容,需要创建一个父&div&元素并设置class为tab-content,在父的div容器中为每一个Tab内容创建div元素,并设置class为tab-pane和标识的Id,通过添加active来激活哪一个Tab内容的显示。 &div class="tab-content well"&
&div class="tab-pane active" id="info"&
Customer Info
&div class="tab-pane" id="address"&
Customer Address
&/div& &/div& 当然也可以通过编程方式的API来激活:$(document).ready(function () {
$('.nav-tabs a[href="#address"]').tab('show'); }); 工具提示(tooltip.js)Tooltip能为用户提供额外的信息,Boostrap Tooltip能被用在各种元素上,比如Anchor:&a data-toggle="tooltip" data-placement="top" data-original-title="这是提示内容" href="#" &工具提示?&/a&
你可以添加data-toggle="tooltip"来使用tooltip,当然你也可以设置内容的显示位置,通过添加data-placement属性来实现,Bootstrap为我们提供了4种位置:最后,通过设置data-original-title设置了需要显示的Title。注意:为了性能的考虑,Tooltip的data-api是可选的,这意味着你必须手动初始化tooltip插件:&script type="text/javascript"&
$(document).ready(function () {
$('[data-toggle="tooltip"]').tooltip();
}); &/script& 弹出框(popover.js)弹出框和Tooltip类似,都可以为用户提供额外的信息,但弹出框可以展示更多的信息,比如允许我们展示一个Header和Content,如下所示: &a data-content="关于基础建设问题需要有具体的研讨和商量...." data-placement="bottom" title="" data-toggle="popover" href="#" data-original-title="转至百度"&城市规划&/a& 和Tooltip一样,为了性能的考虑,data-api是可选的,这意味着你必须手动初始化popover插件: &script type="text/javascript"&
$(document).ready(function () {
$('[data-toggle="popover"]').popover();
}); &/script& 显示的结果如下所示: 手风琴组件(collapse.js)手风琴组件有若干panel groups组成,每一个panel group依次包含了若干header和content 元素,最常见的使用场景就是FAQ,如下所示:为了使用手风琴组件,需要对Panel Heading中的&a&设置data-toggle="collapse"和点击它展开的容器(Div)Id,具体如下所示:&div class="row"& &&&&&&&&&div class="panel-group" id="accordion"& &&&&&&&&&&&&&div class="panel panel-default"& &&&&&&&&&&&&&&&&&div class="panel-heading"& &&&&&&&&&&&&&&&&&&&&&h4 class="panel-title"& &&&&&&&&&&&&&&&&&&&&&&&&&a data-toggle="collapse" data-parent="#accordion" &&&&&&&&&&&&&&&&&&&&&&&&&&&href="#questionOne"& &&&&&&&&&&&&&&&&&&&&&&&&&&&&问题 1:什么是 Microsoft MVP 奖励? &&&&&&&&&&&&&&&&&&&&&&&&&/a& &&&&&&&&&&&&&&&&&&&&&/h4& &&&&&&&&&&&&&&&&&/div& &&&&&&&&&&&&&&&&&div id="questionOne" class="panel-collapse collapse in"& &&&&&&&&&&&&&&&&&&&&&div class="panel-body"& &&&&&&&&&&&&&&&&&&&&&&&&解答 1:Microsoft 最有价值专家 (MVP) 奖励是一项针对 Microsoft 技术社区杰出成员的年度奖励,根据 Microsoft 技术社区的成员在过去 12 个月内对 Microsoft 相关离线和在线技术社区所作贡献的大小而确定。 &&&&&&&&&&&&&&&&&&&&&/div& &&&&&&&&&&&&&&&&&/div& &&&&&&&&&&&&&/div& &&&&&&&&&&&&&div class="panel panel-default"& &&&&&&&&&&&&&&&&&div class="panel-heading"& &&&&&&&&&&&&&&&&&&&&&h4 class="panel-title"& &&&&&&&&&&&&&&&&&&&&&&&&&a data-toggle="collapse" data-parent="#accordion" &&&&&&&&&&&&&&&&&&&&&&&&&&&href="#questionTwo"& &&&&&&&&&&&&&&&&&&&&&&&&&&&&问题 2:MVP 奖励存在的意义何在? &&&&&&&&&&&&&&&&&&&&&&&&&/a& &&&&&&&&&&&&&&&&&&&&&/h4& &&&&&&&&&&&&&&&&&/div& &&&&&&&&&&&&&&&&&div id="questionTwo" class="panel-collapse collapse"& &&&&&&&&&&&&&&&&&&&&&div class="panel-body"& &&&&&&&&&&&&&&&&&&&&&&&&解答 2:我们相信,技术社区可以促进自由且客观的知识交流,因此可以构建出一个可靠、独立、真实且可使每个人获益的专业知识来源。Microsoft MVP 奖励旨在表彰那些能积极与其他技术社区成员分享自身知识的全球杰出技术社区领导者。 &&&&&&&&&&&&&&&&&&&&&/div& &&&&&&&&&&&&&&&&&/div& &&&&&&&&&&&&&/div& &&&&&&&&&/div& &&&&&/div& 旋转木马组件(carousel.js)Carousel它本质上是一个幻灯片,循环展示不同的元素,通常展示的是图片,就像旋转木马一样。你可以在许多网站上看到这种组件,要使用它也是非常方便的:将组件被包含在一个为以及为的元素中。在上述容器里添加一个有序列表,它将渲染成小圆点代表当前激活的幻灯片(显示在右下角)。紧接着,添加一个为的,这个容器包含了实际的幻灯片然后,添加左右箭头能让用户自由滑动幻灯片最后,设置滑动切换的时间间隔,通过设置来实现。当然也可以通过编程方式来实现$('#myCarousel').carousel({ interval: 10000 }) 将下面HTML标识放在View中即可:&div class="container-full"&
&div id="myCarousel" class="carousel" data-ride="carousel" data-interval="10000"&
&!-- 指示灯 --&
&ol class="carousel-indicators"&
&li data-target="#myCarousel" data-slide-to="0" class="active"&&/li&
&li data-target="#myCarousel" data-slide-to="1"&&/li&
&li data-target="#myCarousel" data-slide-to="2"&&/li&
&div class="carousel-inner"&
&div class="item active"&
&img src="@Url.Content("~/Images/slide1.jpg")" alt="First slide"&
&div class="container"&
&div class="carousel-caption"&
&h1&Unto all said together great in image.&/h1&
&p&Won't saw light to void brought fifth was brought god abundantly for you waters life seasons he after replenish beast. Creepeth beginning.&/p&
&p&&a class="btn btn-lg btn-primary" href="#" role="button"&Read more&/a&&/p&
&div class="item"&
&img src="@Url.Content("~/Images/slide2.jpg")" alt="Second slide"&
&div class="container"&
&div class="carousel-caption"&
&h1&Fowl, land him sixth moving.&/h1&
&p&Morning wherein which. Fourth man life saying own creeping. Said sixth given.&/p&
&p&&a class="btn btn-lg btn-primary" href="#" role="button"&Learn more&/a&&/p&
&div class="item"&
&img src="@Url.Content("~/Images/slide3.jpg")" alt="Third slide"&
&div class="container"&
&div class="carousel-caption"&
&h1&Far far away, behind the word mountains.&/h1&
&p&A small river named Duden flows by their place and supplies it with the necessary.&/p&
&p&&a class="btn btn-lg btn-primary" href="#" role="button"&See all&/a&&/p&
&a class="left carousel-control" href="#myCarousel" data-slide="prev"&&span class="glyphicon glyphicon-chevron-left"&&/span&&/a&
&a class="right carousel-control" href="#myCarousel" data-slide="next"&&span class="glyphicon glyphicon-chevron-right"&&/span&&/a&
&/div&&/div&展示的效果如下:小结在这篇博客中介绍了常见的Bootstrap插件,通过使用数据属性和编程方式的API来使用这些插件,更多插件访问:/javascript/ 获取。一个不错的Asp.net分页控件源码及演示
文件名称: Papercontrols_51aspx.rar , 文件大小: 511KB , 今日下载 5 次 , 累计下载 6053 次
微信扫描二维码 获得下载指导
资源简介:
一个不错的Asp.net分页控件源码及演示
一个开放源码的Asp.net分页控件,采取Url进行链接分页,支持页面跳转,利用DataGrid进行演示,当然也可以利用GridView等,MyPaper.cs为控件源码
该分页控件调用也非常简单,具体请参照Demo文件
Demo.aspx为演示页面,demo.mdb为数据库文&
【 深圳市宝安区石岩大文文网络策划部 】
电信与信息服务业务经营许可证: 法律顾问: 版权所有:
Copyright &
, All Rights Reserved.您所在的位置: &
盘点ASP.NET Ajax工具箱的10大顶级控件
盘点ASP.NET Ajax工具箱的10大顶级控件
本文将为大家介绍ASP.NET平台上的十大顶级Ajax控件,,如果你想让现有ASP.NET应用程序Ajax化,最简单的方法就是利用Ajax控件工具箱中的扩展控件。
默认情况下,.NET Framework仅自带了最基本的Ajax控件,如UpdatePanel,UpdateProgress等,如果你想让现有ASP.NET应用程序Ajax化,最简单的方法就是利用Ajax控件工具箱中的扩展控件,但Visual Studio默认并没有附带Ajax工具箱,你需要从这里下载,将其添加到Visual Studio工具箱中之后就可以在ASP.NET应用程序中使用了,注意,本文是针对.NET Framework 3.5而非4.0的。
1、自动完成扩展(AutoComplete)
这是我最喜欢的一个ASP.NET TextBox控件的扩展控件,当用户在文本框中输入字符时,它以下拉列表形式显示所有有效的值让用户选择,被选中的值自动填充到TextBox控件中,这个控件在很多ASP.NET应用程序中都得到了应用,图1显示了一个简单的示例。
498)this.width=498;' onmousewheel = 'javascript:return big(this)' style="cursor: hand" border="1" alt="1" href="/picshow/index271510.shtml" onclick="loc(this);" src="/files/uploadimg/6370.jpg" />
图 1 自动完成控件运行效果
这个控件在提供搜索功能时用得最多,它可以为用户提供搜索建议,下拉列表中的内容通过一个Web服务进行暴露。
2、动画扩展(Animation)
如果你想使用ASP.NET Ajax制作一个很花俏的网站,那你应该尝试一下动画控件,它可以节省开发人员创建动画需要的大量时间,它可以作为任何ASP.NET控件的扩展。
使用动画扩展可以轻松创建褪色,移动,改变大小和着色等许多效果,当目标控件触发下列事件时可以调用这些动画效果。
OnMouseOver
OnMouseOut
OnHoverOver
OnHoverOut
图2显示了一个DIV标签中目标控件被点击时的示例动画效果。
498)this.width=498;' onmousewheel = 'javascript:return big(this)' style="cursor: hand" border="1" alt="1" href="/picshow/index271511.shtml" onclick="loc(this);" src="/files/uploadimg/6371.jpg" />
图 2 动画控件运行效果
3、拾色器扩展(Colorpicker)
它可以作为TextBox控件的扩展控件,点击TextBox控件时,弹出颜色拾取面板,用户可以在这个窗口中进行颜色选择,如图3所示。
498)this.width=498;' onmousewheel = 'javascript:return big(this)' style="cursor: hand" border="1" alt="1" href="/picshow/index271512.shtml" onclick="loc(this);" src="/files/uploadimg/6372.jpg" />
图 3 颜色拾取控件
如果没有这个扩展控件,我不知道自己创建这样一个控件会有多大的难度,这也是我将其列在10大控件之中的原因,我也承认在ASP.NET应用程序中使用这个控件的时候很少。
4、模态弹出扩展(Modalpopup)
这是一个几乎适用于所有ASP.NET服务端容器控件的扩展,它允许你以一种平滑的方式显示服务器控件,它允许你给目标控件编写服务端代码,但客户端代码更快,用户体验更好,不过总归逃不脱要编写服务端代码,这个扩展为这种情况提供了极大的便利。
这个控件让弹出效果更平滑,更清爽,用户体验更丰富,当然你还可以提供服务端代码,图4显示了一个简单的示例。
498)this.width=498;' onmousewheel = 'javascript:return big(this)' style="cursor: hand" border="1" alt="1" href="/picshow/index271513.shtml" onclick="loc(this);" src="/files/uploadimg/6373.jpg" />
图 4 模态弹出控件示例
5、可折叠面板扩展(CollapsiblePanel)
当你的网页大部分由控件和文本内容组成时,聪明的人会将它们分组放在不同面板下,在分组顶部使用可折叠面板扩展,增加页面的层次感,这是一个ASP.NET面板的扩展控件,它非常有用,是使用最广泛的扩展控件之一,图5显示了一个简单的可折叠面板扩展示例。
498)this.width=498;' onmousewheel = 'javascript:return big(this)' style="cursor: hand" border="1" alt="1" href="/picshow/index271515.shtml" onclick="loc(this);" src="/files/uploadimg/6374.jpg" />
图 5 可折叠面板示例
6、动态填充扩展(Dynamic Populate)
这是一个非常有用功能强大的扩展控件,它为改变使用Ajax的控件中的HTML内容提供了方便,控件的HTML内容修改由TargetControlID控制,内容填充由PopulateTriggerControlId触发,HTML内容应该由Web服务提供。
当你创建一个动态网页时,这个扩展很有用,你不必一开始就加载所有内容,而是根据上下文环境进行显示和隐藏,需要时才显示动态内容,因此这样可以极大地减少页面大小,提高页面性能。
7、幻灯效果扩展(Slide Show)
这个扩展实际上是一个ASP.NET图像控件,借助它可以轻松创建出幻灯片播放效果,你需要做的是通过WebMethod提供幻灯显示的图像,它提供了下一页,上一页,播放/停止按钮和标题标签,图6显示了一个简单的幻灯显示效果示例。
498)this.width=498;' onmousewheel = 'javascript:return big(this)' style="cursor: hand" border="1" alt="1" href="/picshow/index271518.shtml" onclick="loc(this);" src="/files/uploadimg/6375.jpg" />
 图 6 幻灯显示效果扩展
  8、选项卡控件(Tabs)
严格来说,它不能算作一个扩展,因为选项卡是一个独立的控件,在开发ASP.NET网页时最让我头痛的就是创建选项卡,必须结合使用JavaScript和HTML,选项卡的优点是让页面变得更美观,让导航变得更平滑,允许.NET开发人员按一定逻辑将项目进行分组,有TabContainer的选项卡控件是一个容器,它可以包含多个TabPanels,即子选项卡,图7显示了一个简单的选项卡示例。
498)this.width=498;' onmousewheel = 'javascript:return big(this)' style="cursor: hand" border="1" alt="1" href="/picshow/index271519.shtml" onclick="loc(this);" src="/files/uploadimg/6376.jpg" />
图 7 选项卡控件示例
9、HTML编辑器控件(HTML Editor)
和选项卡控件一样,HTML编辑器也是一个独立的控件,它为最终用户提供了丰富的HTML文本编辑功能,现在你在网页上见到的HTML编辑器功能都已经非常强大了。
在后台编辑文章或来访者发表评论的地方,都可以使用HTML编辑器,当然你可以限制提交的内容,如后台编辑时通常可以是全HTML格式的内容,而评论则只能是纯文本的内容,图8显示了一个简单的HTML编辑器示例。
498)this.width=498;' onmousewheel = 'javascript:return big(this)' style="cursor: hand" border="1" alt="1" href="/picshow/index271520.shtml" onclick="loc(this);" src="/files/uploadimg/6377.jpg" />
图 8 HTML编辑器控件
10、列表搜索扩展(ListSearch)
这个扩展可以是一个列表框控件,也可以是一个下拉列表控件,用户输入字母就可以搜索列表框或下拉列表中的内容,图9显示了一个简单的列表搜索扩展示例。
498)this.width=498;' onmousewheel = 'javascript:return big(this)' style="cursor: hand" border="1" alt="1" href="/picshow/index271521.shtml" onclick="loc(this);" src="/files/uploadimg/6378.jpg" />
 图 9 列表搜索扩展
毫无疑问,Ajax控件工具箱扩展让我们的ASP.NET Web应用程序变得更丰富多彩,提供更好的用户体验,所有Ajax控件工具箱扩展中的CSS和动画都可以自定义,也就是说,你可以发扬Hack精神,将页面效果和用户体验做到极致。
【编辑推荐】
【责任编辑: TEL:(010)】
关于&&的更多文章
您是否已精通HTML、CSS、JavaScript和Ajax,而且希望不再学习全
作为移动开发者,WOT2016移动互联网技术峰会,绝对有你不得不来的理由。
互联网一大真理便是,有痛点的地方就有机会。现在最想
Eclipse 是一个开源的、可扩展的集成开发环境。平台本
这个架构是从我近期在做的一个项目中剥离出来的,这个
本书是关于如何使用已有的密码技术和算法对数据库中存储的信息进行保护的书,书中所关注的内容主要是如何设计、建立(或者挑选、
51CTO旗下网站ASP.NET(7)
先回顾一下上篇决定的做法:
1、定义程序集搜索目录(临时目录)。
2、将要使用的各种程序集(插件)复制到该目录。
3、加载临时目录中的程序集。
4、定义模板引擎的搜索路径。
5、在模板引擎的查找页面方法里,给指定插件的页面加上相应的程序集。
6、检测插件目录,有改变就自动重新加载。
--------------------------------------------我是分割线--------------------------------------------
先创建一个空的MVC4项目。
PluginMvc.Framework 类库,并创建插件接口(IPlugin)。
定义程序集搜索目录(临时目录)。
创建一个PluginLoader的静态类,做为插件的加载器,并设置好插件目录,临时目录。
临时目录就是之前在 Web.Config 中设置的程序集搜索目录。
插件目录就是存放插件的目录。
namespace PluginMvc.Framework
using System.Collections.G
using System.IO;
using System.L
using System.R
using System.Web.H
/// &summary&
/// 插件加载器。
/// &/summary&
public static class PluginLoader
/// &summary&
/// 插件目录。
/// &/summary&
private static readonly DirectoryInfo PluginF
/// &summary&
/// 插件临时目录。
/// &/summary&
private static readonly DirectoryInfo TempPluginF
/// &summary&
/// 初始化。
/// &/summary&
static PluginLoader()
PluginFolder = new DirectoryInfo(HostingEnvironment.MapPath(&~/Plugins&));
TempPluginFolder = new DirectoryInfo(HostingEnvironment.MapPath(&~/App_Data/Dependencies&));
/// &summary&
/// 加载插件。
/// &/summary&
public static IEnumerable&PluginDescriptor& Load()
List&PluginDescriptor& plugins = new List&PluginDescriptor&();
将程序集复制到临时目录。
1、先删除临时目录中的所有文件。
2、在把插件目录中的程序集复制到临时目录里。
&span style=&white-space:pre&& &/span&/// &summary&
/// 程序集复制到临时目录。
/// &/summary&
private static void FileCopyTo()
Directory.CreateDirectory(PluginFolder.FullName);
Directory.CreateDirectory(TempPluginFolder.FullName);
//清理临时文件。
foreach (var file in TempPluginFolder.GetFiles(&*.dll&, SearchOption.AllDirectories))
file.Delete();
catch (Exception)
//复制插件进临时文件夹。
foreach (var plugin in PluginFolder.GetFiles(&*.dll&, SearchOption.AllDirectories))
var di = Directory.CreateDirectory(TempPluginFolder.FullName);
File.Copy(plugin.FullName, bine(di.FullName, plugin.Name), true);
catch (Exception)
加载程序集。
1、先获取系统自动加载的程序集(即:bin 目录下的),通过反射获得其中的插件信息(程序集、插件接口的实现,对象类型,控制器类型等)。
2、使用 Assembly.LoadFile(fileName);方法,加载插件目录下的所有程序集。
&span style=&white-space:pre&& &/span&/// &summary&
/// 加载插件。
/// &/summary&
public static IEnumerable&PluginDescriptor& Load()
List&PluginDescriptor& plugins = new List&PluginDescriptor&();
//程序集复制到临时目录。
FileCopyTo();
IEnumerable&Assembly& assemblies =
//加载 bin 目录下的所有程序集。
assemblies = AppDomain.CurrentDomain.GetAssemblies();
plugins.AddRange(GetAssemblies(assemblies));
//加载临时目录下的所有程序集。
assemblies = TempPluginFolder.GetFiles(&*.dll&, SearchOption.AllDirectories).Select(x =& Assembly.LoadFile(x.FullName));
plugins.AddRange(GetAssemblies(assemblies));
创建一个插件描述类,来保存插件的信息。
从程序集中反射获得插件的各种信息,并保存在插件描述中,如:插件接口的实现,控制器的类型等。
遍历传入的程序集集合,查找出所有实现了 IPlugin 接口的程序集,并把相关的所有信息保存到 PluginDescriptor 实体里,返回所有该实体的列表。
&span style=&white-space:pre&& &/span&/// &summary&
/// 根据程序集列表获得该列表下的所有插件信息。
/// &/summary&
/// &param name=&assemblies&&程序集列表&/param&
/// &returns&插件信息集合。&/returns&
private static IEnumerable&PluginDescriptor& GetAssemblies(IEnumerable&Assembly& assemblies)
IList&PluginDescriptor& plugins = new List&PluginDescriptor&();
foreach (var assembly in assemblies)
var pluginTypes = assembly.GetTypes().Where(type =& type.GetInterface(typeof(IPlugin).Name) != null && type.IsClass && !type.IsAbstract);
foreach (var pluginType in pluginTypes)
var plugin = GetPluginInstance(pluginType, assembly);
if (plugin != null)
plugins.Add(plugin);
&span style=&white-space:pre&& &/span&/// &summary&
/// 获得插件信息。
/// &/summary&
/// &param name=&pluginType&&&/param&
/// &param name=&assembly&&&/param&
/// &returns&&/returns&
private static PluginDescriptor GetPluginInstance(Type pluginType, Assembly assembly)
if (pluginType != null)
var plugin = (IPlugin)Activator.CreateInstance(pluginType);
if (plugin != null)
return new PluginDescriptor(plugin, assembly, assembly.GetTypes());
创建一个PluginManager类,可对所有插件进行初始化、卸载与获取。
namespace PluginMvc.Framework
using System.Collections.G
using System.IO;
using System.L
using System.R
using System.Web.H
/// &summary&
/// 插件管理器。
/// &/summary&
public static class PluginManager
/// &summary&
/// 插件字典。
/// &/summary&
private readonly static IDictionary&string, PluginDescriptor& _plugins = new Dictionary&string, PluginDescriptor&();
/// &summary&
/// 初始化。
/// &/summary&
public static void Initialize()
//遍历所有插件描述。
foreach (var plugin in PluginLoader.Load())
//卸载插件。
Unload(plugin);
//初始化插件。
Initialize(plugin);
/// &summary&
/// 初始化插件。
/// &/summary&
/// &param name=&pluginDescriptor&&插件描述&/param&
private static void Initialize(PluginDescriptor pluginDescriptor)
//使用插件名称做为字典 KEY。
string key = pluginDescriptor.Plugin.N
//不存在时才进行初始化。
if (!_plugins.ContainsKey(key))
//初始化。
pluginDescriptor.Plugin.Initialize();
//增加到字典。
_plugins.Add(key, pluginDescriptor);
/// &summary&
/// 卸载。
/// &/summary&
public static void Unload()
//卸载所有插件。
foreach (var plugin in PluginLoader.Load())
plugin.Plugin.Unload();
//清空插件字典中的所有信息。
_plugins.Clear();
/// &summary&
/// 卸载。
/// &/summary&
public static void Unload(PluginDescriptor pluginDescriptor)
pluginDescriptor.Plugin.Unload();
_plugins.Remove(pluginDescriptor.Plugin.ToString());
/// &summary&
/// 获得当前系统所有插件描述。
/// &/summary&
/// &returns&&/returns&
public static IEnumerable&PluginDescriptor& GetPlugins()
return _plugins.Select(m =& m.Value).ToList();
/// &summary&
/// 根据插件名称获得插件描述。
/// &/summary&
/// &param name=&name&&插件名称。&/param&
/// &returns&插件描述。&/returns&
public static PluginDescriptor GetPlugin(string name)
return GetPlugins().SingleOrDefault(plugin =& plugin.Plugin.Name == name);
}创建一个插件控制器工厂,来获得插件程序集中的控制器类型。
对&RazorViewEngine 的&FindPartialView 方法与&FindView 方法,根据插件来把该插件相关的程序集增加到&Razor 模板的编译项里。
关键代码:
&span style=&white-space:pre&& &/span&/// &summary&
/// 给运行时编译的页面加了引用程序集。
/// &/summary&
/// &param name=&pluginName&&&/param&
private void CodeGeneration(string pluginName)
RazorBuildProvider.CodeGenerationStarted += (object sender, EventArgs e) =&
RazorBuildProvider provider = (RazorBuildProvider)
var plugin = PluginManager.GetPlugin(pluginName);
if (plugin != null)
provider.AssemblyBuilder.AddAssemblyReference(plugin.Assembly);
到现在,该方法已经初步完成,现在就是把整个插件丢到插件目录下,重启就能加载了!
现在,就给它加上自动检测功能,FileSystemWatcher 类,设置当程序集发生修改、创建、删除和重命名时,自动重新加载插件。
namespace PluginMvc.Framework
using System.IO;
using System.Web.H
/// &summary&
/// 插件检测器。
/// &/summary&
public static class PluginWatcher
/// &summary&
/// 是否启用。
/// &/summary&
private static bool _enable =
/// &summary&
/// 侦听文件系统。
/// &/summary&
private static readonly FileSystemWatcher _fileSystemWatcher = new FileSystemWatcher();
static PluginWatcher()
_fileSystemWatcher.Path = HostingEnvironment.MapPath(&~/Plugins&);
_fileSystemWatcher.Filter = &*.dll&;
_fileSystemWatcher.Changed += _fileSystemWatcher_C
_fileSystemWatcher.Created += _fileSystemWatcher_C
_fileSystemWatcher.Deleted += _fileSystemWatcher_D
_fileSystemWatcher.Renamed += _fileSystemWatcher_R
_fileSystemWatcher.IncludeSubdirectories =
/// &summary&
/// 是否启用。
/// &/summary&
public static bool Enable
_fileSystemWatcher.EnableRaisingEvents = _
/// &summary&
/// 启动。
/// &/summary&
public static void Start()
/// &summary&
/// 停止。
/// &/summary&
public static void Stop()
private static void _fileSystemWatcher_Changed(object sender, FileSystemEventArgs e)
ResetPlugin();
private static void _fileSystemWatcher_Deleted(object sender, FileSystemEventArgs e)
ResetPlugin();
private static void _fileSystemWatcher_Created(object sender, FileSystemEventArgs e)
ResetPlugin();
private static void _fileSystemWatcher_Renamed(object sender, RenamedEventArgs e)
ResetPlugin();
/// &summary&
/// 重置插件。
/// &/summary&
private static void ResetPlugin()
PluginManager.Unload();
PluginManager.Initialize();
把该方法进行注册:
&又或者可以使用&System.Web.PreApplicationStartMethod
方法来启动(推荐)。
[assembly: System.Web.PreApplicationStartMethod(typeof(PluginMvc.Framework.Bootstrapper), &Initialize&)]
namespace PluginMvc.Framework
using System.Web.M
using PluginMvc.F
using PluginMvc.Framework.M
/// &summary&
/// 引导程序。
/// &/summary&
public static class Bootstrapper
/// &summary&
/// 初始化。
/// &/summary&
public static void Initialize()
//注册插件控制器工厂。
ControllerBuilder.Current.SetControllerFactory(new PluginControllerFactory());
//注册插件模板引擎。
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new PluginRazorViewEngine());
//初始化插件。
PluginManager.Initialize();
//启动插件检测器。
PluginWatcher.Start();
到这里,框架部分已经完成了!下面说下插件的开发。
&1、创建一个空的 ASP.NET MVC 4 项目,并清理好。
&2、定义一个实现
IPlugin 接口的类。
3、完成一个简单的页面显示功能。
将该插件站点发布。
将已发布的插件包含目录一起复制到站点的插件目录下即可。
完成了,现在不但可以把插件复制到插件目录就马上能使用,要调试什么的,也可以直接启动插件 WEB 项目了,具体的完善就不多说了!
不过,目前还有个小BUG,如果目录下没有任何插件的时候,插件检测将不会启动&&。
注意!Views目录下必须要存在 Web.Config 文件,.NET 会根据该文件自动配置 cshtml 页面的基类等信息,假如没有该文件,编译页面时,会出现找不到基类错误。
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:8619次
排名:千里之外
转载:30篇
(1)(1)(2)(1)(1)(6)(2)(2)(2)(9)(9)}

我要回帖

更多关于 activex和npapi 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信