62,269
社区成员
发帖
与我相关
我的任务
分享
aspx:
<asp:button runat="server" text="Button" id="xx" />
cs:
xx.Attributes.Add("onclick", "return showdiv()"); /按钮添加的事件(客户端)
protected void xx_Click(object sender, EventArgs e)
{
//按钮的提交数据处理
}
//因为按钮是server控件,提交的时候有post动作,这样子会致使页面重加载一次,故客户端的js也只是一闪而逝,虽然可以在 xx.Attributes.Add("onclick", "return showdiv()"); return showdiv();加return false,但这样又不执行 xx_Click(object sender, EventArgs e)
事件.苦思多时也找不到解决方案,特来求教.给出解决方法者,100分送上,谢谢先了
<div id="doing" runat="server" style="Z-INDEX: 12000; LEFT: 0px; WIDTH: 100%; CURSOR: wait; POSITION: absolute; TOP: 0px; HEIGHT: 100%">
<table width="100%" height="100%">
<tr align="center" valign="middle">
<td>
<table width="169" height="62" bgcolor="#99cccc" style="FILTER: Alpha(Opacity=75); WIDTH: 169px; HEIGHT: 62px">
<tr align="center" valign="middle">
<td>页面提交中.<br>
Loading.</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<asp:Button ID="Button1" runat="server" Text="Button" />protected void Page_Load(object sender, EventArgs e)
{
this.Button1.Attributes.Add("onclick", "javascript:document.getElementById('doing').style.visibility='visible';");
for (int i = 0; i < 10; i++)
{
System.Threading.Thread.Sleep(1000);
}
}
override protected void OnPreRender(EventArgs e)
{
doing.Style.Add("visibility", "hidden");
}
<div id="doing" runat="server" style="Z-INDEX: 12000; LEFT: 0px; WIDTH: 100%; CURSOR: wait; POSITION: absolute; TOP: 0px; HEIGHT: 100%">
<table height="100%" width="100%">
<tr vAlign="middle" align="center">
<td>
<table style="FILTER: Alpha(Opacity=75); WIDTH: 169px; HEIGHT: 62px" height="62" width="169"
bgColor="#99cccc">
<tr vAlign="middle" align="center">
<td>业务处理中...<br>
请稍候...</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
If Page.IsPostBack = False Then
btnTj.Attributes.Add("onclick", "javascript:document.getElementById('doing').style.visibility='visible';")
End If
End Sub
Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs)
doing.Style.Add("visibility", "hidden")
End Sub
<asp:UpdatePanel ID="upl" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<div class="wopen2">
<div align="center" class="login font_04">数据加载中,请等待……</div>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
</asp:UpdatePanel>
11111111
<script language="javascript" type="text/javascript">
function ShowDiv()
{
document.getElementById('divProcess').style.display='block';
document.getElementById('cmdQuery').click();
}
</script>
22222222
<div id="divProcess" style="position:absolute; width:80%; height:200px; top:60px; left:80px; display:none;z-index:100;">
<table border="0" cellpadding="0" cellspacing="0" style="background-color:GrayText; width:100%; height:100%">
<tr>
<td align="center"><img src="../images/loading.gif" width="20px" height="20px"/><b> 正在统计,请等待......</b></td>
</tr>
</table>
</div>
33333333
<input id="btn_sel" type="button" class="btn1" value="查询" onclick="ShowDiv()" />
44444444
<asp:Button ID="cmdQuery" runat="server" CssClass="btn1"
Text="查询" OnClick="cmdQuery_Click" Width="0px"/>