各位,为什么在我启动页面时,被多次提交,也就是page_load被走了多次。
asp.net代码如下(page_load走了4次):<%@ Page Language="vb" AutoEventWireup="true" CodeFile="Login.aspx.vb" Inherits="Login" %>
<!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>login</title>
</head>
<body style="background-color: #fefefe">
<form id="form1" runat="server">
<div style="top: 0px;">
<table cellpadding="0" cellspacing="0" id="main" runat="server" style="width: 100%;
height: 590px; text-align: center; background-color: #fefefe; top: 0px">
<tr>
<td style="height: 300px; vertical-align: bottom;">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<table cellpadding="0" cellspacing="0" id="main_up" runat="server" style="background-color: #fefefe;
width: 100%; text-align: center">
<!-- service logo -->
<tr>
<td style="background-image: url(image/backimage.gif); background-repeat:repeat-x; width: 20%; background-attachment: scroll; height: 100%;">
</td>
<td colspan="3" align="left" style="background-image: url(~/image/backimage.gif); background-repeat:repeat-x; width: 25%;">
<asp:Image ID="ImageLK" runat="server" ImageUrl="~/image/LK-logo.gif" />
</td>
<td style="background-image: url(image/backimage.gif); background-repeat:repeat-x; width: 20%; background-attachment: scroll;">
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</table>
</div>
<div style="text-align : center;">
<asp:Label ID="Label1" runat="server" Text="Copyright© aaa, Inc." Font-Names="Verdana" Font-Size="XX-Small"></asp:Label></div>
</form>
</body>
</html>
如果去掉<td colspan="3" align="left" style="background-image: url(~/image/backimage.gif); background-repeat:repeat-x; width: 25%;">
<asp:Image ID="ImageLK" runat="server" ImageUrl="~/image/LK-logo.gif" />
</td>那么page_load就被走了2次。求解~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
asp.net代码如下(page_load走了4次):<%@ Page Language="vb" AutoEventWireup="true" CodeFile="Login.aspx.vb" Inherits="Login" %>
<!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>login</title>
</head>
<body style="background-color: #fefefe">
<form id="form1" runat="server">
<div style="top: 0px;">
<table cellpadding="0" cellspacing="0" id="main" runat="server" style="width: 100%;
height: 590px; text-align: center; background-color: #fefefe; top: 0px">
<tr>
<td style="height: 300px; vertical-align: bottom;">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<table cellpadding="0" cellspacing="0" id="main_up" runat="server" style="background-color: #fefefe;
width: 100%; text-align: center">
<!-- service logo -->
<tr>
<td style="background-image: url(image/backimage.gif); background-repeat:repeat-x; width: 20%; background-attachment: scroll; height: 100%;">
</td>
<td colspan="3" align="left" style="background-image: url(~/image/backimage.gif); background-repeat:repeat-x; width: 25%;">
<asp:Image ID="ImageLK" runat="server" ImageUrl="~/image/LK-logo.gif" />
</td>
<td style="background-image: url(image/backimage.gif); background-repeat:repeat-x; width: 20%; background-attachment: scroll;">
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</table>
</div>
<div style="text-align : center;">
<asp:Label ID="Label1" runat="server" Text="Copyright© aaa, Inc." Font-Names="Verdana" Font-Size="XX-Small"></asp:Label></div>
</form>
</body>
</html>
如果去掉<td colspan="3" align="left" style="background-image: url(~/image/backimage.gif); background-repeat:repeat-x; width: 25%;">
<asp:Image ID="ImageLK" runat="server" ImageUrl="~/image/LK-logo.gif" />
</td>那么page_load就被走了2次。求解~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
记得有一个IsPostback,可以试试
可能是因为你使用了微软的ajax控件造成的。
<td style="background-image: url(image/backimage.gif); background-repeat:repeat-x; width: 20%; background-attachment: scroll; height: 100%;">
</td>
。。
<td style="background-image: url(image/backimage.gif); background-repeat:repeat-x; width: 20%; background-attachment: scroll;">
</td>如果去掉一上两句,也可以去掉一次page_load,但是无论只去掉以上两句的哪一句,load次数都没变化。
if(!isposback)
{ 加入你的代码
}
<%@ Page Language="vb" AutoEventWireup="true" CodeFile="WebForm1.aspx.vb" Inherits="WebForm1" %>
<!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"><body >
<form >
<table >
<tr>
①<td style="background-image: url(image/backimage.gif); ">
</td>
②<td style="background-image: url(~/image/backimage.gif); " >
③<asp:Image ID="ImageLK" runat="server" />
</td>
④<td style="background-image: url(image/backimage.gif); ">
</td>
</tr>
</table>
</form>
</body>
</html>
原因基本知道了。
首先,造成多次调用的原因是使用了image相关的东西。为什么会被走四次呢?
1。page_load启动时一次。
2。②一次
3。③一次
4。①和④共一次,因为①和④加载的是同一图片。至于为什么图片会被多次加载,自己参看下面的地址意会吧!http://blog.sina.com.cn/s/blog_4d38a3b00100w97h.html
http://www.cnblogs.com/66feifei/archive/2007/04/09/705721.html