public ASP.ascx_wucliteralbox_ascx uc = new ASP.ascx_wucliteralbox_ascx();   protected void Page_Load(object sender, EventArgs e)
    {
       PlaceHolder PH = new PlaceHolder();
       uc = (ASP.ascx_wucliteralbox_ascx)LoadControl("wucliteralbox.ascx");
       uc.sign = true;
        uc.pagesize = 3;
        PH.Controls.Add(uc);
       this.Controls.Add(PH);
    }
代码如上,调试运行没问题,但是生成网站的时候报错:
命名空间“ASP”中不存在类型或命名空间名称“ascx_wucliteralbox_ascx”(是否缺少程序集引用?)
之所以,这种写法,是因为这个调用的控件数量是不一定的,看具体程序的,这里没有体现出来,而且必须需要出现这个uc,因为要向调用的控件传递sign和pagesize这两个参数
本人新手,有些问题或许没有表达清楚,请大神赐教,需要解决的关键问题是,如何去掉这个错误。求各位大神asp.net网站网站调试成功生成网站失败

解决方案 »

  1.   

    参考:
    http://www.cnblogs.com/insus/tag/UserControl/
    先找一找,如找不到,稍后Insus.NET加班帮你找。
      

  2.   

    命名空间“ASP”中不存在类型或命名空间名称“ascx_wucliteralbox_ascx”(是否缺少程序集引用?)看看你的命名空间写没有?
      

  3.   

    以下三种原因是因为当你在建当前项目时,引用空间就出现了问题,其他页面没有报错是因为没有用到那个出错的命名空间,当你一旦用到了,不管你在页面上怎么改都没有用,解决的办法就是把Web里面的dll文档引用程序改一下,若有System.web.UI.Controls命名空间就移除掉,然后再添加System.web;就行了。
      

  4.   


    斑竹,这个答案我也搜索到过,不过我没有用System.web.UI.Controls这个命名空间啊,而且这个空间打不出来,我用到的命名空间在下面
    using System;
    using System.Collections;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using System.Data.SqlClient;
    using System.Web.Configuration;
    using System.Collections.Generic;
    using System.Text;
    using System.Security.Cryptography;
    using System.Net;
      

  5.   

    namespace ASP
    {    public class ascx_wucliteralbox_ascx
        {
          ...
        }
    }
      

  6.   

    大神,我参考你的这篇文章http://www.cnblogs.com/insus/p/3248170.html
    然后在这地方出错报这个错无法将类型为“ASP.ascx_wucliteralbox_ascx”的对象强制转换为类型“Wzn.NET.ISetable”。
    ASP.ascx_wucliteralbox_ascx这个控件相当于你的UcB。Wzn.NET是命名空间,ISetable是接口。能不能再指点指点啊
      

  7.   

    是不是没有在aspx页面注册的原因。。在aspx页面最上方
      

  8.   


    十分感谢,最终通过接口来实现传参,虽然跟原先的做法不太一样了,最后还是没有弄明白题设中为什么编译失败的问题,有点纠结。但总归是解决了这个问题,困扰很久了,万分感谢insus大神!赞一个,也谢谢其他回答的大神们。