Page_Load在asp:login上提交两次 [英] Page_Load fires twice with submit on asp:login

查看:64
本文介绍了Page_Load在asp:login上提交两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我的Page_Load被调用了两次?我正在使用VS 2008,当我在Page_Load上休息并逐步完成时,我看到了这一点。第一次isPostback是真的,第二次是假的。



这是我的aspx页面:

---------- ---------------------

Why is my Page_Load called twice? I'm using VS 2008 and I see this when I put a break on Page_Load and step through it. First time isPostback is true, second time it's false.

Here's my aspx page:
-------------------------------

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="STN.test" %>

<head  runat="server">
    <title></title>
</head>
<body>
    <form id="form1"  runat="server">
    <div>
        <asp:LoginView ID="LoginView2" runat="server">
            <anonymoustemplate>
                <asp:Login ID="Login" runat="server">
                
            </anonymoustemplate>
            <loggedintemplate>
                <div>
                    LoggedInTemplate
                </div>
            </loggedintemplate>
        
    </div>
    </form>
</body>
</html>



这是我的aspx.cs页面:

----------- --------------------




Here's my aspx.cs page:
-------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace STN
{
    public partial class test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}

推荐答案

如果你页面包含src =#删除它们
If you page contain src="#" remove them


页面不会触发,但事件可以。

你的意思是每个Load和PreInit都会触发两次?您没有将任何事件处理程序添加到事件调用列表中(此代码是在ASP XML的代码隐藏中吗?),但您可以将它们添加两次或为同一事件添加不同的句柄。



-SA
Pages do not fire, but events can.
Do you mean each of Load and PreInit fires twice? You don't any event handlers added to event invocation lists (where this code is, either in code-behind of ASP XML?), but you can add them twice or add different handles to the same event.

—SA


AutoEventWireup =true导致此。
AutoEventWireup="true" causes this.


这篇关于Page_Load在asp:login上提交两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆