ASP.NET 中模态弹出扩展器的替代品?
我有一个模态弹出扩展器,其中有一个用户控件,我在一个中以多种形式使用它 ASP.NET 4.0 项目。 我对它生成的 js 代码和标记中的混乱不太满意:/ 那么,有什么可以从代码隐藏轻松控制的有价值的替代方案吗:)?
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 :) ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在使用 Ajax Control Toolkit 的道路上,我建议继续使用 jQuery 或其他一些 JavaScript 框架。虽然我理解“从代码隐藏中控制它”的愿望,因为它一开始看起来更容易,但尝试将客户端功能包装在服务器端控件中通常会带来更多麻烦,而不是值得的。
即使在最简单的情况下,在 jQuery 中创建模式弹出窗口(例如)所需的 javascript 代码量也少于使用 Ajax Control Toolkit MPE。例如,我喜欢 jQuery 插件 SimpleModal。使用带有默认选项的 SimpleModal 将 div 转换为模态弹出窗口的代码如下:
然后,您可以将该函数添加到单击事件中,例如。而且它的灵活性大约提高了一千倍。
如果您只是不喜欢在标记文件中嵌入 javascript,那么从技术上讲,您仍然可以通过使用 ScriptManager 注册脚本并向控件添加事件来从代码隐藏中控制这一切。
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.
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:
Then you can just add that function to a click event, for example. And it's about a thousand times more flexible.
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.
您看过 CodePlex 上的 Ajax Control Toolkit 吗? Ajax 控件工具包 它有几个非常有用且非常容易实现的控件。该工具包包括模式弹出控件和弹出控件。在我给您的链接中,有有关如何下载和使用该工具包的所有说明。
如果您有权访问它,另一个选择是 Telerik 控件。他们的 Ajax 控件包括他们所谓的 radWindow,它也运行得很好。您可以在此处阅读相关内容。 Telerik 的缺点是它相当昂贵。
我都用过,效果都很好。
Have you looked at the Ajax Control Toolkit on CodePlex. Ajax Control Toolkit It has several very useful controls that are very easy to implement. The toolkit includes a modal popup control as well as a popup control. In the link I gave you are all the instruction on how to download and use the toolkit.
Another option if you have access to it is Telerik controls. Their Ajax controls include what they call a radWindow which also works very well. You can read about it here. The drawback to Telerik is it is quite expensive.
I have used both and they work very well.
使用 jQuery 对话框 UI,因为这可能会为您提供最佳支持的选项。它支持模态行为。
Use jQuery Dialog UI as this would likely give you the best supported option. It supports modal behavior.