【发布时间】:2014-03-18 22:18:42
【问题描述】:
我用过这样的花哨的弹出框
<div class="x-popup" id="PopUpWarning">
<table cellspacing="0" cellpadding="0" class="info" width="100%">
<tr>
<td align="center" valign="middle" height="175">
<asp:Label ID="lblWarning" runat="server" Text="You must choose less than 256 item in the following fields :"></asp:Label>
<telerik:RadListView ID="lvWarningFields" runat="server" ItemPlaceholderID="itemTemplate">
<LayoutTemplate>
<div>
<ul>
<asp:PlaceHolder ID="itemTemplate" runat="server"></asp:PlaceHolder>
</ul>
</div>
</LayoutTemplate>
<ItemTemplate>
<li>
<asp:Label ID="lblWarning" runat="server"><%# Container.DataItem %></asp:Label>
</li>
</ItemTemplate>
</telerik:RadListView>
</td>
<td>
</tr>
</table>
<div class="bottom-buttons cf">
<div class="fr">
<a href="#" class="button cancel">Cancel</a>
</div>
</div>
</div>
我在代码后面的按钮单击事件中打开了幻想框弹出窗口。像这样
c#端
string jsWarning = "<script language='javascript' type='text/javascript'>Sys.Application.add_load(showWarning);</script>";
ClientScript.RegisterStartupScript(this.GetType(), "showWarning", jsWarning);
aspx 端
function showWarning() {
show_popup('PopUpWarning');
};
我在按钮事件中打开弹出窗口。并单击关闭按钮调用 $.fancybox.close();并弹出关闭。但是在同一页面回发后弹出窗口会自动打开。
我想我需要删除 Sys.Application.add_load(showWarning);脚本?是真的吗?
为什么我的弹出窗口在回发后打开。我需要打开仅弹出按钮单击触发。我该怎么做?
【问题讨论】:
-
是否有任何理由将 javascript 事件绑定到后面代码中的按钮?如果您只是在您的 aspx 页面上添加适当的 onClick 事件,事情可能会容易得多。您愿意详细说明您的实施吗?
-
因为我用的是fancybox。在该示例中,花式框弹出窗口仅使用 js 打开,“show_popup”调用了 fancybox.js 中的函数。我们无法从服务器端打开 fancybox。但是我需要在一些服务器端操作后打开fancybox pop up。所以我需要从服务器端调用js。
标签: c# javascript jquery asp.net fancybox