面板问题

时间:2011-07-09 15:09:01

标签: asp.net controls panel

我无法从cs文件后面的代码中找到panelID ..

        <asp:Panel ID="Panel1" runat="server" ondatabinding="Panel1_DataBinding" 
        Visible="False">
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
    </asp:Panel>


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

public partial class PanelControl : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
      Panel1.  --- intellisense doesnt work and there is a red line underneath it!!
    }

    protected void Panel1_DataBinding(object sender, EventArgs e)
    {

    }
}


    <%@ Page Title="" Language="C#" MasterPageFile="~/Forum.master" AutoEventWireup="true" CodeFile="PanelControl.aspx.cs" Inherits="PanelControl" %>

<script runat="server">

    protected void ButtonPanel1_Click(object sender, EventArgs e)
    {

    }
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <p>
        <br />
    </p>
    <p>
    </p>
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    <asp:Panel ID="Panel1" runat="server">
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
    </asp:Panel>
     <asp:Button ID="ButtonPanel1" runat="server" Text="Panel 1" 
        onclick="ButtonPanel1_Click" />
    <p>
    </p>
    <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
    <asp:Panel ID="Panel2" runat="server">
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    </asp:Panel>
    <asp:Button ID="ButtonPanel2" runat="server" Text="Panel 2" />
</asp:Content>

2 个答案:

答案 0 :(得分:0)

razlebe指出,你可能只需要重建。

大约每天一次,我的代码会显示一堆代码无效,只是进行重建修复它。

如果这不起作用,那么您的示例显示您正在使用“部分类”并检查designer.cs类以确保定义了面板的变量。

例如:

    public partial class PanelControl {
       protected System.Web.UI.WebControls.Panel Panel1;
    }

答案 1 :(得分:-1)

尝试删除designer.cs文件,然后单击aspx文件上的右键,并从上下文菜单中选择“转换为Web应用程序”项。