面板问题
我无法从 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如拉兹勒贝所指出的,你可能只需要重建。
大约每天一次,我的代码会显示一堆代码无效,只需进行重建即可修复它。
如果这不起作用,您的示例表明您正在使用“部分类”并检查 Designer.cs 类以确保定义了面板的变量。
例如:
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:
尝试删除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.