ASP.NET创建控件时出现错误

8
我刚打开我的ASP.NET解决方案,发现每个控件都显示这条信息!
以下是我的代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="EnterData.DataEntry.WebForm1" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:ScriptManager ID="ScriptManager1" runat="server" />


        <br /><table>
                <tr>  
                <td>
                lom_number:
                </td>
               <td><asp:TextBox ID="lom_numberTextBox" runat="server"
                    Text=''/></td>

                <td>occurrence_date:</td>
                <td><asp:TextBox ID="occurrence_dateTextBox" runat="server" 
                    Text='<%# Bind("occurrence_date") %>' />

                    <asp:MaskedEditExtender ID="MaskedEditExtender1"
    TargetControlID="occurrence_dateTextBox" 
    Mask="99/99/9999"
    MessageValidatorTip="true" 
    OnFocusCssClass="MaskedEditFocus" 
    OnInvalidCssClass="MaskedEditError"
    MaskType="Date" 
    InputDirection="RightToLeft" 
    AcceptNegative="Left" 
    DisplayMoney="Left"
    ErrorTooltipEnabled="True" runat="server"/></td>
                <td>report_date:</td>
                <td><asp:TextBox ID="report_dateTextBox" runat="server" 
                    Text='<%# Bind("report_date") %>' /></td>
                    <td>spec_id:</td>
                <td><asp:TextBox ID="spec_idTextBox" runat="server" Text='<%# Bind("spec_id") %>' /></td>             
                    </tr>
                <tr>


                <td>batch_id:</td>
                <td><asp:TextBox ID="batch_idTextBox" runat="server" 
                    Text='<%# Bind("batch_id") %>' /></td>
                <td>report_by:</td>
                <td>
                <asp:TextBox ID="report_byTextBox" runat="server" 
                    Text='<%# Bind("report_by") %>' /></td>

                <td>identified_by:</td> 


                <td><asp:TextBox ID="identified_byTextBox" runat="server" 
                    Text='<%# Bind("identified_by") %>' /></td>
                <td>problem:</td>
                <td><asp:TextBox ID="problemTextBox" runat="server" Text='<%# Bind("problem") %>' /></td>
                <td></td>
               </tr></table>
               <table><tr><td>section_c_issue_error_identified_by:</td>
               <td>
                <asp:TextBox ID="section_c_issue_error_identified_byTextBox"  width="500" runat="server" 
                    Text='<%# Bind("section_c_issue_error_identified_by") %>' />
                    </td></tr>
                <tr><td>section_c_comments:</td><td><asp:TextBox ID="section_c_commentsTextBox" Width="500" runat="server" 
                    Text='<%# Bind("section_c_comments") %>' /></td></tr>
               <tr><td>section_d_investigation:</td><td>
                <asp:TextBox ID="section_d_investigationTextBox" runat="server" 
                    Text='<%# Bind("section_d_investigation") %>' /></td></tr>
               <tr><td>section_e_corrective_action:</td>  <td><asp:TextBox ID="section_e_corrective_actionTextBox" runat="server" 
                    Text='<%# Bind("section_e_corrective_action") %>' /></td></tr>
               <tr><td>section_f_comments:</td><td><asp:TextBox ID="section_f_commentsTextBox" runat="server" 
                    Text='<%# Bind("section_f_comments") %>' /></td></tr>


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

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

有人知道我做错了什么吗?

这段内容与IT技术无关。

在设计模式下,错误信息的工具提示显示什么? - Nick Rolando
@shredder,它没有工具提示。 - Alex Gordon
5个回答

4
这是英文原文,需要翻译成中文:

这刚刚发生在我身上。当我重命名页面并在项目文件夹中移动aspx文件时发生了这种情况,但是里面的代码没有被重命名。

将内部代码更改为:

public partial class foldername_unrenamedname : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
}

当前的
public partial class newfoldername_renamedname : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
}

并且在Page标签中编辑Inherits属性为:
Inherits="Newfoldername_renamedname"

2
您可以按照以下步骤解决此错误,该错误的根本原因是 Web 应用程序项目与 IIS 中虚拟目录之间的映射不正确。
要解决此错误,请按照以下步骤操作:
1.右键单击您的 Web 应用程序项目,选择属性->Web。
2.在服务器部分中选择使用 IIS Web 服务器,然后单击创建虚拟目录。
3.清理您的项目并重新编译。
完成 :)
这些信息在以下网站上。

http://weblogs.asp.net/hosamkamel/archive/2007/09/15/resolving-error-creating-control-xxx-in-web-application-project.aspx

这里有另一篇文章提出了不同的解决方案,因为在使用之前该对象未被初始化。

http://blogs.msdn.com/b/webdevtools/archive/2010/05/06/another-error-creating-control-in-the-design-view-with-object-reference-not-set-in-visual-studio-2010.aspx


1
关闭aspx设计器,清理项目并重新构建,一切开始完美运行。(使用Visual Studio 2015)

1

我所有的页面都遇到了同样的问题。我改变了.NETFramework的版本,然后问题得到解决。 在添加组件时使用的.NETFramework版本与当前版本不同。


0

我曾经遇到同样的问题,尝试了以上所有方法,但都没有解决。

最终解决方法如下: 进入项目->属性,点击Web,然后将服务器(我的定义为本地IIS)更改为外部IIS并保存。

我甚至不需要重新启动VS,控件就能正确显示。

一旦您的控件正确显示,您可以将Web->服务器设置改回之前的设置。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接