各位,为什么在我启动页面时,被多次提交,也就是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次。求解~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

解决方案 »

  1.   

    诡异……
    记得有一个IsPostback,可以试试
      

  2.   

    asp:UpdatePanel 
    可能是因为你使用了微软的ajax控件造成的。
      

  3.   

    去掉Ajax后,一样被执行多次!
      

  4.   

    貌似有关系,不解~~~~~可能和run=server有关。
      

  5.   


    <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次数都没变化。
      

  6.   

    在load事件中
    if(!isposback)
    {  加入你的代码
    }
      

  7.   

    没有后台代码,谁也不知道你在后台干了些什么!服务器控件都会激发Page_load的
      

  8.   

    后台什么也没做,load里啥也没有……,只是打了个断点,load被多次执行了。
      

  9.   

    好像跟图片有关系,还有就是table,好像是一个属性不对,不知道是不是image的source不设置,或者是甚至不对,都会引起page_load走2次的google搜 “image page_load 2次” 有答案,楼主看看。
      

  10.   

    前台后台都贴一下代码。[color=#FF0000]或者楼主注释一部分,一部分的测试加断点[/color]
      

  11.   

    UpdatePanel 大概是这个控件的特性,局部刷新。。可能是多个控件绑定造成的咯,没绑定一次都会造成回发
      

  12.   

    LZ,这你代码,我测试的时候就调用一次啊,我曾经遇到这个问题,挺奇怪的,莫名奇妙的调用两次,后来逐个排查,是因为引用了两JS造成的。
      

  13.   


    <%@ 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