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