记得要在test.aspx中加入自定义控件的命名空间<%@ Register……

解决方案 »

  1.   

    //********************************************
    base.Render(writer);//调用基类的函数据输出数据
    //********************************************
    加上就OK了,呵呵,给分吧!
      

  2.   

    早已经加了,贴出的代码版本早了一个号,但问题依然:
    编译通过,其他工程调用时编译也通过,但浏览时报错:CS0103: 名称“__ctrl”在类或命名空间“ASP.test_aspx”中不存在
      

  3.   

    已经using System.Data.SqlClient;
    似乎应该是编译方面的问题
      

  4.   

    将此类库单独建立一个项目!重新编译!不要将类库的项目和web应用程序放在一个解决方案中!
      

  5.   

    TO: herofyf
    没有放在一起,我建了一个新的项目引用的
      

  6.   

    你的错误原因:编译器错误 CS0103--
    名称“name”在类或命名空间“namespace”中不存在
    试图使用 namespace 中不存在的名称。
      

  7.   

    在 private void Page_Load(object sender, System.EventArgs e)
    上按F9,然后按F5,执行单步调试(F11,要有耐性)。
    GO!
      

  8.   

    编译没有任何问题,只是在浏览器里看才会报错,错误行在:
    “<cc1:CusGrid id="CusGrid1" style="Z-INDEX: 101; LEFT: 89px; POSITION: absolute; TOP: 54px" runat="server" AutoGenerateColumns="False" CellPadding="0" BorderWidth="1px" BorderStyle="Outset">”
    属于页面级的
      

  9.   

    我也曾经遇到这个问题,找不到原因,可能是iis不稳定吧!
    自己后来,重新开了一个project,一样的代码,就编译通过,而且正常显示啦!你可以试试!
      

  10.   

    the following works for me (by the way, you shouldn't do those settings in Render):WebCustomControl3.cs (compile it to WebControlLibrary1.dll):using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.ComponentModel;namespace WebControlLibrary1
    {
    [DefaultProperty("Text"), 
    ToolboxData("<{0}:CusGrid runat=server></{0}:CusGrid>")]
    public class CusGrid : System.Web.UI.WebControls.DataGrid
    {
    private string text;

    public CusGrid() : base()
    {
    this.ItemStyle.Height = 20;//行高
    this.ItemStyle.CssClass = "itemstyle";
    this.AlternatingItemStyle.CssClass = "alternatingitemstyle";
    this.HeaderStyle.Height = 25;//题头行高
    this.HeaderStyle.CssClass = "headerstyle";
    this.CellPadding = 0;
    this.CellSpacing = 0;
    this.BorderWidth = 1;//表格边框高度
    this.BorderStyle = (BorderStyle)Enum.Parse(typeof(BorderStyle),"Outset");//表格边框样式
    this.AutoGenerateColumns = false;//不允许自动绑定
    } [Category("属性"),DefaultValue("")] 
    public string Text 
    {
    get
    {
    return text;
    } set
    {
    text = value;
    }
    } /// <summary> 
    /// 将此控件呈现给指定的输出参数。
    /// </summary>
    /// <param name="output"> 要写出到的 HTML 编写器 </param>
    protected override void Render(HtmlTextWriter output)
    {
    output.Write(Text);
    base.Render(output);
    }
    }
    }
    webform1.aspx:<%@ Register TagPrefix="cc1" Namespace="WebControlLibrary1" Assembly="WebControlLibrary1" %><form id=Form1 method=post runat="server">
    *****************************
    <cc1:CusGrid id="CusGrid1" runat="server" CellPadding="0" BorderWidth="1px" BorderStyle="Outset">
    <Columns>
    <asp:TemplateColumn HeaderText="Hello World">
    <ItemTemplate>
    <asp:Literal ID="lit" Runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"au_fname").ToString() + " " + DataBinder.Eval(Container.DataItem,"au_lname").ToString()%>' />
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    </cc1:CusGrid>
    *****************************
    </form>
    cs code:                 SqlDataAdapter da = new SqlDataAdapter("select * from authors",
    "server=(local);database=pubs;uid=sa;pwd=;");
    DataTable dt = new DataTable();
    da.Fill(dt);

    CusGrid1.Text = "hello world";
    CusGrid1.DataSource = dt.DefaultView;
    CusGrid1.DataBind();
      

  11.   

    for a custom control to work, you must have a namespace