【问题标题】:User Control editing that I did not create我没有创建的用户控件编辑
【发布时间】:2014-02-17 22:36:14
【问题描述】:

我正在编辑 .ascx 和 .ascx.cs 控件,但是,我看到了 using MMG.Globalusing MMG.CMS,它们是 .ascx 控件中的命名空间,如下所示:

<%@ Import Namespace="MMG.Global" %>
<%@ Import Namespace="MMG.CMS" %>

嗯,问题是这些文件还包含我需要的所有对象,例如按钮和占位符等。新服务将使用 IDSS,并将取代 MMG 的服务,但想知道它是否是可以编辑这些文件,以及将 MMG 更改为使用 IDSS 会涉及什么?

我相信 MMG 是在原始项目中使用的参考,并且在构建时已部署在 .ascx 和 .ascx.cs 文件本身中。但我不知道这种事情是如何工作的,这就是我问的原因。

替换具有 MMG 前缀的 20 到 30 个用户控件的最佳方法是什么?

在 MasterMain.master 文件中,我有以下内容:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterMain.master.cs" Inherits="MasterMain"       %>
<%@ Register TagPrefix="mmg" TagName="SEOControl"               Src="~/controls/SEOControl.ascx"            %>
<%@ Register TagPrefix="mmg" TagName="ScriptControl"            Src="~/controls/ScriptControl.ascx"         %>
<%@ Register TagPrefix="mmg" TagName="HeaderControl"            Src="~/controls/HeaderControl.ascx"         %>
<%@ Register TagPrefix="mmg" TagName="HeroControl"              Src="~/controls/HeroControl.ascx"           %>
<%@ Register TagPrefix="mmg" TagName="MenuFooterControl"        Src="~/controls/MenuFooterControl.ascx"     %>
<%@ Register TagPrefix="mmg" TagName="StickyFooterControl"      Src="~/controls/StickyFooterControl.ascx"   %>
<%@ Register TagPrefix="mmg" TagName="FavoritePromptControl"    Src="~/controls/Forms/FavoritePromptControl.ascx" %>
<%@ Register TagPrefix="mmg" TagName="LoginRegistrationControl" Src="~/controls/Forms/LoginRegistrationControl.ascx" %>
<%@ Register TagPrefix="mmg" TagName="EmailFavoriteFormControl" Src="~/controls/Forms/EmailFavoriteFormControl.ascx" %>

<!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 runat="server" visible="false"></title>
        <mmg:SEOControl    ID="TheSEOControl"    runat="server" />
        <asp:Literal       ID="TheFavIcon"       runat="server" />
        <mmg:ScriptControl ID="TheScriptControl" runat="server" />
        <asp:ContentPlaceHolder ID="TheHeadContentPlaceHolder" runat="server"></asp:ContentPlaceHolder>
    </head>
    <body class="" data-page="">
        <form id="form1" runat="server">
            <asp:ScriptManager ID="TheScriptManager" runat="server">
                <CompositeScript>
                    <Scripts>
                        <asp:ScriptReference name="MicrosoftAjax.js"                            />
                        <asp:ScriptReference name="MicrosoftAjaxWebForms.js"                    />
                        <asp:ScriptReference Path="/scripts/jquery.stickyfooter.js"             />
                        <asp:ScriptReference Path="/scripts/modernizr.js"                       />
                        <asp:ScriptReference Path="/scripts/jquery-select2/select2.min.js"      />
                        <asp:ScriptReference Path="/scripts/jquery.jcarousel.pack.js"           />
                        <asp:ScriptReference Path="/scripts/jquery.cycle.all.js"                />
                        <asp:ScriptReference Path="/scripts/bootstrap-tab.js"                   />
                        <asp:ScriptReference Path="/scripts/jquery-ui-1.9.1.custom.min.js"      />
                        <asp:ScriptReference Path="/scripts/jquery.isotope.min.js"              />
                        <asp:ScriptReference Path="/scripts/BaseUI.js"                          />                        
                        <asp:ScriptReference Path="/scripts/FavoriteUI.js"                      />
                        <asp:ScriptReference Path="/scripts/UserLoginUI.js"                     />


                    </Scripts>
                </CompositeScript>
            </asp:ScriptManager>
            <div id="Container" class="">
                <mmg:HeaderControl          ID="TheHeaderControl"       runat="server" />
                <mmg:HeroControl            ID="TheHeroControl"         runat="server" />
                <asp:ContentPlaceHolder     ID="TheContentPlaceHolder"  runat="server" />
                <mmg:StickyFooterControl    ID="TheStickyFooterControl" runat="server" />
            </div>
            <mmg:MenuFooterControl      ID="TheMenuFooterControl"   runat="server" />
        </form>
        <mmg:FavoritePromptControl    ID="TheFavoritePromptControl"     runat="server" />
        <mmg:LoginRegistrationControl ID="TheLoginRegistrationControl"  runat="server" />
        <mmg:EmailFavoriteFormControl ID="TheEmailFavoriteFormControl"  runat="server" />
    </body>
</html>



<script type="text/javascript"> 
        UserLoginUI.SiteUser        = <%= _SiteUserJson %> 
        FavoriteUI.FavoriteList     = <%= _FavoritesJson %>
    </script>

但这些不是命名空间,我想知道我是否只编辑 .ascx 和 .ascx.cs 文件,这样是否足够好?或者创建一个新项目并以与 MMG 绑定到其中的相同方式绑定它会更好吗?

IDSS 是一个需要替代 MMG 的网络服务,一直在努力研究如何在当前网站设置中准确地实现这一点。

【问题讨论】:

    标签: c# asp.net web-config


    【解决方案1】:

    嗯,问题是这些文件包含所有的对象 我也需要,比如按钮和占位符等。新的 服务将与 IDSS 一起,并将取代 MMG 的服务,但 想知道是否可以编辑这些文件以及会是什么 是否涉及将 MMG 改为使用 IDSS?

    您可以在 MasterMain.master &lt;%@ Register TagPrefix="mmg" ... %&gt;&lt;%@ Register TagPrefix="idss" ... %&gt;

    中将 mmg 替换为 idss

    如果这样做,您将不得不重命名 MasterMain.master 中的 所有 mmg 标签,例如 &lt;idss:SEOControl ID="TheSEOControl" runat="server" /&gt;

    但这些不是命名空间,我想知道我是否只是编辑 .ascx 和 .ascx.cs 文件,够好吗?

    你是对的。没有命名空间,所以重命名标签不会造成任何伤害。

    注意:如果在 web.config 中注册了控件,则不能简单地在单个文件中重命名。 但是,这不是我在你的场景中看到的。例如,

    <system.web>
      <pages>
        <controls>
         <add tagPrefix="telerik" namespace="Telerik.Web.UI" 
            assembly="Telerik.Web.UI" />
        </controls>
      </pages>
    </system.web>
    

    【讨论】:

    • 非常感谢,但是我应该在哪里调用 IDSS 中在线的 Web 服务 .asmx?您认为需要调用哪个文件,如果我导入 .ascx 和 .ascx.cs 文件(我应该添加所有 .ascx 和 .ascx.cs 文件吗?)并在新的 Visual Studio 项目中编辑它们,并添加对 IDSS .asmx 文件的引用,我可以保存这些文件并在服务器上覆盖吗?如何添加 Web 参考?如何确保将其添加到网站?
    • 另外,是的,你是对的,web.config 文件中绝对没有注册控件。
    • 在 .ascx.cs 文件中定义了命名空间(例如 using MMG.CMSusing MMG.Global),并且 .ascx 文件也使用 Import 来获取命名空间。如何找到这些命名空间的定义位置并删除它们?还是我只是更改名称空间?如果是这样,对什么?命名空间的名称是否重要?我确定确实如此...抱歉所有问题...非常感谢您的帮助...
    • WebService asmx 与用户 Controls ascx 无关。如果您想将 Service Reference 添加到您的项目中,请查看this。回到最初的问题,如果您的整个应用程序的名称空间是 MMG.xxx,您最终将更新所有文件。这是颈部疼痛,除非你有正当理由这样做。
    • 嗯,我需要把MMG的服务换成IDSS,名字不重要,但服务很重要!这不是我的申请。它是由其他人创建并与网站相关联,所以我不相信它是整个网站。它只是整个站点的大量文件,仅此而已。基本上,我需要用 Web 服务替换 MMG 的用户控件。如何快速做到这一点,同时保持网站的外观和感觉?
    猜你喜欢
    • 2013-01-30
    • 1970-01-01
    • 2013-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-24
    相关资源
    最近更新 更多