繁体   English   中英

asp.net 创建控件时出错

[英]asp.net error creating control

我刚刚打开我的 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>

有谁知道我做错了什么?

这件事发生在我身上。 它发生在我重命名页面并在项目文件夹中移动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"

您可以通过执行以下步骤来解决此错误,此错误的根本原因是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-视觉工作室2010.aspx

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

我的所有页面都遇到了同样的问题。 我更改了 .NETFramework 的版本并且它起作用了。 添加组件时.NETFramework 的版本与当前版本不同。

我遇到了同样的问题,我尝试了以上所有方法,但没有一个对我有用。

起作用的是以下内容:Go 到项目-> 属性单击 Web,然后将服务器(我的服务器定义为本地 IIS)更改为外部 IIS 并保存。

我什至不必重新启动 VS,并且控件重新正确显示。

一旦您的控件正确显示,您可以将 Web->Server 设置更改回它们之前的状态。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM