面板问题

发布于 2024-11-19 08:59:57 字数 1957 浏览 1 评论 0原文

我无法从 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>

I cant reach the panelID from the code behind cs file..

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心在旅行 2024-11-26 08:59:57

正如拉兹勒贝所指出的,你可能只需要重建。

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

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

例如:

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

as razlebe indicated, you may just have to rebuild.

About once a day, my code will show that a bunch of code is invalid and just doing a rebuild fixes it.

If that does not work, your example shows that you are using a "partial class" and check the designer.cs class to make sure that your variable for the panel is defined.

for example:

    public partial class PanelControl {
       protected System.Web.UI.WebControls.Panel Panel1;
    }
手长情犹 2024-11-26 08:59:57

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

Try to delete designer.cs file then click right button on the aspx file and choose 'Convert to Web Application' item from context menu.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文