【发布时间】:2021-03-08 02:18:36
【问题描述】:
我有一个带有单个按钮的简单网络表单:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="DemoWeb.Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="https://unpkg.com/showmodaldialog"></script>
<script>
function showPopup() {
var ret = window.showModalDialog("Popup.aspx");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
</div>
</form>
</body>
</html>
如何使用 https://github.com/niutech/showModalDialog 的 ShowModalDialog Polyfill 使该按钮打开 Popup.aspx?
我尝试过这样的 Default.aspx.cs:
using System;
namespace DemoWeb
{
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Button1.Attributes.Add("OnClick", "showPopup()");
}
protected void Button1_Click(object sender, EventArgs e)
{
}
}
}
它在 IE 中使用旧的 showModalDialog 有效,但在 Chrome 中出现并立即消失。
【问题讨论】:
标签: c# asp.net polyfills showmodaldialog