【发布时间】:2016-11-27 22:46:05
【问题描述】:
我正在尝试在链接按钮上使用此代码,但因为它需要使用表单,所以它不起作用。我希望在单击链接按钮时显示覆盖 div,以便用户知道函数的处理时间会很长。我正在尝试在http://www.aspsnippets.com/demos/289/
上遵循示例我认为问题出在 jquery 上,因为当我希望它在按钮单击时显示时,它需要一个表单提交。请记住,我是在用户控件中执行此操作的,因此它可能也与页面生命周期有关,但由于我的链接按钮的格式不正确,它在母版页中,这可能不是问题。
$('form').live("submit", function () {
ShowProgress();
});
这是我的脚本代码
<script type="text/javascript">
function ShowProgress() {
setTimeout(function () {
var modal = $('<div />');
modal.addClass("modal");
$('body').append(modal);
var loading = $(".loading");
loading.show();
var top = Math.max($(window).height() / 2 - loading[0].offsetHeight / 2, 0);
var left = Math.max($(window).width() / 2 - loading[0].offsetWidth / 2, 0);
loading.css({ top: top, left: left });
}, 200);
}
$('form').live("submit", function () {
ShowProgress();
});
</script>
样式
<style type="text/css">
.modal
{
position: fixed;
top: 0;
left: 0;
background-color: black;
z-index: 99;
opacity: 0.8;
filter: alpha(opacity=80);
-moz-opacity: 0.8;
min-height: 100%;
width: 100%;
}
.loading
{
font-family: Arial;
font-size: 10pt;
border: 5px solid #67CFF5;
width: 200px;
height: 100px;
display: none;
position: fixed;
background-color: White;
z-index: 999;
}
</style>
我的 Html 和按钮点击
<div class="loading" align="center">
Loading. Please wait.<br />
<br />
<img src="~/Images/slateloading.gif" alt="" />
</div>
<asp:LinkButton ID="lnkExport" CausesValidation="false" style="margin-top: 5px;" on Height="60" OnClick="lnkExport_Click" ClientIDMode="Static" runat="server" Text=" <i class='glyphicon glyphicon-open-file' ></i><br/>Submit Case" CssClass="btn btn-info btn-dark-theme-negative pull-right" />
然后,在page_load 我有这个。我需要在单击lnkexport 按钮时显示进度窗口。
if (!IsPostBack)
{
string script = "$(document).ready(function () { $('[id*=lnkExport]').click(); });";
Page.ClientScript.RegisterStartupScript(this.GetType(), "load", script, true);
}
【问题讨论】:
-
感谢您的编辑帮助我使帖子更清晰对不起我的英语不好