0

我已经搬到了 Visual Studio 4.5,起初我的更新面板工作得很好,但有一天,即使我开始一个新项目,它们似乎也完全停止了。

代码背后:

public partial class TestPage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            Label1.Text = "Post Back";
        }

    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        Testl.Text = DateTime.Now.ToString();
        UpdatePanel1.Update();
    }
}

页:

  <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"        CodeBehind="TestPage.aspx.cs" Inherits="" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
     <asp:Label ID="Label1" runat="server" ></asp:Label>

 <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />

 <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
    <ContentTemplate>
        <asp:Label runat="server" ID="Testl"></asp:Label>
    </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>

甚至此代码也会导致回发,我终其一生都无法弄清楚原因。以下是我的参考资料,以防我遗漏了一份我没有意识到的情况。

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

我让它在我的母版页的脚本管理器中运行。

  <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="UFODataRepositoryWebApplication.SiteMaster" %>

<!DOCTYPE html>
<html lang="en">
<head id="Head1" runat="server">
<meta charset="utf-8" />
<title></title>

<asp:ContentPlaceHolder runat="server" ID="HeadContent" />
</head>
<body>
<form runat="server" id="MainForm">
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <header>
        <div class="content-wrapper">

            <div class="float-right">

                <div id="MainLogin_Div">
                    <div class="fb-login-button" data-show-faces="true" data-    width="400" data-max-rows="1"></div>

                    <asp:UpdatePanel ID="MainLogin_UpdatePanel"    UpdateMode="Conditional" runat="server">
                        <ContentTemplate>
                            <asp:Panel ID="UnLoggedMain_Panel" runat="server"    Visible="true">
                                <p>
                                    <asp:LinkButton runat="server" PostBackUrl="Login.aspx" CssClass="NotLoggedMenu"
                                        ID="MainLogin_Link">Login</asp:LinkButton>
                                    <span style="color: #7E7F7F;">or </span>
                                    <asp:LinkButton runat="server" PostBackUrl="Register.aspx" CssClass="NotLoggedMenu"
                                        ID="MainRegister_Link">Become a    member</asp:LinkButton>
                                </p>
                            </asp:Panel>
                            <asp:Panel ID="LoggedMain_Panel" ClientIDMode="Static" runat="server" Visible="false">
                                <span style="color: #CACCCB;">Welcome: </span>
                                <asp:LinkButton ID="Welcome_LinkButton" ClientIDMode="Static" runat="server" PostBackUrl="~/UserPanel.aspx"></asp:LinkButton>
                                <asp:LinkButton ID="MainLogout_LinkButton" runat="server" OnClick="MainLogout_User">  Logout</asp:LinkButton>
                            </asp:Panel>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </div>

                </ul>
            </div>
        </div>
    </header>


    <div id="body">
        <asp:ContentPlaceHolder runat="server" ID="MainContent" />
    </div>

   </form>
  </body>
</html>

所以这应该是我拥有的所有代码。我故意在这篇文章的页面顶部取出了继承。

4

0 回答 0