在ASP.NET c#上释放UpdateProgress后如何激发JavaScript事件?
我有一个webform,其中有一个javascript函数,用于评估它是否应该显示div。。。 这是函数在ASP.NET c#上释放UpdateProgress后如何激发JavaScript事件?,c#,javascript,asp.net,updatepanel,updateprogress,C#,Javascript,Asp.net,Updatepanel,Updateprogress,我有一个webform,其中有一个javascript函数,用于评估它是否应该显示div。。。 这是函数 function viewCalendars() { if (document.getElementById('ddlDates').value == '5') { document.getElementById('divSpecificDates').style.
function viewCalendars()
{
if (document.getElementById('ddlDates').value == '5')
{
document.getElementById('divSpecificDates').style.display = 'inline';
}
else
{
document.getElementById('divSpecificDates').style.display = 'none';
}
return;
}
我还将此添加到我的表单中
<body onload="viewCalendars();">
//Everything
</body>
//一切
因此,即使有回发,如果dropdownlist选择了特定值,它也会显示div
然而,我最近添加了updatepanel和updateprogress。。。现在我认为,由于回发将不会发生,因此该方法将不再有效
这是我现在拥有的
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Consumptions.aspx.cs" Inherits="Station.Consumptions" %>
<%@ Register TagPrefix="ew" Namespace="eWorld.UI" Assembly="eWorld.UI, Version=1.9.0.0, Culture=neutral, PublicKeyToken=24d65337282035f2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>
Lista De Consumos
</title>
<link href="css/Style.css" type="text/css" rel="stylesheet"/>
<style type="text/css">
#blur
{
width: 100%;
background-color: black;
moz-opacity: 0.5;
khtml-opacity: .5;
opacity: .5;
filter: alpha(opacity=50);
z-index: 120;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
#progress
{
border: black 1px solid;
padding: 5px;
z-index: 100;
width: 250px;
position: absolute;
background-color: #fff;
-moz-opacity: 0.75;
font-family: Tahoma;
font-size: 11px;
font-weight: bold;
text-align: center;
}
</style>
<script type="text/javascript">
function viewCalendars()
{
if (document.getElementById('ddlDates').value == '5')
{
document.getElementById('divSpecificDates').style.display = 'inline';
}
else
{
document.getElementById('divSpecificDates').style.display = 'none';
}
return;
}
</script>
</head>
<body onload="viewCalendars();">
<form id="form1" runat="server">
<asp:ScriptManager ID="sm" runat="server">
</asp:ScriptManager>
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<div id="blur">
</div>
<div id="progress">
<asp:Image ID="imgLoading" GenerateEmptyAlternateText="true" runat="server" ImageUrl="~/images/loading.gif" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="upd" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddlDates" CssClass="tbox" runat="server">
</asp:DropDownList>
<div runat="server" id="divSpecificDates" style="display: none; width: 100%; z-index: 1000;">
</div>
<asp:Button Text="Filtrar" CssClass="btn" runat="server" ID="btnFilter" onclick="btnFilter_Click" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnFilter" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</form>
</body>
</html>
消费清单
#模糊
{
宽度:100%;
背景色:黑色;
moz不透明度:0.5;
khtml不透明度:.5;
不透明度:.5;
过滤器:α(不透明度=50);
z指数:120;
身高:100%;
位置:绝对位置;
排名:0;
左:0;
}
#进展
{
边框:黑色1px实心;
填充物:5px;
z指数:100;
宽度:250px;
位置:绝对位置;
背景色:#fff;
-moz不透明度:0.75;
字体系列:Tahoma;
字体大小:11px;
字体大小:粗体;
文本对齐:居中;
}
函数viewCalendars()
{
if(document.getElementById('ddlDates')。值=='5')
{
document.getElementById('divSpecificDates').style.display='inline';
}
其他的
{
document.getElementById('divSpecificDates').style.display='none';
}
返回;
}
因此,我注意到,在单击btnFilter按钮后,它的函数将被触发,而updateprogress是可见的,但在它消失(并且btnFilter函数完成)后,当它应该是可见的时候,日期是不可见的。我想我必须在一切完成后调用viewCalendars()
如何以及在何处调用此函数
更新:
我刚刚摆脱了updateprogress。。。它仍然不起作用,所以我想问题不在那里。。。可能是在updatepanel上,当updatepanel被更新时,DOM被更改,您需要重新运行加载页面时所做的初始化。这是通过添加UpdatePanel时asp.net包含的javascript函数完成的。因此,从正文中删除
onload
,并使用pageLoad
因此,从这条线中移除onload
<body onload="viewCalendars();">
并添加此脚本
<script>
function pageLoad() {
viewCalendars();
}
</script>
函数pageLoad(){
查看日历();
}
相似的参考资料:我正在更新一些遗留系统,这正是我所要寻找的。谢谢你,阿里斯托斯