ASP.NET 模态弹出窗口,完全来自代码隐藏?
我想做的是创建一些可重用的代码,可以通过 javascript 或使用 ajaxcontrol 工具包编写模式弹出窗口,所有这些代码都来自后面的代码。
该模式将是一种登录弹出窗口,用于控制对网站更受限制的区域的访问,允许某些用户重新登录以获得更高的访问权限。
我正在考虑做一个用户控件,但我预见到在传递所有适当的信息而不完全是虚假的情况下会出现一些问题。
如果有人有任何好的链接或建议,我们将不胜感激!
谢谢!
编辑:我知道如何使用 ajax 控制工具包及其控件,并且我知道如何制作登录屏幕,我问如何完全从独立于其实现的类后面的代码中执行此操作
What I am trying to do is create a bit of reusable code that can write a modal popup, either through javascript or using the ajaxcontrol toolkit all from the code behind.
The modal would be a sort of login pop up for controlling access to more restricted areas of the website allowing certain users to re-credential in for higher access.
I was thinking of doing a user control but I forsee some problems with passing all of the appropriate information along without it being completely hoaky.
If anyone has any good links or advice for doing so it would be greatly appreciated!
Thanks!
EDIT: I know how to use the ajax control toolkit and its controls, and I know how to make login screens, I'm asking how to do this entirely from the code behind from a class that would be independent of its implementation
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
像ajax控件工具包一样编写一个服务器控件或一个asp.net 扩展器控件。
您能做的最好的事情就是从 CodePlex 下载 AjaxControlToolkit 的源代码并探索其中 ModalPopup 的来源。
Write a server control or an asp.net extender control like ajax control toolkit does.
The best you can do is download the source of AjaxControlToolkit from CodePlex and explore the source of ModalPopup within that.
您可以做的另一件事就是简单地调用 popupExtender 来从代码隐藏文件中显示。
正如我们所知,扩展器必须以某种方式链接到目标控件,只需添加一个虚拟控件作为隐藏文本框(实际上是为了隐藏控件,请从 asp 文件中执行此操作,因为 style="display:none" 不是来自控件属性(visible=false),否则它将无法工作),然后只需从扩展器后面的代码中调用,如下所示:
DummyTextBox_ModalPopupExtender.Show();
您可以在 page_load 中或使用任何其他触发器调用它。
客户端不需要 JavaScript,只需服务器端。
Xds。
Another thing you can do is just simply call the popupExtender to show from the code behind file.
As we know the extender has to be somehow linked to a target control, just add a dummy control as a hidden textbox (actually to hide the control, do it from the asp file, as style="display:none" not from the control properties (visible=false) otherwise it won't work), and then just call from the code behind the extender like this:
DummyTextBox_ModalPopupExtender.Show();
You can call it in the page_load or with anyother trigger.
No need javascript neither client side, just, server side.
Xds.
有一个 使用 asp.net 上的 ajaxtoolkit 的示例模式弹出窗口
There's a sample modal popup using the ajaxtoolkit on asp.net
Ajax控件工具包中的modalpopupextender很容易使用,而且它有一个服务器端或客户端方法来显示弹出窗口(在过去的版本中,我在服务器端方法上遇到了麻烦,但在当前版本中可能已经解决了) )。
您可以将 modalpopupextender 放入母版页中,并在母版页中创建一个 JS 方法,您可以调用该方法来调用模态弹出扩展器,例如:
function showPopup() {
var modal = $find("<%= mpe1.ClientID %>");
模态.show();
弹出
窗口的内容可以通过 javascript 替换,因为您可以控制该内容。
The modalpopupextender in the Ajax control toolkit is easy to use, plus it has a server or client side method for showing the popup (in past versions, I had trouble with the server-side method, but it may have been resolved in the current version).
You could put the modalpopupextender inside the master page, and create a JS method in the master page you can call to invoke the modal popup extender, like:
function showPopup() {
var modal = $find("<%= mpe1.ClientID %>");
modal.show();
}
The contents of the popup can be replaced via javascript, as you control that content.
将
BehaviorID="my_cool_id"
添加到您的 modalpopup 扩展程序中,并将其添加到任何服务器函数中Add
BehaviorID="my_cool_id"
to your modalpopup extender and add this to any server function