2011-07-09 59 views
1

我不能從後面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> 
+1

你有沒有做過清潔和重建? – razlebe

+0

yup..still不會出現 – WithFlyingColors

+2

可能是你的面板是在一個模板容器內?請張貼表格的整個aspx標記 – platon

回答

0

爲razlebe表示,你可能只需要重建。

大約每天一次,我的代碼將顯示一堆代碼是無效的,只是做一個重建修復它。

如果這不起作用,您的示例將顯示您正在使用「部分類」並檢查designer.cs類以確保您的面板變量已定義。

例如:

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

嘗試刪除designer.cs文件,然後點擊aspx文件右鍵,然後從上下文菜單中選擇「轉換爲Web應用程序」項。

+0

沒有這樣的選項轉換爲網頁應用程序 – WithFlyingColors