ASP.NET 模态弹出窗口,完全来自代码隐藏?

发布于 2024-08-17 03:39:22 字数 319 浏览 4 评论 0原文

我想做的是创建一些可重用的代码,可以通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

蓝海 2024-08-24 03:39:22

像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.

蔚蓝源自深海 2024-08-24 03:39:22

您可以做的另一件事就是简单地调用 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.

梦晓ヶ微光ヅ倾城 2024-08-24 03:39:22

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.

清君侧 2024-08-24 03:39:22

BehaviorID="my_cool_id" 添加到您的 modalpopup 扩展程序中,并将其添加到任何服务器函数中

ScriptManager.RegisterStartupScript(Page, this.GetType(),"id","function pageLoad(){$find('my_cool_id').show();}",true);

Add BehaviorID="my_cool_id" to your modalpopup extender and add this to any server function

ScriptManager.RegisterStartupScript(Page, this.GetType(),"id","function pageLoad(){$find('my_cool_id').show();}",true);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文