替代模式弹出扩展在asp.net? [英] Alternatives to modal popup extender in asp.net?

查看:98
本文介绍了替代模式弹出扩展在asp.net?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有了一个用户控件中有一个模式弹出扩展,我以多种形式在使用它 ASP.NET 4.0项目。 我不是很满意,它生产的JS code和标记的混乱:/ 所以,这可以从codebehind容易控制:)任何有价值的替代方案?

I have a modal pop extender that has a user control in it, I use it in several forms in a ASP.NET 4.0 project. I am not very happy with the js code that it produces and the mess in the markup :/ So, any worthy alternatives that can be controlled from the codebehind easily :) ?

推荐答案

已经下降Ajax控件工具包的路,我会建议移动到jQuery的或其他一些JavaScript框架。虽然我理解的愿望从codebehind控制它,因为它似乎在第一容易,试图总结在服务器端控制通常是更多的麻烦比它的价值的客户端功能。

Having been down the road of Ajax Control Toolkit, I would recommend moving on to jQuery or some other javascript framework. While I understand the desire to "control it from codebehind," because it seems easier at first, trying to wrap client-side functionality in a server-side control usually is more trouble than it's worth.

即使在最简单的情况下,对在jQuery的创建模式弹出所需的javascript code(例如)的量小于用Ajax控制工具包MPE。比如,我喜欢的jQuery插件SimpleModal。在code打开一个div到使用SimpleModal使用默认选项的模式弹出是这样的:

Even in the simplest case, the the amount of javascript code needed to create a modal popup in jQuery (e.g.) is less than with Ajax Control Toolkit MPE. For example, I like the jQuery plugin SimpleModal. The code to turn a div into a modal popup using SimpleModal with default options is this:

   <script type="text/javascript">
    function showPopup() {
        $('#<%=popupDivID.ClientID %>').modal({ appendTo: '#aspnetForm' });
    }
    </script>

然后就可以在函数只是添加到单击事件,例如。它是关于一千倍更灵活。

Then you can just add that function to a click event, for example. And it's about a thousand times more flexible.

如果你不喜欢你的标记文件中嵌入的JavaScript,你仍然可以在技术上使用的ScriptManager注册脚本和事件添加到控件控制这一切从codebehind。

If you just don't like embedding javascript in your markup files, you can still technically control this all from codebehind by using ScriptManager to register the scripts and add events to controls.

这篇关于替代模式弹出扩展在asp.net?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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