【问题标题】:Need help on running a ASP.Net project with .ascx file在使用 .ascx 文件运行 ASP.Net 项目时需要帮助
【发布时间】:2014-03-12 18:18:33
【问题描述】:

在过去的两天里,我在尝试编译和运行使用用户控件的现有 ASP.net 项目时遇到了很多困难。我面临的问题如下

  1. 当我尝试编译项目时,.ascx 文件出现错误,无法加载在继承标记部分中定义的类型。在继承部分中,在我的项目中,在用户控件名称之前添加了另一个命名空间,我在项目中找不到任何位置。但是我有 .ascx 代码文件。要克服这个问题,我能做些什么?

  2. 下一个问题是,在编译项目时,我在 .ascx 文件中遇到了一些错误。但奇怪的问题是它从项目的备份文件夹而不是项目中获取用户控件的代码文件主文件夹。我可以在我的项目中更改什么配置,以便它将从我的项目主文件夹中获取用户控件的代码文件。

.ascx 文件的代码是

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ViewClinic.ascx.cs" Inherits="Tree.Templates.DynamicContent.Vpo.UserControls.ViewClinic" %>


<link type="text/css" href='<%=ResolveUrl("../Styles/StyleSheetVpo1.css")%>' rel="stylesheet" />

<script type="text/javascript" src='<%=ResolveUrl("../Scripts/jquery-1.4.4.js")%>'></script>
<script type="text/javascript" src='<%=ResolveUrl("../Scripts/jquery.tooltip.js")%>'></script>
<script type="text/javascript" src='<%=ResolveUrl("../Scripts/GeneralNEEV.js")%>'></script>


            <asp:Repeater ID="rcClinics" runat="server" OnItemDataBound="rcClinics_ItemDataBound" >
                <ItemTemplate>
                    <div id="menu" runat="server"  class='FirstMenu'>
                        <div>
                            <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                    <tr>
                                        <td width="45%" style="font-size:13px !important;">
                                            <span>
                                                <asp:Label ID="lblCli" runat="server"></asp:Label>
                                            </span>
                                        </td>
                                        <td width="55%" style="font-size:14px !important;">
                                            <span id="spVac" runat="server">0</span>
                                        </td>
                                    </tr>
                            </table>
                        </div>
                    </div>
                </ItemTemplate>
            </asp:Repeater>

文件后面的代码是

namespace Tree.Templates.DynamicContent.Vpo.UserControls
{
    public partial class ViewClinic : System.Web.UI.UserControl
    {
        public VpoParameters VpoParas { get; set; }
        private JArray AllClinics = new JArray();
        private List<Clinic> clinics;
        private List<CareUnit> careUnits;
        private List<Total> total;
        private int intClinicId = 0;
        private int satellite_patient = 0;
        private int id = 0;
        protected String VpoEditUpdateUrl = System.Configuration.ConfigurationManager.AppSettings["VpoEditUpdateUrl"];
        protected List<ColumnInfo> cinfo = new List<ColumnInfo>();
        protected String user = "";
        CareUnit ava = new CareUnit();
        protected int avCuId = 0;
}

感谢和问候 乌特帕尔

【问题讨论】:

  • 您能否提供 ascx 文件中的代码以及代码隐藏文件中的命名空间和类声明行。这将有助于给出准确的答案
  • @matt_lethargic 我已经修改了帖子并给出了代码

标签: c# asp.net asp.net-mvc-3 visual-studio user-controls


【解决方案1】:

尝试右键单击 Visual Studio 中的备份文件夹并选择从项目中排除并重建。如果存在具有相同命名空间和类名的 .cs 文件,那么它们会发生冲突。由于您的课程是部分的,它会尝试编译您的备份文件夹并且可能会失败

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-05-25
    • 2012-11-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多